- (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.
Related
My app keeps crashing whenever I tap on a UITextField that I add to my view programmatically. Here is the stack trace if it is of any help:
'NSInvalidArgumentException', reason: '-[Clifford_Bradford.OtherVehiclesViewController numOfOtherVehiclesUpdated:]: unrecognized selector sent to instance 0x7fd92a57f8d0'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107e5dc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001099c8bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000107e650ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000107dbb13c ___forwarding___ + 988
4 CoreFoundation 0x0000000107dbacd8 _CF_forwarding_prep_0 + 120
5 UIKit 0x00000001086fdd62 -[UIApplication sendAction:to:from:forEvent:] + 75
6 UIKit 0x000000010880f50a -[UIControl _sendActionsForEvents:withEvent:] + 467
7 UIKit 0x0000000108e26d39 -[UITextField _resignFirstResponder] + 256
8 UIKit 0x0000000108e26bab -[UITextField _finishResignFirstResponder] + 45
9 UIKit 0x000000010888078b -[UIResponder resignFirstResponder] + 114
10 UIKit 0x0000000108e26b04 -[UITextField resignFirstResponder] + 114
11 UIKit 0x0000000108880575 -[UIResponder becomeFirstResponder] + 284
12 UIKit 0x000000010876fb81 -[UIView(Hierarchy) becomeFirstResponder] + 99
13 UIKit 0x0000000108e26307 -[UITextField becomeFirstResponder] + 51
14 UIKit 0x0000000108ab5d4e -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 177
15 UIKit 0x0000000108ab7dc0 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 2263
16 UIKit 0x0000000108aad656 _UIGestureRecognizerSendActions + 262
17 UIKit 0x0000000108aac2f9 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 532
18 UIKit 0x0000000108ab0f16 ___UIGestureRecognizerUpdate_block_invoke662 + 51
19 UIKit 0x0000000108ab0e12 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 254
20 UIKit 0x0000000108aa6e8d _UIGestureRecognizerUpdate + 2796
21 UIKit 0x000000010874a646 -[UIWindow _sendGesturesForEvent:] + 1041
22 UIKit 0x000000010874b272 -[UIWindow sendEvent:] + 666
23 UIKit 0x0000000108711541 -[UIApplication sendEvent:] + 246
24 UIKit 0x000000010871ecdc _UIApplicationHandleEventFromQueueEvent + 18265
25 UIKit 0x00000001086f959c _UIApplicationHandleEventQueue + 2066
26 CoreFoundation 0x0000000107d91431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
27 CoreFoundation 0x0000000107d872fd __CFRunLoopDoSources0 + 269
28 CoreFoundation 0x0000000107d86934 __CFRunLoopRun + 868
29 CoreFoundation 0x0000000107d86366 CFRunLoopRunSpecific + 470
30 GraphicsServices 0x000000010be31a3e GSEventRunModal + 161
31 UIKit 0x00000001086fc8c0 UIApplicationMain + 1282
32 Clifford Bradford 0x0000000107c33bb7 main + 135
33 libdyld.dylib 0x000000010a0fe145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException`.
It just points me to the first line of the AppDelegate.swift which doesn't really help me. Here is the corresponding code that adds the textField to the view. I would like to add that the contView is inside a scrollView.
var otherVehiclePlateNum:UITextField = UITextField(frame: CGRectMake(carLabel.bounds.origin.x + 15, carLabel.frame.maxY + 10, self.contView.frame.width - 30, 25))
otherVehiclePlateNum.placeholder = "TEST"
self.contView.addSubview(otherVehiclePlateNum)
Thanks so much for your help, I've been stuck on this.
Look at the first line: Does the method numOfOtherVehiclesUpdated: actually exist in the OtherVehiclesViewController class? Make sure that that if you're calling any #selectors that the colon matches the signature (i.e., you may have a numOfOtherVehiclesUpdated method, which isn't the same as numOfOtherVehiclesUpdated: which takes a parameter).
Look there first - you may be calling that by accident
So, I'm having problems with my code.
It runs smoothly with iOS8 but when I run iOS7.1 simulator or run it through an iOS7.1 phone, I get this error.
*** First throw call stack:
(
0 CoreFoundation 0x004dd1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01afc8e5 objc_exception_throw + 44
2 CoreFoundation 0x0057a243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x004cd50b ___forwarding___ + 1019
4 CoreFoundation 0x004cd0ee _CF_forwarding_prep_0 + 14
5 testapp 0x00062e29 _TFC4hp2m14ViewController11viewDidLoadfS0_FT_T_ + 633
6 testapp 0x00063392 _TToFC4hp2m14ViewController11viewDidLoadfS0_FT_T_ + 34
7 UIKit 0x00d0133d -[UIViewController loadViewIfRequired] + 696
8 UIKit 0x00d015d9 -[UIViewController view] + 35
9 UIKit 0x00c21267 -[UIWindow addRootViewControllerViewIfPossible] + 66
10 UIKit 0x00c215ef -[UIWindow _setHidden:forced:] + 312
11 UIKit 0x00c2186b -[UIWindow _orderFrontWithoutMakingKey] + 49
12 UIKit 0x00c2c3c8 -[UIWindow makeKeyAndVisible] + 65
13 UIKit 0x00bdcbc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
14 UIKit 0x00be1667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
15 UIKit 0x00bf5f92 -[UIApplication handleEvent:withNewEvent:] + 3517
16 UIKit 0x00bf6555 -[UIApplication sendEvent:] + 85
17 UIKit 0x00be3250 _UIApplicationHandleEvent + 683
18 GraphicsServices 0x037c2f02 _PurpleEventCallback + 776
19 GraphicsServices 0x037c2a0d PurpleEventCallback + 46
20 CoreFoundation 0x00458ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
21 CoreFoundation 0x004589db __CFRunLoopDoSource1 + 523
22 CoreFoundation 0x0048368c __CFRunLoopRun + 2156
23 CoreFoundation 0x004829d3 CFRunLoopRunSpecific + 467
24 CoreFoundation 0x004827eb CFRunLoopRunInMode + 123
25 UIKit 0x00be0d9c -[UIApplication _run] + 840
26 UIKit 0x00be2f9b UIApplicationMain + 1225
27 testapp 0x0006cd9e top_level_code + 78
28 testapp 0x0006cddb main + 43
29 libdyld.dylib 0x023db6d9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
The error occurs at the first line of appdelegate:
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
My app imports corelocation, foundation and contactlist.
Check all the methods called in your ViewController (viewDidLoad method) you probably have a selector only available on iOS8.
To check the availability you can just right click on the method and check the documentation.
Here is an example for the showViewController:sender: method.
I'm trying to unwind segue form a scene. It works fine but I need to get a value to the parent screen. (I use the push segue to navigate from parent to child scene)
I'm calling the unwind segue like this
- (IBAction)done:(UIStoryboardSegue *)segue {
NSLog(#"gonna navigate");
RESTToppingTableViewController *vc = [segue destinationViewController];
[self setSelectedToppings:[vc toppingList]];
NSLog(#"%#", [vc toppingList]);
}
But the issue is, it seems the toppingList array is removed from memory even before the parent view is called.
Below is the error I got.
2013-12-06 13:26:42.192 Pizza to Go[2319:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RESTAddToCartViewController toppingList]: unrecognized selector sent to instance 0x9b681a0'
*** First throw call stack:
(
0 CoreFoundation 0x01f405e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01cc38b6 objc_exception_throw + 44
2 CoreFoundation 0x01fdd903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01f3090b ___forwarding___ + 1019
4 CoreFoundation 0x01f304ee _CF_forwarding_prep_0 + 14
5 Pizza to Go 0x0004a3a2 -[RESTAddToCartViewController done:] + 130
6 libobjc.A.dylib 0x01cd581f -[NSObject performSelector:withObject:] + 70
7 UIKit 0x010d01f1 -[UIStoryboardUnwindSegueTemplate _perform:] + 536
8 UIKit 0x00f660f9 -[UIStoryboardSegueTemplate perform:] + 115
9 libobjc.A.dylib 0x01cd5874 -[NSObject performSelector:withObject:withObject:] + 77
10 UIKit 0x00a330c2 -[UIApplication sendAction:to:from:forEvent:] + 108
11 UIKit 0x00d07c9b -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
12 libobjc.A.dylib 0x01cd5874 -[NSObject performSelector:withObject:withObject:] + 77
13 UIKit 0x00a330c2 -[UIApplication sendAction:to:from:forEvent:] + 108
14 UIKit 0x00a3304e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
15 UIKit 0x00b2b0c1 -[UIControl sendAction:to:forEvent:] + 66
16 UIKit 0x00b2b484 -[UIControl _sendActionsForEvents:withEvent:] + 577
17 UIKit 0x00b2a733 -[UIControl touchesEnded:withEvent:] + 641
18 UIKit 0x00a7051d -[UIWindow _sendTouchesForEvent:] + 852
19 UIKit 0x00a71184 -[UIWindow sendEvent:] + 1232
20 UIKit 0x00a44e86 -[UIApplication sendEvent:] + 242
21 UIKit 0x00a2f18f _UIApplicationHandleEventQueue + 11421
22 CoreFoundation 0x01ec983f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
23 CoreFoundation 0x01ec91cb __CFRunLoopDoSources0 + 235
24 CoreFoundation 0x01ee629e __CFRunLoopRun + 910
25 CoreFoundation 0x01ee5ac3 CFRunLoopRunSpecific + 467
26 CoreFoundation 0x01ee58db CFRunLoopRunInMode + 123
27 GraphicsServices 0x03e159e2 GSEventRunModal + 192
28 GraphicsServices 0x03e15809 GSEventRun + 104
29 UIKit 0x00a31d3b UIApplicationMain + 1225
30 Pizza to Go 0x000574ad main + 141
31 libdyld.dylib 0x0285e725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
What could be the possible fix? thanks for your time in advance.
I'm not sure but I think your destinationViewController isn't a RESTToppingTableViewController.
The log:
-[RESTAddToCartViewController toppingList]:
unrecognized selector sent to instance 0x9b681a0
states that you are trying to get the toppingList of a RESTAddToCartViewController but this controller has no toppingList property.
Make sure that the UIViewController returned by [segue destinationViewController] really is what you are expecting.
I am simply pushing a UITableviewController to navigation stack. Code works fine in both iOS 4.3 and 5 but crashes in iOS 6. Exception is:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "MenuController" nib but the view outlet was not set.'
I know this exception is raised when view outlet is not set. Outlet is set automatically by IB as you can see in figure, but still the same. What am I doing wrong?
Simple code pushing the controller:
MenuController *menu = [[MenuController alloc] initWithStyle:UITableViewStylePlain];
menu.title = #"Watches";
menu.MenuToBeDisplayed = #"main menu";
[self.navigationController pushViewController:menu animated:YES];
Stack trace is:
0 CoreFoundation 0x01f3e02e __exceptionPreprocess + 206
1 libobjc.A.dylib 0x01a12e7e objc_exception_throw + 44
2 CoreFoundation 0x01f3ddeb +[NSException raise:format:] + 139
3 UIKit 0x00a3af18 -[UIViewController _loadViewFromNibNamed:bundle:] + 505
4 UIKit 0x00a3b418 -[UIViewController loadView] + 302
5 UIKit 0x00b8934e -[UITableViewController loadView] + 80
6 UIKit 0x00a3b648 -[UIViewController loadViewIfRequired] + 73
7 UIKit 0x00a3b882 -[UIViewController view] + 33
8 UIKit 0x00a3bb2a -[UIViewController contentScrollView] + 36
9 UIKit 0x00a52ef5 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 36
10 UIKit 0x00a52fdb -[UINavigationController _layoutViewController:] + 43
11 UIKit 0x00a53286 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 254
12 UIKit 0x00a53381 -[UINavigationController _startTransition:fromViewController:toViewController:] + 72
13 UIKit 0x00a53eab -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
14 UIKit 0x00a544a3 -[UINavigationController pushViewController:transition:forceImmediate:] + 1030
15 UIKit 0x00a54098 -[UINavigationController pushViewController:animated:] + 62
16 Tick 0x000e5f02 -[MarketWatchViewController openMenu] + 274
17 libobjc.A.dylib 0x01a26705 -[NSObject performSelector:withObject:withObject:] + 77
18 UIKit 0x0095d920 -[UIApplication sendAction:to:from:forEvent:] + 96
19 UIKit 0x00b99b24 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
20 libobjc.A.dylib 0x01a26705 -[NSObject performSelector:withObject:withObject:] + 77
21 UIKit 0x0095d920 -[UIApplication sendAction:to:from:forEvent:] + 96
22 UIKit 0x0095d8b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
23 UIKit 0x00a1e671 -[UIControl sendAction:to:forEvent:] + 66
24 UIKit 0x00a1ebcf -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
25 UIKit 0x00a1dd38 -[UIControl touchesEnded:withEvent:] + 546
26 UIKit 0x0098d33f -[UIWindow _sendTouchesForEvent:] + 846
27 UIKit 0x0098d552 -[UIWindow sendEvent:] + 273
28 UIKit 0x0096b3aa -[UIApplication sendEvent:] + 436
29 UIKit 0x0095ccf8 _UIApplicationHandleEvent + 9874
30 GraphicsServices 0x0291adf9 _PurpleEventCallback + 339
31 GraphicsServices 0x0291aad0 PurpleEventCallback + 46
32 CoreFoundation 0x01eb3bf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
33 CoreFoundation 0x01eb3962 __CFRunLoopDoSource1 + 146
34 CoreFoundation 0x01ee4bb6 __CFRunLoopRun + 2118
35 CoreFoundation 0x01ee3f44 CFRunLoopRunSpecific + 276
36 CoreFoundation 0x01ee3e1b CFRunLoopRunInMode + 123
37 GraphicsServices 0x029197e3 GSEventRunModal + 88
38 GraphicsServices 0x02919668 GSEventRun + 104
39 UIKit 0x0095a65c UIApplicationMain + 1211
40 Tick 0x00002dc5 main + 197
41 Tick 0x00002cb5 start + 53
EDIT:
I have removed nib file, and also initWithNibName: method, but I am still getting this stupid exception since yesterday. This will drive me crazy :(
With
MenuController *menu = [[MenuController alloc] initWithStyle:UITableViewStylePlain];
You aren't using your xib file at all becouse for initing contreoller with xib you need to use
initWithNibName:bundle: instead of initWithStyle:
and then set your controller's class on xib like this
I wanted to know why I have this crash in my iOS app (deployment target iOS 4.3 - xcode 4).
I tested in iPad simulator 5.0 to 6.1 and worked 100% but in my iPad with iOS 4.3 (well, it's not mine so I can't update the iOS but it's good to practice with old iOS version) crash the app saying this:
2013-02-07 16:07:45.093 GeoRuta[169:707] -[mainViewController presentViewController:animated:completion:]: unrecognized selector sent to instance 0x331960
2013-02-07 16:07:45.113 GeoRuta[169:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[mainViewController presentViewController:animated:completion:]: unrecognized selector sent to instance 0x331960'
*** Call stack at first throw:
(
0 CoreFoundation 0x30f8064f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x32828c5d objc_exception_throw + 24
2 CoreFoundation 0x30f841bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x30f83649 ___forwarding___ + 508
4 CoreFoundation 0x30efa180 _CF_forwarding_prep_0 + 48
5 GeoRuta 0x00003781 -[mainViewController saltarConfiguracion:] + 184
6 CoreFoundation 0x30ef0571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 24
7 UIKit 0x3575eec9 -[UIApplication sendAction:to:from:forEvent:] + 84
8 UIKit 0x3575ee69 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
9 UIKit 0x3575ee3b -[UIControl sendAction:to:forEvent:] + 38
10 UIKit 0x3575eb8d -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 356
11 UIKit 0x3575f423 -[UIControl touchesEnded:withEvent:] + 342
12 UIKit 0x3575dbf5 -[UIWindow _sendTouchesForEvent:] + 368
13 UIKit 0x3575d56f -[UIWindow sendEvent:] + 262
14 UIKit 0x35746313 -[UIApplication sendEvent:] + 298
15 UIKit 0x35745c53 _UIApplicationHandleEvent + 5090
16 GraphicsServices 0x31a4de77 PurpleEventCallback + 666
17 CoreFoundation 0x30f57a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
18 CoreFoundation 0x30f5983f __CFRunLoopDoSource1 + 166
19 CoreFoundation 0x30f5a60d __CFRunLoopRun + 520
20 CoreFoundation 0x30eeaec3 CFRunLoopRunSpecific + 230
21 CoreFoundation 0x30eeadcb CFRunLoopRunInMode + 58
22 GraphicsServices 0x31a4d41f GSEventRunModal + 114
23 GraphicsServices 0x31a4d4cb GSEventRun + 62
24 UIKit 0x35770d69 -[UIApplication _run] + 404
25 UIKit 0x3576e807 UIApplicationMain + 670
26 GeoRuta 0x000030a9 main + 172
27 GeoRuta 0x00002ff8 start + 40
)
terminate called after throwing an instance of 'NSException'
The selector is:
- (IBAction) saltarConfiguracion: (id)sender
{
configuracionViewController *obj = [[configuracionViewController alloc]initWithNibName:#"configuracionViewController" bundle:nil];
[self presentViewController:obj animated:YES completion:nil];
}
Because [self presentViewController:obj animated:YES completion:nil] is a new iOS 5 methods. You can't use it on iOS 4. Instead, try calling [self presentModalViewController:obj animated:YES] (something like that)