int value not passing, unrecognized selector sent to instance Terminating app due to uncaught exception 'NSInvalidArgumentException' - objective-c

I'm trying to pass two integer values between different files but getting a error as mentioned in title.
Error at this line: - (NSString *) lookup: (NSString *)in get:(int)dictio get1:(int)dictio1;
Error File:
2014-02-05 13:27:48.019 MaisOui[4556:70b] Value of d: 10 d1: 0
2014-02-05 13:27:49.496 MaisOui[4556:70b] Value of d: 10 d1: 10
2014-02-05 13:27:56.405 MaisOui[4556:70b] -[MaisOuiDictionary lookup:]: unrecognized selector sent to instance 0x8c44d30
2014-02-05 13:27:56.409 MaisOui[4556:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MaisOuiDictionary lookup:]: unrecognized selector sent to instance 0x8c44d30'
*** First throw call stack:
(
0 CoreFoundation 0x0173f5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014c28b6 objc_exception_throw + 44
2 CoreFoundation 0x017dc903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0172f90b ___forwarding___ + 1019
4 CoreFoundation 0x0172f4ee _CF_forwarding_prep_0 + 14
5 MaisOui 0x00003299 -[MaisOuiViewController textFieldShouldReturn:] + 313
6 UIKit 0x0091761f -[UITextField keyboardInput:shouldInsertText:isMarkedText:] + 357
7 UIKit 0x004054f3 -[UIKeyboardImpl callShouldInsertText:] + 271
8 UIKit 0x0040f7d0 -[UIKeyboardImpl addWordTerminator:afterSpace:elapsedTime:executionContext:] + 63
9 UIKit 0x0040f2ca -[UIKeyboardImpl completeAcceptCandidateBeforeAddingInput:executionContext:] + 1668
10 UIKit 0x0040eba6 __60-[UIKeyboardImpl addInputString:withFlags:executionContext:]_block_invoke + 53
11 UIKit 0x0093ee7e -[UIKeyboardTaskExecutionContext returnExecutionToParent] + 254
12 UIKit 0x0041244b -[UIKeyboardImpl acceptCurrentCandidateIfSelectedWithExecutionContext:] + 250
13 UIKit 0x0040eb69 -[UIKeyboardImpl addInputString:withFlags:executionContext:] + 451
14 UIKit 0x0040da2f -[UIKeyboardImpl handleStringInput:withFlags:executionContext:] + 248
15 UIKit 0x0041bc1f -[UIKeyboardImpl handleKeyWithString:forKeyEvent:executionContext:] + 633
16 UIKit 0x0041b766 -[UIKeyboardImpl handleKeyEvent:executionContext:] + 1808
17 UIKit 0x0041afbf __33-[UIKeyboardImpl handleKeyEvent:]_block_invoke + 51
18 UIKit 0x0093f3c8 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 402
19 UIKit 0x0093fa6f -[UIKeyboardTaskQueue addTask:] + 144
20 UIKit 0x0041af84 -[UIKeyboardImpl handleKeyEvent:] + 227
21 UIKit 0x0024440b -[UIApplication _handleKeyUIEvent:] + 330
22 UIKit 0x0038afa4 -[UIResponder(Internal) _handleKeyUIEvent:] + 59
23 UIKit 0x0038afa4 -[UIResponder(Internal) _handleKeyUIEvent:] + 59
24 UIKit 0x0038afa4 -[UIResponder(Internal) _handleKeyUIEvent:] + 59
25 UIKit 0x0038afa4 -[UIResponder(Internal) _handleKeyUIEvent:] + 59
26 UIKit 0x002442ba -[UIApplication handleKeyUIEvent:] + 84
27 UIKit 0x0024425e -[UIApplication handleKeyHIDEvent:] + 458
28 UIKit 0x0022c07c _UIApplicationHandleEventQueue + 2954
29 CoreFoundation 0x016c883f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
30 CoreFoundation 0x016c81cb __CFRunLoopDoSources0 + 235
31 CoreFoundation 0x016e529e __CFRunLoopRun + 910
32 CoreFoundation 0x016e4ac3 CFRunLoopRunSpecific + 467
33 CoreFoundation 0x016e48db CFRunLoopRunInMode + 123
34 GraphicsServices 0x036e49e2 GSEventRunModal + 192
35 GraphicsServices 0x036e4809 GSEventRun + 104
36 UIKit 0x00230d3b UIApplicationMain + 1225
37 MaisOui 0x00002c5d main + 141
38 libdyld.dylib 0x01d7d70d start + 1
39 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
#import "MaisOuiAppDelegate.h"
int main(int argc, char * argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([MaisOuiAppDelegate class]));
}
}
From file to pass:
int d=0;
int d1=0;
File passed to:
#interface MaisOuiDictionary : NSObject
- (NSString *) lookup: (NSString *) in;
- (int) dic : (int) dictio;
- (int) dic1 : (int ) dictio1;
#end
- (NSString *) lookup: (NSString *)in get:(int)dictio get1:(int)dictio1;
{
// if(dictio==10 && dictio1==10)
{
NSString *rv = [self.wordsE_S objectForKey: in];
if ( !rv )
return #"*** no translation ***";
return rv;
}
// return #"**nothing**";
}
Can someone tell me where I wrong. I have tried changing all values to int * and NSInteger *, but still getting the same error.

