I am learning how to develop iPhone applications and I ran into an interesting problem. In my view controller class, I have a an int variable that I #synthesize and overload the setter (though) this is not needed. When I run the application, I get this trace back:
*** Call stack at first throw:
(
0 CoreFoundation 0x024e0919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0262e5de objc_exception_throw + 47
2 CoreFoundation 0x024e242b -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x02452116 ___forwarding___ + 966
4 CoreFoundation 0x02451cd2 _CF_forwarding_prep_0 + 50
5 Awesome App 0x00001ff1 -[Controller refreshView] + 69
6 Awesome App 0x00002180 -[Controller awakeFromNib] + 133
7 UIKit 0x004a3924 -[UINib instantiateWithOwner:options:] + 1556
8 UIKit 0x004a54b5 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x002b49bb -[UIApplication _loadMainNibFile] + 172
10 UIKit 0x002b590d -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 198
11 UIKit 0x002bf452 -[UIApplication handleEvent:withNewEvent:] + 1958
12 UIKit 0x002b8074 -[UIApplication sendEvent:] + 71
13 UIKit 0x002bcac4 _UIApplicationHandleEvent + 7495
14 GraphicsServices 0x02d46afa PurpleEventCallback + 1578
15 CoreFoundation 0x024c1dc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x02422737 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x0241f9c3 __CFRunLoopRun + 979
18 CoreFoundation 0x0241f280 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x0241f1a1 CFRunLoopRunInMode + 97
20 UIKit 0x002b5226 -[UIApplication _run] + 625
21 UIKit 0x002c0b58 UIApplicationMain + 1160
22 Awesome App 0x00001e4c main + 102
23 Awesome App 0x00001ddd start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
My attention got drawn to line 2. This happens when I try to assign an int value to my class iVar. Please can you tell me what the problem is and how to fix this?
Thanks a million.
Well, yeah. The default implementation of doesNotRecognizeSelector: is supposed to kill your program. That's not the problem. The problem is that you're sending an object a message it can't respond to. In this case, it looks like Controller can't respond to the message refreshView.
Let the exception be thrown and let the program crash on the uncaught exception. The exception contains all the information you need. You should see a log line that identifies the target of the method invocation and what method (that doesn't exist) was trying to be invoked.
Related
I am having a strange problem in xcode. i created a button in xib and connected to a function. I am printing the message inside the function. That's all, when i click the button i get the following error. I tried clean and deleted app from my simulator.
-(IBAction)languageSelection:(id)sender is my function name
-[NSCFString languageSelection:]: unrecognized selector sent to instance 0x713cd40
2012-05-03 15:14:35.055 Example[33420:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString languageSelection:]: unrecognized selector sent to instance 0x713cd40'
*** Call stack at first throw:
(
0 CoreFoundation 0x02966919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x02ab45de objc_exception_throw + 47
2 CoreFoundation 0x0296842b -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x028d8116 ___forwarding___ + 966
4 CoreFoundation 0x028d7cd2 _CF_forwarding_prep_0 + 50
5 UIKit 0x005ece14 -[UIApplication sendAction:to:from:forEvent:] + 119
6 UIKit 0x006766c8 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x00678b4a -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
8 UIKit 0x006776f7 -[UIControl touchesEnded:withEvent:] + 458
9 UIKit 0x006102ff -[UIWindow _sendTouchesForEvent:] + 567
10 UIKit 0x005f21ec -[UIApplication sendEvent:] + 447
11 UIKit 0x005f6ac4 _UIApplicationHandleEvent + 7495
12 GraphicsServices 0x02dedafa PurpleEventCallback + 1578
13 CoreFoundation 0x02947dc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
14 CoreFoundation 0x028a8737 __CFRunLoopDoSource1 + 215
15 CoreFoundation 0x028a59c3 __CFRunLoopRun + 979
16 CoreFoundation 0x028a5280 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x028a51a1 CFRunLoopRunInMode + 97
18 GraphicsServices 0x02dec2c8 GSEventRunModal + 217
19 GraphicsServices 0x02dec38d GSEventRun + 115
20 UIKit 0x005fab58 UIApplicationMain + 1160
21 Example 0x000023c9 main + 121
22 Example 0x00002345 start + 53
)
terminate called after throwing an instance of 'NSException'
this is perhaps you are trying to call a method languageSelection with object that is infact string, but you have passed into another object which has languageSelection method.
this is because you think the object is what you want but the pointer passed the allocated memory to string and hence it will work as string. when you try to call method it crashes because it didn't find the method in string. check your object type just before u use it anywhere
I am trying to run the Apple's Scrolling Sample Code, but I get following Error:
Scrolling[45877:207] Unknown class ScrollingAppDelegate in Interface Builder file.
Scrolling[45877:207] Unknown class ScrollingViewController in Interface Builder file.
Scrolling[45877:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UICustomObject 0x4b33330> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key viewController.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00f0cbe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x010615c2 objc_exception_throw + 47
2 CoreFoundation 0x00f0cb21 -[NSException raise] + 17
3 Foundation 0x000306cf _NSSetUsingKeyValueSetter + 135
4 Foundation 0x0003063d -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x004af8d6 -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x00e832cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x004ae2ed -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x004b0081 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x002ba943 -[UIApplication _loadMainNibFile] + 172
10 UIKit 0x002bb4ca -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
11 UIKit 0x002c5db2 -[UIApplication handleEvent:withNewEvent:] + 1533
12 UIKit 0x002be202 -[UIApplication sendEvent:] + 71
13 UIKit 0x002c3732 _UIApplicationHandleEvent + 7576
14 GraphicsServices 0x01842a36 PurpleEventCallback + 1550
15 CoreFoundation 0x00eee064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x00e4e6f7 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x00e4b983 __CFRunLoopRun + 979
18 CoreFoundation 0x00e4b240 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x00e4b161 CFRunLoopRunInMode + 97
20 UIKit 0x002bafa8 -[UIApplication _run] + 636
21 UIKit 0x002c742e UIApplicationMain + 1160
22 Scrolling 0x0000279c main + 102
23 Scrolling 0x0000272d start + 53
)
terminate called after throwing an instance of 'NSException'
The weird thing is, that I can't find those connections in the MainWindow.xib (The only xib file). The Outlets are properly connected to the AppDelegate and MyViewController classes.
The Runtime cannot find a way to create an instance of the classes "ScrollingAppDelegate" and "ScrollingViewController", which are serialized in the xib file. So it defaults to UICustomObject, which you don't have either.
Are you sure those classes exist in your source file(s) and that they are compiled correctly (i.e., part of the "Compile" build phase)?
Also check the spelling and the capitalization of the classes. It has to match between the xib files and the source files.
If something is wrong, there could be a yellow warning dot in the xib file (bottom-right). Click it for more info.
Finally, the sample code is marked as iOS4+. Do you have iOS 4 on your device?
I had two apps in xcode, which i wanted to combine, so i started a new project and attempted to put the two apps together in this new one. Was this a really stupid thing to do?
The app now crashes on start up and i have no idea why, i'm 99% the outlets are all connected. It uses xcdatamodel for storage and i've imported the right framework.
Can anyone think of any other things that could be going wrong?
I can attach a zip file with the project in if someone wouldn't mind having a look
Any help is massively appreciated!
Thanks
This is the stack trace:
2010-11-02 08:18:59.903 iStalker[34745:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x5b10e20> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key textField.'
*** Call stack at first throw:
(
0 CoreFoundation 0x0256f919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x026bd5de objc_exception_throw + 47
2 CoreFoundation 0x0256f851 -[NSException raise] + 17
3 Foundation 0x0003bc2b _NSSetUsingKeyValueSetter + 135
4 Foundation 0x0003bb99 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x004b5d0a -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x024e5b6f -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x004b4721 -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x004b64b5 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x002c59bb -[UIApplication _loadMainNibFile] + 172
10 UIKit 0x002c690d -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 198
11 UIKit 0x002d0452 -[UIApplication handleEvent:withNewEvent:] + 1958
12 UIKit 0x002c9074 -[UIApplication sendEvent:] + 71
13 UIKit 0x002cdac4 _UIApplicationHandleEvent + 7495
14 GraphicsServices 0x02dd5afa PurpleEventCallback + 1578
15 CoreFoundation 0x02550dc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x024b1737 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x024ae9c3 __CFRunLoopRun + 979
18 CoreFoundation 0x024ae280 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x024ae1a1 CFRunLoopRunInMode + 97
20 UIKit 0x002c6226 -[UIApplication _run] + 625
21 UIKit 0x002d1b58 UIApplicationMain + 1160
22 iStalker 0x00001b50 main + 102
23 iStalker 0x00001ae1 start + 53
)
terminate called after throwing an instance of 'NSException'
Looks like you have a text field connected to the application delegate in your main XIB. There is no such field defined on the real application delegate, which is why you’re getting the error.
Thats because you set main xib for app in info plist and set File Owner to appDelegate, while main xib file's owner is always UIApplication. Possible solution - add Object to .xib, set its class for appDelegate class and connect all unnecessary outlets. This worked for me.
I'm pushing a simple view onto a NavigationController. The view loads fine, and when I use the built-in back button, it is properly popped.
However, when I try and pop the view with my own UIButton within the view, I get a crash.
This is the action run by my UIButton:
-(IBAction)iAgreePressed {
[[self navigationController] popViewControllerAnimated:YES];}
Am I missing something obvious here?
This is the error coming back in the console:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LegalAgreementController iAgreePressed:]: unrecognized selector sent to instance 0x6169190'
*** Call stack at first throw:
(
0 CoreFoundation 0x0283ab99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0298a40e objc_exception_throw + 47
2 CoreFoundation 0x0283c6ab -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x027ac2b6 ___forwarding___ + 966
4 CoreFoundation 0x027abe72 _CF_forwarding_prep_0 + 50
5 UIKit 0x002d67f8 -[UIApplication sendAction:to:from:forEvent:] + 119
6 UIKit 0x00361de0 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x00364262 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
8 UIKit 0x00362e0f -[UIControl touchesEnded:withEvent:] + 458
9 UIKit 0x002fa3d0 -[UIWindow _sendTouchesForEvent:] + 567
10 UIKit 0x002dbcb4 -[UIApplication sendEvent:] + 447
11 UIKit 0x002e09bf _UIApplicationHandleEvent + 7672
12 GraphicsServices 0x02f57822 PurpleEventCallback + 1550
13 CoreFoundation 0x0281bff4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
14 CoreFoundation 0x0277c807 __CFRunLoopDoSource1 + 215
15 CoreFoundation 0x02779a93 __CFRunLoopRun + 979
16 CoreFoundation 0x02779350 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x02779271 CFRunLoopRunInMode + 97
18 GraphicsServices 0x02f5600c GSEventRunModal + 217
19 GraphicsServices 0x02f560d1 GSEventRun + 115
20 UIKit 0x002e4af2 UIApplicationMain + 1160
21 WeiglWorksMobileCommander 0x00001fa2 main + 84
22 WeiglWorksMobileCommander 0x00001f45 start + 53
23 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Thank you for your time!
Method signatures don't match. The button is sending
-[LegalAgreementController iAgreePressed:]
but you defined
-[LegalAgreementController iAgreePressed] //(note one arg versus no arg)
IBActions should be defined as:
- (IBAction) someMethod:(id)sender
You don't strictly have to include that arg, but you want to for consistency.
I recently tried to integrate open feint into my app. When my app launches, the 'Welcome back player xxxx' at the bottom works so I know that open feint is working. However, when I press the button that has this linked to it
-(IBAction) leaderboard: (id) sender
{
[OpenFeint launchDashboard];
}
I get this error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DemoAppViewController leaderboard]: unrecognized selector sent to instance 0x7a40250'
*** Call stack at first throw:
(
0 CoreFoundation 0x02d71919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x02ebf5de objc_exception_throw + 47
2 CoreFoundation 0x02d7342b -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x02ce3116 ___forwarding___ + 966
4 CoreFoundation 0x02ce2cd2 _CF_forwarding_prep_0 + 50
5 UIKit 0x00695e14 -[UIApplication sendAction:to:from:forEvent:] + 119
6 UIKit 0x0071f6c8 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x00721b4a -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
8 UIKit 0x007206f7 -[UIControl touchesEnded:withEvent:] + 458
9 UIKit 0x006b92ff -[UIWindow _sendTouchesForEvent:] + 567
10 UIKit 0x0069b1ec -[UIApplication sendEvent:] + 447
11 UIKit 0x0069fac4 _UIApplicationHandleEvent + 7495
12 GraphicsServices 0x032f3afa PurpleEventCallback + 1578
13 CoreFoundation 0x02d52dc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
14 CoreFoundation 0x02cb3737 __CFRunLoopDoSource1 + 215
15 CoreFoundation 0x02cb09c3 __CFRunLoopRun + 979
16 CoreFoundation 0x02cb0280 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x02cb01a1 CFRunLoopRunInMode + 97
18 GraphicsServices 0x032f22c8 GSEventRunModal + 217
19 GraphicsServices 0x032f238d GSEventRun + 115
20 UIKit 0x006a3b58 UIApplicationMain + 1160
21 DemoApp 0x00004f84 main + 102
22 DemoApp 0x00004f15 start + 53
)
terminate called after throwing an instance of 'NSException'
I haven't been able to find any post on how to resolve this so any help would be greatly appreciated! Thanks in advance
From the exception it looks to me as if you tried to message your object with leaderboard when the method requires one argument and as such you should call it with one.
That is, it looks like you are doing something like this:
[someDemoAppViewControllerObject leaderboard]
When your should be doing this:
[someDemoAppViewControllerObject leaderboard:theSenderObject]
Quite often self is used as theSenderObject.
is
-(IBAction) leaderboard: (id) sender
declared in the .h file?