When running my app, it crashes and I don't see something wrong with my code. Please help me to find this issue.
Here is the code in method didSelectRow in UITableViewDelegate, where it crashes:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[[SingletonClass SharedMethod] setGlobalAddSubjectResueIdentifier:#"ForListDetails"];
[self.tblSearchHolder deselectRowAtIndexPath:[self.tblSearchHolder indexPathForSelectedRow] animated:YES];
NSDictionary *dictGGetSelectedVal=[arrLoadDataTemp objectAtIndex:indexPath.row];
[[SingletonClass SharedMethod] setGlobalSelectedSearchProperty:dictGGetSelectedVal];
arrGetValForTable=nil;
arrLoadDataTemp=nil;
[[SingletonClass SharedMethod] setGlobalHolder:#"addPropertyScene"];
[[NSNotificationCenter defaultCenter] postNotificationName:#"ChangeViewsAsPerCriteria" object:nil];
}
And the crash report itself:
NSInvalidArgumentException: Cannot create task from nil request
18 UIKit 0x18d7f8b20 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] (in UIKit) + 1352
19 UIKit 0x18d8a1760 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] (in UIKit) + 268
20 UIKit 0x18d94faa8 _runAfterCACommitDeferredBlocks (in UIKit) + 292
21 UIKit 0x18d942e5c _cleanUpAfterCAFlushAndRunDeferredBlocks (in UIKit) + 288
22 UIKit 0x18d6d4464 _afterCACommitHandler (in UIKit) + 132
23 CoreFoundation 0x1840cecdc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ (in CoreFoundation) + 32
24 CoreFoundation 0x1840cc694 __CFRunLoopDoObservers (in CoreFoundation) + 412
25 CoreFoundation 0x1840ccc50 __CFRunLoopRun (in CoreFoundation) + 1292
26 CoreFoundation 0x183fecc58 CFRunLoopRunSpecific (in CoreFoundation) + 436
27 GraphicsServices 0x185e98f84 GSEventRunModal (in GraphicsServices) + 100
28 UIKit 0x18d7455c4 UIApplicationMain (in UIKit) + 236
29 EnrichedValues 0x100dd6cc8 0x100d80000 + 355528
30 libdyld.dylib 0x183b0c56c start (in libdyld.dylib) + 4
Ok, it can be found quite easily (with a bit of luck :)).
First of all, try to enable NSZombie objects as follows:
Try to put an exception breakpoint as follows (make sure you're on the breakpoint's tab):
Good luck & happy coding! :)
Related
In my iPhone app, for some users the app will always crash, whenever they open a certain window. The same window works fine for me and other people, but always causes a crash for some people. It is unclear at this moment what the difference is between people for whom it fails, and for whom it works fine.
The animation to open the specific view will run fine, but will then cause a crash immediately after the animation is finished.
They have sent me the crashlog, but it is hard to understand what is exactly going wrong. I am hoping you can help me understand. The cause for the failure as given by the crashlog is the following exception:
Last Exception Backtrace:
0 CoreFoundation 0x1836ffd38 __exceptionPreprocess + 124
1 libobjc.A.dylib 0x182c14528 objc_exception_throw + 55
2 CoreFoundation 0x18370d1f8 -[NSObject+ 1372664 (NSObject) doesNotRecognizeSelector:] + 139
3 UIKit 0x18cec7cc4 -[UIResponder doesNotRecognizeSelector:] + 295
4 CoreFoundation 0x1837056e4 ___forwarding___ + 1379
5 CoreFoundation 0x1835eb0dc _CF_forwarding_prep_0 + 91
6 CoreFoundation 0x1835d6be8 CFStringAppend + 519
7 CoreFoundation 0x1836bddf0 __CFStringAppendFormatCore + 9271
8 CoreFoundation 0x1836bf658 _CFStringCreateWithFormatAndArgumentsAux2 + 131
9 AccessibilityUtilities 0x192d6b388 _AXStringForArgs + 279
10 UIKit 0x1a242adf8 -[UIViewControllerAccessibility viewDidAppear:] + 267
11 UIKit 0x18cb2869c -[UIViewController _setViewAppearState:isAnimating:] + 851
12 UIKit 0x18cb28c08 -[UIViewController _endAppearanceTransition:] + 227
13 UIKit 0x18cbcee00 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 1327
14 UIKit 0x1a2440cd4 -[UINavigationControllerAccessibility navigationTransitionView:didEndTransition:fromView:toView:] + 111
15 UIKit 0x18cc96bbc __49-[UINavigationController _startCustomTransition:]_block_invoke + 251
16 UIKit 0x18cc229d8 -[_UIViewControllerTransitionContext completeTransition:] + 115
17 UIKit 0x18cd67d30 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke.124 + 751
18 UIKit 0x18cb47d7c -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 763
19 UIKit 0x18cb4770c -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 311
20 UIKit 0x18cb47418 -[UIViewAnimationState animationDidStop:finished:] + 295
21 UIKit 0x1a2468970 -[UIViewAnimationStateAccessibility animationDidStop:finished:] + 131
22 QuartzCore 0x1876ebd6c CA::Layer::run_animation_callbacks+ 1232236 (void*) + 283
23 libdispatch.dylib 0x183085048 _dispatch_client_callout + 15
24 libdispatch.dylib 0x183091b74 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1015
25 CoreFoundation 0x1836a7f20 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 11
26 CoreFoundation 0x1836a5afc __CFRunLoopRun + 2011
27 CoreFoundation 0x1835c62d8 CFRunLoopRunSpecific + 435
28 GraphicsServices 0x185457f84 GSEventRunModal + 99
29 UIKit 0x18cb73880 UIApplicationMain + 207
30 Flyskyhy 0x10490bd80 main + 32128 (main.m:17)
31 libdyld.dylib 0x1830ea56c start + 3
The crashlog seems to indicate that it goes wrong while doing a CFStringAppend, but it is not clear which string is the problem, or what is wrong with it, or even why a CFStringAppend is needed. All strings visible in the view have been filled in already before the animation starts, and they all are correct.
EDIT:
As requested, here is the code that starts the view. Everything is under a NavigationController, so the new view controller is pushed on the navigation stack to open it.
WaypointEditController *controller = [[WaypointEditController alloc] initWithNibName:#"WayPointEdit" bundle:nil];
controller.navigationItem.title = #"New Waypoint";
// initialisation of other, custom, fields of controller
[self.navigationController pushViewController:controller animated:YES];
The WaypointEditController class that is pushed is derived from UIViewController. The viewWillAppear is overridden, to do initialisation of the fields of the view. But - relevant here - viewDidAppear is not overridden.
In case relevant, here are the most important actions in the viewWillAppear method:
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
self.navigationItem.title = #"New Waypoint";
// other initialisation of internal fields
}
Like you, I have customers reporting this problem and I could see the stack traces that XCode downloaded from production but I could not reproduce it... until I tried enabling "voice over".
The other accessibility options that I tried worked OK.
The stack trace shows that iOS is sending a selector of "length" to an instance of UILabel. This seemed odd. To see what would happen, I added a "length" method to UILabel to return the length of the UILabel's text property. Then it just failed with an unknown selector of _encodingCantBeStoredInEightBitCFString. So clearly iOS thought that my UILabel was something that it wasn't.
This ended up being because "description" was used for the name of my UILabel property/IBOutlet.
To fix the problem I renamed the property from "description" to something different. I suspect that my synthesized "description" getter was overriding NSObject's description method (which returns an NSString which fits the selectors which were being sent to my UILabel).
I have a crash occurring in life app which I can not reproduce on my devices. I have not been able to figure out what causes it. I studied to crash report but seem not to be able to understand what is causing this.
1 CoreFoundation __exceptionPreprocess + 1241536
2 libobjc.A.dylib objc_exception_throw + 34136
3 CoreFoundation -[NSObject(NSObject) doesNotRecognizeSelector:] + 1270388
4 CoreFoundation ___forwarding___ + 1258100
5 CoreFoundation _CF_forwarding_prep_0 + 185752
6 GLKit -[GLKViewController setPaused:] + 144836
7 GLKit -[GLKViewController _pauseByNotification] + 142828
8 CoreFoundation __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 823848
9 CoreFoundation _CFXRegistrationPost + 821548
10 CoreFoundation ___CFXNotificationPost_block_invoke + 820904
11 CoreFoundation -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1276824
12 CoreFoundation _CFXNotificationPost + 44016
13 Foundation -[NSNotificationCenter postNotificationName:object:userInfo:] + 26152
14 UIKit -[UIApplication _deactivateForReason:notify:] + 491392
15 UIKit __61-[UIApplication _sceneSettingsPreLifecycleEventDiffInspector]_block_invoke + 2711892
16 FrontBoardServices __52-[FBSSettingsDiffInspector inspectDiff:withContext:]_block_invoke.27 + 144868
17 Foundation __NSIndexSetEnumerate + 788368
18 BaseBoard -[BSSettingsDiff inspectChangesWithBlock:] + 208636
19 FrontBoardServices -[FBSSettingsDiff inspectOtherChangesWithBlock:] + 120484
20 FrontBoardServices -[FBSSettingsDiffInspector inspectDiff:withContext:] + 144320
21 UIKit __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 2717116
22 UIKit -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 2716256
23 UIKit -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 6065056
24 FrontBoardServices __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke.376 + 52104
25 FrontBoardServices __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 239800
26 FrontBoardServices -[FBSSerialQueue _performNext] + 239396
27 FrontBoardServices -[FBSSerialQueue _performNextFromRunLoopSource] + 240332
28 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 905844
29 CoreFoundation __CFRunLoopDoSources0 + 904124
30 CoreFoundation __CFRunLoopRun + 894908
31 CoreFoundation CFRunLoopRunSpecific + 36932
32 GraphicsServices GSEventRunModal + 49556
33 UIKit -[UIApplication _run] + 504568
34 UIKit UIApplicationMain + 483376
35 XXX main (XXXViewController.swift:14)
36 libdyld.dylib
start + 17844
Line 35 (only mention of code I wrote) is the XXXViewController class definition line:
class XXXViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
...
}
This ViewController calls an observer, which seems to be the problem. I am making sure the I remove all observers in the ViewControllers that use them in the deinit function.
deinit {
NSNotificationCenter.defaultCenter().removeObserver(self)
}
Does anybody have an idea what else could be going wrong?
UPDATE:
I register the observer like this ini init() (should I use viewDidLoad instead?):
NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(YViewController.dataUpdate(_:)), name: "DataChanged", object: nil)
and post the notification like this:
NSNotificationCenter.defaultCenter().postNotificationName("DataChanged", object: self, userInfo: nil)
The YViewController dataUpdate is as follows:
func dataUpdate(notification: NSNotification) {
//Some stuff is done
}
I use swift 2.0 for now and the crash has happened on iOS version 10.0.1-10.1.1
Just in case anybody lands here. The problem was that I was overwriting the base view of the GLKViewController instead of adding the new view as a subview. This became easily clear, when I switched to Crashlytics, which had more information about the crash.
I've had this problem for a while and it's driving me nuts. This is reported by Crashlytics but only for a few users. I'm unable to recreate the problem myself.
I'm using a SplitViewController and this occurs after a user adds data within a UIViewController and touch the save button, which then returns to the SplitViewController to perform the method 'saveItemEntry' shown below.
I've tried a suggestion from a previous post which was to wrap the [self.tableView reloadData] with dispatch_async(dispatch_get_main_queue(), ^(void), but that actually made it worse. It isn't like the data takes ages to load, it doesn't, so I can't see that multi-tasking will help, but I'm open to advice on whether I should be doing that.
I'm really not clear on how to interperupt the crash info. If someone can and can suggest what might be causing this that would be awesome.
If more info is needed please let me know.
Here's the crash details:
Here's the Raw stuff..
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x20407ae2 objc_msgSend + 1
1 CoreFoundation 0x20b8391b -[NSDictionary descriptionWithLocale:indent:] + 310
2 Foundation 0x2136fe2d _NSDescriptionWithLocaleFunc + 60
3 CoreFoundation 0x20c011a3 __CFStringAppendFormatCore + 7986
4 CoreFoundation 0x20bff255 _CFStringCreateWithFormatAndArgumentsAux2 + 80
5 CoreFoundation 0x20c17559 _CFLogvEx2 + 96
6 CoreFoundation 0x20c179af _CFLogvEx3 + 118
7 Foundation 0x214374f7 _NSLogv + 126
8 Foundation 0x2137e79d NSLog + 28
9 UIKit 0x24eac5fb -[UITableView reloadData] + 1818
10 Simple Meeting Minutes 0xfb859 -[MMDetailTableVC saveItemEntry:] (MMDetailTableVC.m:1423)
11 Simple Meeting Minutes 0x10becf -[MMItemViewController saveButtonAction:] (MMItemViewController.m:526)
12 UIKit 0x24dfd771 -[UIApplication sendAction:to:from:forEvent:] + 80
13 UIKit 0x24f7ec71 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 140
14 UIKit 0x24dfd771 -[UIApplication sendAction:to:from:forEvent:] + 80
15 UIKit 0x24dfd701 -[UIControl sendAction:to:forEvent:] + 64
16 UIKit 0x24de561f -[UIControl _sendActionsForEvents:withEvent:] + 446
17 UIKit 0x24de574b -[UIControl _sendActionsForEvents:withEvent:] + 746
18 UIKit 0x24dfd051 -[UIControl touchesEnded:withEvent:] + 616
19 UIKit 0x24dfccbf -[UIWindow _sendTouchesForEvent:] + 646
20 UIKit 0x24df55d7 -[UIWindow sendEvent:] + 642
21 UIKit 0x24dc6119 -[UIApplication sendEvent:] + 204
22 UIKit 0x24dc4757 _UIApplicationHandleEventQueue + 5134
23 CoreFoundation 0x20bf1257 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
24 CoreFoundation 0x20bf0e47 __CFRunLoopDoSources0 + 454
25 CoreFoundation 0x20bef1af __CFRunLoopRun + 806
26 CoreFoundation 0x20b41bb9 CFRunLoopRunSpecific + 516
27 CoreFoundation 0x20b419ad CFRunLoopRunInMode + 108
28 GraphicsServices 0x21dbbaf9 GSEventRunModal + 160
29 UIKit 0x24e2dfb5 UIApplicationMain + 144
30 Simple Meeting Minutes 0xf5d6f main (main.m:16)
31 libdispatch.dylib 0x207f4873 (Missing)
and here's my code in this particular area..
- (void)saveItemEntry:(MMitem *)item{
if (item)
{
// save item to the sqlite3 database file
NSString *resultStr = [self.meetingModel saveItem:item];
if ([resultStr isEqualToString:#"OK"])
{
// all good so close form and refresh data
[self dismissViewControllerAnimated:NO completion:nil];
[self.tableView reloadData];
// or if there is an error result then display message
}
else if ([resultStr isEqualToString:#"DescriptionNotesMissing"])
{
[self showAlert:#"Missing Description or Notes" :#"An Item Description or Notes is required" :0];
[self.itemViewController.itemDescription becomeFirstResponder];
}
// for any other error do nothing
}
}
I'm getting a crash report from Crashlytics that is always in the same place but I'm unable to replicate the crash.
It seems to be only users on iOS 9 and only very occasionally. I'm not sure if it's a code issue or something else. The last line mentions libdispatch.dylib as being missing, again, not sure if relevant.
Crashlytics indicates that the crash occurs at MMDetailTableVC.m line 1407, which is the reloadData line.
Here's what is reported:
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000001
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x20f0fae2 objc_msgSend + 1
1 CoreFoundation 0x2168b91b -[NSDictionary descriptionWithLocale:indent:] + 310
2 Foundation 0x21e77e2d _NSDescriptionWithLocaleFunc + 60
3 CoreFoundation 0x217091a3 __CFStringAppendFormatCore + 7986
4 CoreFoundation 0x21707255 _CFStringCreateWithFormatAndArgumentsAux2 + 80
5 CoreFoundation 0x2171f559 _CFLogvEx2 + 96
6 CoreFoundation 0x2171f9af _CFLogvEx3 + 118
7 Foundation 0x21f3f4f7 _NSLogv + 126
8 Foundation 0x21e8679d NSLog + 28
9 UIKit 0x259b45fb -[UITableView reloadData] + 1818
10 Simple Meeting Minutes 0x91fff -[MMDetailTableVC saveItemEntry:] (MMDetailTableVC.m:1407)
11 Simple Meeting Minutes 0xa2edf -[MMItemViewController saveButtonAction:] (MMItemViewController.m:526)
12 UIKit 0x25905771 -[UIApplication sendAction:to:from:forEvent:] + 80
13 UIKit 0x25a86c71 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 140
14 UIKit 0x25905771 -[UIApplication sendAction:to:from:forEvent:] + 80
15 UIKit 0x25905701 -[UIControl sendAction:to:forEvent:] + 64
16 UIKit 0x258ed61f -[UIControl _sendActionsForEvents:withEvent:] + 446
17 UIKit 0x258ed74b -[UIControl _sendActionsForEvents:withEvent:] + 746
18 UIKit 0x25905051 -[UIControl touchesEnded:withEvent:] + 616
19 UIKit 0x25904cbf -[UIWindow _sendTouchesForEvent:] + 646
20 UIKit 0x258fd5d7 -[UIWindow sendEvent:] + 642
21 UIKit 0x258ce119 -[UIApplication sendEvent:] + 204
22 UIKit 0x258cc757 _UIApplicationHandleEventQueue + 5134
23 CoreFoundation 0x216f9257 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
24 CoreFoundation 0x216f8e47 __CFRunLoopDoSources0 + 454
25 CoreFoundation 0x216f71af __CFRunLoopRun + 806
26 CoreFoundation 0x21649bb9 CFRunLoopRunSpecific + 516
27 CoreFoundation 0x216499ad CFRunLoopRunInMode + 108
28 GraphicsServices 0x228c3af9 GSEventRunModal + 160
29 UIKit 0x25935fb5 UIApplicationMain + 144
30 Simple Meeting Minutes 0x8c59f main (main.m:16)
31 libdispatch.dylib 0x212fc873 (Missing)
And here's my code for saveItemEntry that always seems to be the place where the crash occurs.
- (void)saveItemEntry:(MMitem *)item{
if (item)
{
NSString *resultStr = [self.meetingModel saveItem:item];
if ([resultStr isEqualToString:#"OK"])
{
// all good so close form and refresh data
[_itemViewController dismissViewControllerAnimated:NO completion:nil];
[self.tableView reloadData];
// or if there is an error result then display message
}
else if ([resultStr isEqualToString:#"DescriptionNotesMissing"])
{
[self showAlert:#"Missing Description or Notes" :#"An Item Description or Notes is required" :0];
[self.itemViewController.itemDescription becomeFirstResponder];
}
// for any other error do nothing
}
}
We don't know if you are calling this method in main thread or not.
And also tableview is taking time in reloading it's cell. So it would be great, if you can add these codes in dispatch_get_main_queue
dispatch_async(dispatch_get_main_queue(), ^(void){
[_itemViewController dismissViewControllerAnimated:NO completion:nil];
[self.tableView reloadData];
}
and
dispatch_async(dispatch_get_main_queue(), ^(void){
[self showAlert:#"Missing Description or Notes" :#"An Item Description or Notes is required" :0];
[self.itemViewController.itemDescription becomeFirstResponder];
}
It will be much safe, if we are working on refreshing the UI from any notification or delegation with dispatch_async(dispatch_get_main_queue(), ^(void){
Hooray - finally found the reason for this elusive problem. The crash was being due to the user being in edit mode within a UITextfield within a cell in the table when the reloadData was being called (as a result of the user tapping elsewhere or rotating the iPad, which also called ReloadData).
I fixed the issue by preceeding any [self.tableView ReloadData] with [self.view endEditing:YES] to ensure that the keyboard was dismissed and cells were not in an edit mode.
Does make sense but what a nasty trap.
- (IBAction)startSignin:(id)sender {
Login *aview = [[Login alloc] init];
aview.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self.navigationController presentModalViewController:aview animated:YES];
[_window addSubview:aview.view];
[aview release];
}
What is causing my EXC BAD ACCESS?
Every time it loads Login, It crashes whenever i press a button or something on that page.
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f16313 objc_exception_throw + 44
2 CoreFoundation 0x00d7aef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x00d7ae6a +[NSException raise:format:] + 58
4 UIKit 0x000c6709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5 UIKit 0x000c4134 -[UIViewController loadView] + 120
6 UIKit 0x000c400e -[UIViewController view] + 56
7 UIKit 0x00037d42 -[UIWindow addRootViewControllerViewIfPossible] + 51
8 Test 0x00001b3c -[TestAppDelegate application:didFinishLaunchingWithOptions:] + 220
9 UIKit 0x00014c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
10 UIKit 0x00016d88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
11 UIKit 0x00021617 -[UIApplication handleEvent:withNewEvent:] + 1533
12 UIKit 0x00019abf -[UIApplication sendEvent:] + 71
13 UIKit 0x0001ef2e _UIApplicationHandleEvent + 7576
14 GraphicsServices 0x00ffb992 PurpleEventCallback + 1550
15 CoreFoundation 0x00da3944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x00d03cf7 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x00d00f83 __CFRunLoopRun + 979
18 CoreFoundation 0x00d00840 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x00d00761 CFRunLoopRunInMode + 97
20 UIKit 0x000167d2 -[UIApplication _run] + 623
21 UIKit 0x00022c93 UIApplicationMain + 1160
22 Test 0x00001a29 main + 121
23 Test 0x000019a5 start + 53
)
terminate called throwing an exceptionCurrent language: auto; currently objective-c
This is frequently caused by accessing an object after it is released. This is a good point to familiarize yourself with the debugger, too. Set a break point on the first line of the button action method, and step through it to find out which line is bad.
This time, i suspect it is your call to addSubview:, the presentModal… will take care of presenting the view.