You've implemented this method
- (NSString*)lookup:(NSString*)in get:(int)dictio get1:(int)diction;
...but it looks like you're trying to call this method (that has been defined in your interface)
- (NSString*)lookup:(NSString*)in;
Because the implementation of lookup: doesn't exist, you're getting an exception thrown. You need to either:
Declare lookup:get:get1: in your interface, and call that in textFieldShouldReturn: instead of lookup:
Implement lookup: in your implementation
It all boils down to you calling a method that doesn't exist. Clarification on method naming in Objective C can be found here: Method Syntax in Objective C

Related

Objective-C JavaScriptCore Bind a Completion Handler with JSExport

Supposed to have a completion block like
typedef void(^JSAPICallback)(id result);
and a binding class
#protocol JSProtocol<JSExport>
- (void)initAPI:(JSAPICallback)success;
#end
#interface JSObject : NSObject<JSProtocol>
- (void)initAPI:(JSAPICallback)success error:(JSAPICallback)error;
#end
#implementation JSObject
- (void)initAPI:(JSAPICallback)success {
[[API sharedInstance] initialize:^(id results, NSError *error) {
if(error==nil) {
success(results)
} else {
error()
}
}];
}
}
If I try to bind it in a JSContext in this case in a tvOS TVApplicationControllerDelegate delegate like:
- (void)appController:(TVApplicationController *)appController evaluateAppJavaScriptInContext:(JSContext *)jsContext {
JSObject *jsObject = [[JSObject alloc] init];
[jsContext setObject:jsObject forKeyedSubscript:#"jsobject"];
[jsContext setExceptionHandler:^(JSContext *context, JSValue *value) {
NSLog(#"%#", value);
}];
}
I have a crash:
2015-10-09 23:33:16.669 TestbedTV[9707:3524754] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
0 CoreFoundation 0x000000011008f105 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010fb07deb objc_exception_throw + 48
2 CoreFoundation 0x000000010ff9206e -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 318
3 CoreFoundation 0x000000010ffa43bb +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
4 JavaScriptCore 0x000000011905d388 -[JSObjCClassInfo allocateConstructorAndPrototype] + 2664
5 JavaScriptCore 0x000000011905e25f -[JSObjCClassInfo prototype] + 47
6 JavaScriptCore 0x000000011905e0ab -[JSObjCClassInfo wrapperForObject:] + 587
7 JavaScriptCore 0x000000011905e737 -[JSWrapperMap jsWrapperForObject:] + 423
8 JavaScriptCore 0x0000000118fdce80 -[JSContext(Internal) wrapperForObjCObject:] + 64
9 JavaScriptCore 0x0000000119054238 _ZL24objectToValueWithoutCopyP9JSContextP11objc_object + 760
10 JavaScriptCore 0x000000011905053a _Z13objectToValueP9JSContextP11objc_object + 74
11 JavaScriptCore 0x0000000119051ad9 -[JSValue setValue:forProperty:] + 137
12 TestbedTV 0x000000010eeb42cd -[AppDelegate appController:evaluateAppJavaScriptInContext:] + 141
13 TVMLKit 0x000000011048d3be -[TVApplicationController appContext:evaluateAppJavaScriptInContext:] + 889
14 ITMLKit 0x000000011b47d431 -[IKAppContext(JS) evaluateFoundationJS] + 2566
15 ITMLKit 0x000000011b4a56b3 -[IKAppContext _startWithScript:scriptUrl:] + 262
16 ITMLKit 0x000000011b4a52a5 -[IKAppContext _startWithURL:urlTrusted:] + 1277
17 ITMLKit 0x000000011b4a37e7 __21-[IKAppContext start]_block_invoke + 46
18 ITMLKit 0x000000011b4a6633 -[IKAppContext _sourcePerform] + 379
19 ITMLKit 0x000000011b4a647d IKRunLoopSourcePerformCallBack + 34
20 CoreFoundation 0x000000010ffbb1b1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
21 CoreFoundation 0x000000010ffb10dc __CFRunLoopDoSources0 + 556
22 CoreFoundation 0x000000010ffb0593 __CFRunLoopRun + 867
23 CoreFoundation 0x000000010ffaffa8 CFRunLoopRunSpecific + 488
24 CoreFoundation 0x0000000110063201 CFRunLoopRun + 97
25 ITMLKit 0x000000011b4a62ea -[IKAppContext _jsThreadMain] + 337
26 Foundation 0x000000010f79224b __NSThread__start__ + 1198
27 libsystem_pthread.dylib 0x000000011311505a _pthread_body + 131
28 libsystem_pthread.dylib 0x0000000113114fd7 _pthread_body + 0
29 libsystem_pthread.dylib 0x00000001131123ed thread_start + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
It seems that the JavaScriptCore is not able to bind the completion block. Having a simple function with simple parameters like this
#protocol JSProtocol<JSExport>
- (void)initAPI:(NSString*)options;
#end
instead the binding would work as expected.
This happens in tvOS9.0, but I think it would crash in iOS9.1 as well.
The most likely question to get some idea is ObjectiveC and JavaScriptCore: Will using this method of calling CallBacks cause memory issues?.

libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) [duplicate]

This question already has answers here:
Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?
(79 answers)
Closed 5 years ago.
Error refers to my main.m, not sure what to do to fix, tried a lot.
int main(int argc, char * argv[]) {
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
Appreciate the help.
Here is the crash log:
2014-12-31 01:49:28.838 iChat[4855:142422] Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?
2014-12-31 01:49:28.922 iChat[4855:142422] Application windows are expected to have a root view controller at the end of application launch
2014-12-31 01:49:30.342 iChat[4855:142422] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<LoginViewController 0x7f8763d77870> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key forgotPasswordButton.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a627f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010a2c0bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010a627b79 -[NSException raise] + 9
3 Foundation 0x00000001074477b3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x000000010a571e80 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x0000000107b80c7d -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x00000001079dff98 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x00000001079e0588 -[UIViewController loadView] + 109
8 UIKit 0x00000001079e07f9 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x0000000107a0f06b -[UINavigationController _layoutViewController:] + 44
10 UIKit 0x0000000107a0f5b5 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 216
11 UIKit 0x0000000107a0f6b4 -[UINavigationController _startTransition:fromViewController:toViewController:] + 92
12 UIKit 0x0000000107a10487 -[UINavigationController _startDeferredTransitionIfNeeded:] + 523
13 UIKit 0x0000000107a10f47 -[UINavigationController __viewWillLayoutSubviews] + 43
14 UIKit 0x0000000107b56509 -[UILayoutContainerView layoutSubviews] + 202
15 UIKit 0x0000000107934973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
16 QuartzCore 0x0000000106bbcde8 -[CALayer layoutSublayers] + 150
17 QuartzCore 0x0000000106bb1a0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
18 QuartzCore 0x0000000106bb187e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
19 QuartzCore 0x0000000106b1f63e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
20 QuartzCore 0x0000000106b2074a _ZN2CA11Transaction6commitEv + 390
21 UIKit 0x00000001078de022 _afterCACommitHandler + 123
22 CoreFoundation 0x000000010a55cdc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
23 CoreFoundation 0x000000010a55cd20 __CFRunLoopDoObservers + 368
24 CoreFoundation 0x000000010a552b53 __CFRunLoopRun + 1123
25 CoreFoundation 0x000000010a552486 CFRunLoopRunSpecific + 470
26 GraphicsServices 0x000000010bccd9f0 GSEventRunModal + 161
27 UIKit 0x00000001078bb420 UIApplicationMain + 1282
28 iSociety 0x00000001065a8b83 main + 115
29 libdyld.dylib 0x000000010b822145 start + 1
30 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Now I understand it would be coming from LoginViewController as this is the initial controller where the user logs in but there are buttons in which the user can "sign up" or "forgot password". At first it would crash everytime I would try clicking sign up but soon enough it crashed in general.
It would be better if you can post crash log along with the question.
But most of the time, this error occurs due to dangling connection with XIB/Storyboards like this:
Remove this connections which contains "!" exclamation mark on it.
Update : Another reason:
If one forgets to set initial view controller to the start point of scene.

textViewDidChange: crashes in iOS 7

As we know the UITextView is more powerful in iOS 7, but here it performs more fragile. The following code works fine when inputting "rr" with Chinese input keyboard in iOS 6, but crashes in iOS 7.
- (void)viewDidLoad
{
[super viewDidLoad];
self.tv = [[UITextView alloc] initWithFrame:CGRectMake(0, 100, 320, 100)];
self.tv.backgroundColor = [UIColor yellowColor];
self.tv.textColor = [UIColor blackColor];
self.tv.editable = YES;
self.tv.delegate = self;
[self.view addSubview:self.tv];
}
-(void)textViewDidChange:(UITextView *)textView{
int maxLength = 2;
if (self.tv.text.length > maxLength) {
NSLog(#"self.tv.text :%#",self.tv.text);
NSLog(#"self.tv.text.length :%d",self.tv.text.length);
NSLog(#"maxLength :%d",maxLength);
self.tv.text = [self.tv.text substringToIndex:maxLength];
}
}
The log is as following:
2013-11-13 15:48:16.003 Test2[1388:70b] self.tv.text :r r
2013-11-13 15:48:16.004 Test2[1388:70b] self.tv.text.length :3
2013-11-13 15:48:16.005 Test2[1388:70b] maxLength :2
2013-11-13 15:48:16.032 Test2[1388:70b] *** Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds'
*** First throw call stack:
(
0 CoreFoundation 0x017355e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014b88b6 objc_exception_throw + 44
2 CoreFoundation 0x017353bb +[NSException raise:format:] + 139
3 Foundation 0x010ebba1 -[NSMutableRLEArray replaceObjectsInRange:withObject:length:] + 136
4 Foundation 0x010ebb14 -[NSMutableRLEArray deleteObjectsInRange:] + 63
5 Foundation 0x010ea559 -[NSConcreteMutableAttributedString replaceCharactersInRange:withAttributedString:] + 324
6 UIFoundation 0x02d9d9f4 __71-[NSConcreteTextStorage replaceCharactersInRange:withAttributedString:]_block_invoke + 68
7 UIFoundation 0x02d9d92f -[NSConcreteTextStorage replaceCharactersInRange:withAttributedString:] + 121
8 UIKit 0x00924d22 __53-[UITextInputController setMarkedText:selectedRange:]_block_invoke + 352
9 UIFoundation 0x02d9b491 -[NSTextStorage coordinateEditing:] + 48
10 UIKit 0x00924a38 -[UITextInputController setMarkedText:selectedRange:] + 249
11 UIKit 0x008fb3b1 -[UITextView setMarkedText:selectedRange:] + 63
12 UIKit 0x00644aa5 -[UIResponder(UITextInput_Internal) _setMarkedText:selectedRange:] + 101
13 UIKit 0x004031aa -[UIKeyboardImpl setMarkedText:selectedRange:inputString:searchString:] + 365
14 UIKit 0x00419737 -[TIKeyboardOperationSetMarkedText(UIKeyboardImpl) main] + 178
15 Foundation 0x0118da69 -[__NSOperationInternal _start:] + 671
16 Foundation 0x0110a798 -[NSOperation start] + 83
17 UIKit 0x0040e08a -[UIKeyboardImpl updateCandidateDisplayAsyncWithCandidateSet:documentOperation:] + 188
18 UIKit 0x00419041 -[TIKeyboardOperationSetCandidates(UIKeyboardImpl) main] + 112
19 Foundation 0x0118da69 -[__NSOperationInternal _start:] + 671
20 Foundation 0x0110a798 -[NSOperation start] + 83
21 UIKit 0x0040671d -[UIKeyboardImpl performOperations:] + 153
22 UIKit 0x00404f4e -[UIKeyboardImpl continueGenerateCandidatesAsynchronouslyWithOperations:] + 40
23 UIKit 0x00404c51 __87-[UIKeyboardImpl replyHandlerForGenerateCandidatesAsynchronouslyWithSelectedCandidate:]_block_invoke_2 + 46
24 UIKit 0x009381b8 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 402
25 UIKit 0x0093885f -[UIKeyboardTaskQueue addTask:] + 144
26 CoreFoundation 0x01729d1d __invoking___ + 29
27 CoreFoundation 0x01729c2a -[NSInvocation invoke] + 362
28 UIKit 0x008e63d2 -[_UIActionWhenIdle invoke] + 100
29 UIKit 0x008e64a6 __41-[_UIActionWhenIdle addObserverToRunLoop]_block_invoke + 36
30 CoreFoundation 0x0172924d _runLoopObserverWithBlockContext + 29
31 CoreFoundation 0x016fd53e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
32 CoreFoundation 0x016fd48f __CFRunLoopDoObservers + 399
33 CoreFoundation 0x016db3b4 __CFRunLoopRun + 1076
34 CoreFoundation 0x016dab33 CFRunLoopRunSpecific + 467
35 CoreFoundation 0x016da94b CFRunLoopRunInMode + 123
36 GraphicsServices 0x036d69d7 GSEventRunModal + 192
37 GraphicsServices 0x036d67fe GSEventRun + 104
38 UIKit 0x0022b94b UIApplicationMain + 1225
39 Test2 0x0000388d main + 141
40 libdyld.dylib 0x01d7370d start + 1
41 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
In addition, I test the following code, it also crashes after input "rr" with Chinese input keyboard.
-(void)textViewDidChange:(UITextView *)textView{
int maxLength = 2;
if (self.tv.text.length > maxLength) {
self.tv.text = #"c";
}
}
Any help will be appreciated!
What's happening is that you're typing what is referred to as multistage text input, i.e. the input has to be confirmed from the user before it's actually committed into the underlying text. You get the crash because the text is only kind-of inputted, and until the text has been committed, it could easily change to something else.
To detect this situation, you're looking for the markedTextRange property of the UITextView, which indicates if you're in this complex input mode.
If the property is non-nil, then you're in this special input mode, so you should guard your modification code with something like:
if (self.tv.markedTextRange == nil && self.tv.text.length > maxLength) {
// Perform change
}
Near as I can tell the crash is triggered by the special multistage text input mode, so you should avoid changing the text while this mode is active.

unrecognized selector sent to instance of custom class

Here is class header:
#interface ChallengeItem : NSObject
.......
- (NSString *) getAlertIntervalInString;
- (void) createReminder;
#end
some implementation in .m file:
- (NSString *) getAlertIntervalInString {
... do something
}
- (void)createReminder {
... do something
}
I call
for (int i = 0; i < [self count]; i++) {
ChallengeItem *currentItem = [self getChallengeAtIndex:i];
if (currentItem.isStarted) {
[currentItem createReminder];
}
}
and receive an unrecognized selector error, but when I change
[currentItem createReminder];
to
[currentItem getAlertIntervalInString];
error isn't appear.
What is the problem?
Here is the console log
Current language: auto; currently objective-c 2011-11-23 00:56:40.056
30 Day Challenge[379:12b03] -[ChallengeItem createReminder]:
unrecognized selector sent to instance 0x6079900 2011-11-23
00:56:40.147 30 Day Challenge[379:12b03] * Terminating app due to
uncaught exception 'NSInvalidArgumentException', reason:
'-[ChallengeItem createReminder]: unrecognized selector sent to
instance 0x6079900'
* Call stack at first throw:
(
0 CoreFoundation 0x00fb35a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01107313 objc_exception_throw + 44
2 CoreFoundation 0x00fb50bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00f24966 ___forwarding___ + 966
4 CoreFoundation 0x00f24522 _CF_forwarding_prep_0 + 50
5 30 Day Challenge 0x00006950 -[ChallengeCollection setRemindersForStartedChallenges] + 144
6 30 Day Challenge 0x00002f27 -[_0_Day_ChallengeAppDelegate applicationDidEnterBackground:] + 151
7 UIKit 0x00209a40 -[UIApplication _handleApplicationSuspend:eventInfo:] + 607
8 UIKit 0x00213039 -[UIApplication handleEvent:withNewEvent:] + 4127
9 UIKit 0x0020aabf -[UIApplication sendEvent:] + 71
10 UIKit 0x0020ff2e _UIApplicationHandleEvent + 7576
11 GraphicsServices 0x01712992 PurpleEventCallback + 1550
12 CoreFoundation 0x00f94944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
13 CoreFoundation 0x00ef4cf7 __CFRunLoopDoSource1 + 215
14 CoreFoundation 0x00ef1f83 __CFRunLoopRun + 979
15 CoreFoundation 0x00ef1840 CFRunLoopRunSpecific + 208
16 CoreFoundation 0x00ef1761 CFRunLoopRunInMode + 97
17 GraphicsServices 0x017111c4 GSEventRunModal + 217
18 GraphicsServices 0x01711289 GSEventRun + 115
19 UIKit 0x00213c93 UIApplicationMain + 1160
20 30 Day Challenge 0x00002059 main + 121
21 30 Day Challenge 0x00001fd5 start + 53
22 ??? 0x00000001 0x0 + 1
)
terminate called throwing an exception(gdb)
I don't see any obvious problems with your code. To make sure getChallengeAtIndex is in fact returning ChallengeItem instances, you could put a breakpoint at that line and inspect the returned values.
After you install the new version of XCode, the problem will be gone.

sorting an NSMutableArray of objects in cocoa gives SIGABRT

I am creating a program that requires me to build an NSMutable array and then add objects to that array as buttons are clicked.
After the user has clicked all the buttons that they want (therefore adding all the objects that they need into the mutable array) I need to sort the array based on the objects name.
The objects are NSImageViews that are added to the array with names like view1, view2, view40.
I need a way to sort the objects in the array according to the numbers in the last digit of their name.
I was using
[nameOfArray sortUsingSelector:#selector(caseInsensitiveCompare:)];
but when I run the app I get SIGABRT at that line.
I have looked at many many other threads and can not find a solution.
Any help is greatly appreciated, as I have been working on this for several weeks now,
Anybody know what I am doing wrong?
EDIT , Here is what the debugger said afterwords
2011-09-30 08:16:06.669 CAP helper[9874:b303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView caseInsensitiveCompare:]: unrecognized selector sent to instance 0x4e5f650'
*** Call stack at first throw:
(
0 CoreFoundation 0x00de05a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f34313 objc_exception_throw + 44
2 CoreFoundation 0x00de20bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d51966 ___forwarding___ + 966
4 CoreFoundation 0x00d51522 _CF_forwarding_prep_0 + 50
5 CoreFoundation 0x00d472f6 __CFSimpleMergeSort + 374
6 CoreFoundation 0x00d4706c CFSortIndexes + 268
7 CoreFoundation 0x00dda642 -[NSMutableArray sortRange:options:usingComparator:] + 274
8 CoreFoundation 0x00d598cf -[NSMutableArray sortWithOptions:usingComparator:] + 95
9 CoreFoundation 0x00d5983c -[NSMutableArray sortUsingSelector:] + 108
10 CAP helper 0x0000cf81 -[RibbonStacker stackit:] + 305
11 UIKit 0x000324fd -[UIApplication sendAction:to:from:forEvent:] + 119
12 UIKit 0x000c2799 -[UIControl sendAction:to:forEvent:] + 67
13 UIKit 0x000c4c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
14 UIKit 0x000c37d8 -[UIControl touchesEnded:withEvent:] + 458
15 UIKit 0x00056ded -[UIWindow _sendTouchesForEvent:] + 567
16 UIKit 0x00037c37 -[UIApplication sendEvent:] + 447
17 UIKit 0x0003cf2e _UIApplicationHandleEvent + 7576
18 GraphicsServices 0x01019992 PurpleEventCallback + 1550
19 CoreFoundation 0x00dc1944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
20 CoreFoundation 0x00d21cf7 __CFRunLoopDoSource1 + 215
21 CoreFoundation 0x00d1ef83 __CFRunLoopRun + 979
22 CoreFoundation 0x00d1e840 CFRunLoopRunSpecific + 208
23 CoreFoundation 0x00d1e761 CFRunLoopRunInMode + 97
24 GraphicsServices 0x010181c4 GSEventRunModal + 217
25 GraphicsServices 0x01018289 GSEventRun + 115
26 UIKit 0x00040c93 UIApplicationMain + 1160
27 CAP helper 0x00002219 main + 121
28 CAP helper 0x00002195 start + 53
29 ??? 0x00000001 0x0 + 1
)
terminate called throwing an exception
Current language: auto; currently objective-c>
Your array contains UIImageViews and your sort calls caseInsensitiveCompare: on those instances of UIImageView, but that class doesn't have any method by that name. You should do something like this:
[nameOfArray sortUsingComparator:^(id obj1, id obj2) {
UIImageView *view1 = obj1;
UIImageView *view2 = obj2;
// Somehow compare the views and return NSOrderedAscending,
// NSOrderedDescending or NSOrderedSame, for example by calling
// appropriate "compare:" methods.
return myComparisonResult
}];