New here (this forum and Xcode in general), so bear with me.
I've spent multiple hours off and on over the last severals days trying to track down what exactly that I'm doing wrong here, but I just don't seem to be able to pinpoint my issue.
Here's the relevant sections of my code (I believe).
In the header:
#interface BlahViewController : UIViewController {
NSMutableString *display;
}
#property (nonatomic, retain) NSMutableString *display;
In the main:
#implementation BlahViewController
#synthesize display;
- (void)viewDidLoad {
self.display = [[NSMutableString alloc] init];
}
- (void)anotherFunction:(UIButton *)sender {
NSString *info = [[sender titleLabel] text];
[self.display appendString:info];
}
I run the code, press the UIButton, and I get an error. Here's the initial throw:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM appendString:]: unrecognized selector sent to instance 0x4e3d300' ***
Thanks!
EDIT: The whole stack trace was requested, so here it is (after reviewing the stack I realize there may be confusion, I'm writing a very basic calculator currently, so the ViewController, etc, should consider that backdrop and "anotherFunction" = "digitPressed" in this particular case):
* Call stack at first throw:
(
0 CoreFoundation 0x00e345a9 exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f88313 objc_exception_throw + 44
2 CoreFoundation 0x00e360bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00da5966 __forwarding + 966
4 CoreFoundation 0x00da5522 _CF_forwarding_prep_0 + 50
5 Calculator 0x0000273b -[CalculatorViewController digitPressed:] + 113
6 UIKit 0x002bb4fd -[UIApplication sendAction:to:from:forEvent:] + 119
7 UIKit 0x0034b799 -[UIControl sendAction:to:forEvent:] + 67
8 UIKit 0x0034dc2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
9 UIKit 0x0034c7d8 -[UIControl touchesEnded:withEvent:] + 458
10 UIKit 0x002dfded -[UIWindow _sendTouchesForEvent:] + 567
11 UIKit 0x002c0c37 -[UIApplication sendEvent:] + 447
12 UIKit 0x002c5f2e _UIApplicationHandleEvent + 7576
13 GraphicsServices 0x01723992 PurpleEventCallback + 1550
14 CoreFoundation 0x00e15944 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 52
15 CoreFoundation 0x00d75cf7 __CFRunLoopDoSource1 + 215
16 CoreFoundation 0x00d72f83 __CFRunLoopRun + 979
17 CoreFoundation 0x00d72840 CFRunLoopRunSpecific + 208
18 CoreFoundation 0x00d72761 CFRunLoopRunInMode + 97
19 GraphicsServices 0x017221c4 GSEventRunModal + 217
20 GraphicsServices 0x01722289 GSEventRun + 115
21 UIKit 0x002c9c93 UIApplicationMain + 1160
22 Calculator 0x00002254 main + 102
23 Calculator 0x000021e5 start + 53
)
terminate called after throwing an instance of 'NSException'
Current language: auto; currently objective-c
* Terminating app due to uncaught
exception
'NSInvalidArgumentException', reason:
'-[__NSArrayM appendString:]:
unrecognized selector sent to instance
0x4e3d300' *
This indicates that you are calling appendString: an instance of some kind of NSArray, which obviously won't work.
Assuming that [self.display appendString:info]; is the actual source of the exception, then it is happening because self.display has likely been over-released and, coincidentally, an NSArray instance was allocated at the same place in memory.
You could use zombie detection to debug this.
Alternatively, you might be corrupting memory somewhere. Or, maybe, there is another assignment to display.
In any case, whenever you have a crash, there will be a backtrace. Please post it. There is the off chance that the crash is happening somewhere else.
5 Calculator 0x0000273b -[CalculatorViewController digitPressed:] + 113
Show the source to your digitPressed: method.
self.display = [[NSMutableString alloc] init];
That is a memory leak; it'll be retained twice. Just do self.display = [NSMutableString string]; and self.display = nil; (in your viewDidUnload).
But that isn't the source of your problem; something is resetting the display variable or it is being over-released. Show all uses of display.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am making an iPad app compatible for iOS7. App is working perfect in iOS 6 but it crashes in iOS 7.
if ([self.exercise.variant isEqualToString:kVariantGFTextItem]) {
NSLog(#"item:%#",[[[itemArray objectAtIndex:0] superview]superview]);
GapsFillItem *itemView = (GapsFillItem*)[[[[itemArray objectAtIndex:0] superview]superview]subviews];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
itemView = (GapsFillItem*)[[[itemArray objectAtIndex:0] superview]superview];
}
[itemView.buttonPlaySound setImage:(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)?kImageButtonSoundPerItemPad:kImageButtonSoundPerItemPhone forState:UIControlStateNormal];
itemView.buttonPlaySound.userInteractionEnabled = YES;
}
This code is worked perfect in iOS 6 but not in iOS 7.
Here is the crash log :
2013-10-19 09:41:53.208 Elementary[645:a0b] item:<TextViewWithTextField: 0xa9e3800; baseClass = UITextView; frame = (183 -10; 562 92); text = 'Hello. Can I +change+ ...'; clipsToBounds = YES; gestureRecognizers = <NSArray: 0xa7a8170>; layer = <CALayer: 0xa7a7ef0>; contentOffset: {0, 0}>
2013-10-19 09:41:53.209 Elementary[645:a0b] -[__NSArrayM buttonPlaySound]: unrecognized selector sent to instance 0xa7ac9a0
2013-10-19 09:41:53.212 Elementary[645:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM buttonPlaySound]: unrecognized selector sent to instance 0xa7ac9a0'
*** First throw call stack:
(
0 CoreFoundation 0x02a435e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x027178b6 objc_exception_throw + 44
2 CoreFoundation 0x02ae0903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x02a3390b ___forwarding___ + 1019
4 CoreFoundation 0x02a334ee _CF_forwarding_prep_0 + 14
5 Elementary 0x00066185 -[GapsFill checkAnswers] + 4693
6 Elementary 0x00011bd4 -[ParentViewController checkToolMenuItemTapped] + 228
7 Elementary 0x0002da45 -[ToolsMenu menuItemTapped:] + 565
8 libobjc.A.dylib 0x02729874 -[NSObject performSelector:withObject:withObject:] + 77
9 UIKit 0x00f1dc8c -[UIApplication sendAction:to:from:forEvent:] + 108
10 UIKit 0x00f1dc18 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
11 UIKit 0x010156d9 -[UIControl sendAction:to:forEvent:] + 66
12 UIKit 0x01015a9c -[UIControl _sendActionsForEvents:withEvent:] + 577
13 UIKit 0x01014d4b -[UIControl touchesEnded:withEvent:] + 641
14 UIKit 0x00f5b0cd -[UIWindow _sendTouchesForEvent:] + 852
15 UIKit 0x00f5bd34 -[UIWindow sendEvent:] + 1232
16 UIKit 0x00f2fa36 -[UIApplication sendEvent:] + 242
17 UIKit 0x00f19d9f _UIApplicationHandleEventQueue + 11421
18 CoreFoundation 0x029cc8af __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
19 CoreFoundation 0x029cc23b __CFRunLoopDoSources0 + 235
20 CoreFoundation 0x029e930e __CFRunLoopRun + 910
21 CoreFoundation 0x029e8b33 CFRunLoopRunSpecific + 467
22 CoreFoundation 0x029e894b CFRunLoopRunInMode + 123
23 GraphicsServices 0x035b79d7 GSEventRunModal + 192
24 GraphicsServices 0x035b77fe GSEventRun + 104
25 UIKit 0x00f1c94b UIApplicationMain + 1225
26 Elementary 0x00002285 main + 181
27 Elementary 0x000021c5 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Please if anyone has any idea why it is happening. Please let me know.
Your itemView, which it looks like you expect to be of type GapsFillItem, is actually of type NSArray.
You know this because the crash report is telling you that NSArray does not recognize the selector named buttonPlaySound, which I assume is defined on the GapsFillItem class.
I recommend throwing some NSLog statements in there to understand how itemView is becoming an NSArray.
In general, lines like this are very dubious:
GapsFillItem *itemView = (GapsFillItem*)[[[[itemArray objectAtIndex:0] superview]superview]subviews];
itemView = (GapsFillItem*)[[[itemArray objectAtIndex:0] superview]superview];
One of these two lines is where the problem is. I would recommend avoiding accessing objects via calls to superview upon superview upon subviews etc etc. If you need to reach something via this sort of chain there's most likely a better way.
Best of luck
Edit
At second glance it looks like this will always crash on iPad because of this line:
GapsFillItem *itemView = (GapsFillItem*)[[[[itemArray objectAtIndex:0] superview]superview]subviews];
Subviews is an array. This is your problem. You probably mean to set itemView to an item within subviews.
That said, the crash may just be device specific and have nothing to do with iOS 7.
I wanted to confirm that the following functionality is supported:
I have a simple app where I am trying to send an array of strings to UIActivityViewController. The array contains an attributed string and also a regular string. When I click on the share button and open the Mail app, I get a crash and error. However when I only send the attributed string by itself, it works.
I have tried this on IOS6 and it works fine on that.
Here is the configuration:
NSAttributedString *appName=[[NSAttributedString alloc] initWithString:#"TasteBank\n"
attributes:#{NSFontAttributeName : [UIFont boldSystemFontOfSize:[UIFont
systemFontSize]],NSForegroundColorAttributeName:[UIColor brownColor]}];
//crash seen when #"test" added to array without that no crash when mail app opened on ios7
NSMutableArray *dataToShare = [[NSMutableArray alloc ] initWithObjects: appName, #"test", nil];
UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:^{}];
IS there something wrong with this? Is this configuration supported in IOS7? if so, could this be a bug?
I see the following error when I run on my iPhone 4 with IOS 7:
2013-10-17 11:43:50.609 testing12[2499:60b] -[NSConcreteMutableAttributedString appendString:]: unrecognized selector sent to instance 0x165ae670
2013-10-17 11:43:50.612 testing12[2499:60b] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableAttributedString appendString:]: unrecognized selector sent to instance 0x165ae670'
First throw call stack:
(0x2ff53f53 0x3a32c6af 0x2ff578e7 0x2ff561d3 0x2fea5598 0x32c389a1 0x328e2f2b 0x328e2bb1 0x328e2791 0x328e23b7 0x328e20dd 0x3284c101 0x3284c101 0x326f9601 0x326f468d 0x326c9a25 0x326c8221 0x2ff1f18b 0x2ff1e65b 0x2ff1ce4f 0x2fe87ce7 0x2fe87acb 0x34ba8283 0x32729a41 0xbd1ed 0x3a834ab7)
I see this error when run on IOS7.0 simulator in XCODE 5:
2013-10-17 11:23:42.054 testing12[3258:a0b] -[NSConcreteMutableAttributedString appendString:]: unrecognized selector sent to instance 0xa181470
2013-10-17 11:23:42.085 testing12[3258:a0b] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableAttributedString appendString:]: unrecognized selector sent to instance 0xa181470'
First throw call stack:
(0 CoreFoundation 0x017345e4 exceptionPreprocess + 180
1 libobjc.A.dylib 0x014b78b6 objc_exception_throw + 44
2 CoreFoundation 0x017d1903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0172490b forwarding___ + 1019
4 CoreFoundation 0x017244ee _CF_forwarding_prep_0 + 14
5 UIKit 0x008bdfa3 -[UIMailActivity prepareWithActivityItems:] + 2346
6 UIKit 0x008b9242 -[UIActivityViewController _executeActivity] + 424
7 UIKit 0x008ba824 -[UIActivityViewController _performActivity:] + 1359
8 libobjc.A.dylib 0x014c981f -[NSObject performSelector:withObject:] + 70
9 UIKit 0x0063c75a -[UIActivityGroupViewController collectionView:didSelectItemAtIndexPath:] + 148
10 UIKit 0x0083929b -[UICollectionView _selectItemAtIndexPath:animated:scrollPosition:notifyDelegate:] + 605
11 UIKit 0x008516d8 -[UICollectionView _userSelectItemAtIndexPath:] + 189
12 UIKit 0x00851895 -[UICollectionView touchesEnded:withEvent:] + 437
13 libobjc.A.dylib 0x014c9874 -[NSObject performSelector:withObject:withObject:] + 77
14 UIKit 0x00382f92 forwardTouchMethod + 271
15 UIKit 0x00383002 -[UIResponder touchesEnded:withEvent:] + 30
16 libobjc.A.dylib 0x014c9874 -[NSObject performSelector:withObject:withObject:] + 77
17 UIKit 0x00382f92 forwardTouchMethod + 271
18 UIKit 0x00383002 -[UIResponder touchesEnded:withEvent:] + 30
19 UIKit 0x0059dd7f _UIGestureRecognizerUpdate + 7166
20 UIKit 0x00268d4a -[UIWindow _sendGesturesForEvent:] + 1291
21 UIKit 0x00269c6a -[UIWindow sendEvent:] + 1030
22 UIKit 0x0023da36 -[UIApplication sendEvent:] + 242
23 UIKit 0x00227d9f _UIApplicationHandleEventQueue + 11421
24 CoreFoundation 0x016bd8af CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
25 CoreFoundation 0x016bd23b __CFRunLoopDoSources0 + 235
26 CoreFoundation 0x016da30e __CFRunLoopRun + 910
27 CoreFoundation 0x016d9b33 CFRunLoopRunSpecific + 467
28 CoreFoundation 0x016d994b CFRunLoopRunInMode + 123
29 GraphicsServices 0x036859d7 GSEventRunModal + 192
30 GraphicsServices 0x036857fe GSEventRun + 104
31 UIKit 0x0022a94b UIApplicationMain + 1225
32 testing12 0x00002efd main + 141
33 libdyld.dylib 0x01d70725 start + 0
34 ??? 0x00000001 0x0 + 1
)
I don't know if this will help but I fixed my problem with a custom activity provider that just gave a NSString to email types and the attributed string to all the others. The email controller autodetected that the string was HTML and formatted it correctly anyway.
I guess if you can get the same effect from HTML that you can with your attributed string this might help?
#implementation ProductActivityItemProvider
...
- (id)placeholderItem {
return [[NSAttributedString alloc] initWithString:#""];
}
- (NSString *)activityViewController:(UIActivityViewController *)activityViewController subjectForActivityType:(NSString *)activityType {
if ([activityType isEqualToString:UIActivityTypeMail])
return [NSString stringWithFormat:#"I shared %#", self.product.title];
return nil;
}
- (id)item {
NSString *raw = [NSString stringWithFormat:#"<html><body>%#<br />%#<br /><b>%#</b></body></html>",
self.product.designer,
self.product.title,
self.product.price];
// The mail controller will (a) autodetect HTML and (b) crash if it's given an attributed string. sigh.
if ([self.activityType isEqualToString:UIActivityTypeMail])
return raw;
NSData *data = [raw dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *options = #{
NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute : #(NSUTF8StringEncoding)
};
NSAttributedString *text = [[NSAttributedString alloc] initWithData:data
options:options
documentAttributes:nil
error:nil];
return text;
}
#end
Got some fast solution here. Just implement a category:
#implementation NSMutableAttributedString (append)
-(void)appendString:(id)string{
if([string isKindOfClass:[NSString class]]){
[self appendAttributedString:[[NSAttributedString alloc] initWithString:string]];
}else if ([string isKindOfClass:[NSAttributedString class]]){
[self appendAttributedString:string];
}
}
#end
I am loading some values in UItableview from an array of dictionary values. I then alter the dictionary in the array by adding one more key value object as below
NSMutableDictionary *rowDict = [tableList objectAtIndex:arrayindex];
[rowDict setObject:#"download successfull" forKey:#"downloadstatus"];
but after this when I try retrieveing value from dictionary in the array as below
NSMutableDictionary *rowDict = [tableList objectAtIndex:arrayindex];
NSString *SelectedState = (NSString*)[rowDict objectForKey:#"downloadstatus"];
it crashes ... can any one help me out to fix this
this is the crash display on my consol
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableData objectForKey:]: unrecognized selector sent to instance 0x61a8270'
*** Call stack at first throw:
(
0 CoreFoundation 0x003b0be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x015c15c2 objc_exception_throw + 47
2 CoreFoundation 0x003b26fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00322366 ___forwarding___ + 966
4 CoreFoundation 0x00321f22 _CF_forwarding_prep_0 + 50
5 SifyMyStorage 0x0003b35b -[DownloadListViewController tableView:cellForRowAtIndexPath:] + 314
6 UIKit 0x00ec67fa -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
7 UIKit 0x00ebc77f -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
8 UIKit 0x00ed1450 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
9 UIKit 0x00ec9538 -[UITableView layoutSubviews] + 242
10 QuartzCore 0x009f4451 -[CALayer layoutSublayers] + 181
11 QuartzCore 0x009f417c CALayerLayoutIfNeeded + 220
12 QuartzCore 0x009ed37c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
13 QuartzCore 0x009ed0d0 _ZN2CA11Transaction6commitEv + 292
14 QuartzCore 0x00a1d7d5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
15 CoreFoundation 0x00391fbb __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
16 CoreFoundation 0x003270e7 __CFRunLoopDoObservers + 295
17 CoreFoundation 0x002efbd7 __CFRunLoopRun + 1575
18 CoreFoundation 0x002ef240 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x002ef161 CFRunLoopRunInMode + 97
20 GraphicsServices 0x02ead268 GSEventRunModal + 217
21 GraphicsServices 0x02ead32d GSEventRun + 115
22 UIKit 0x00e6142e UIApplicationMain + 1160
23 SifyMyStorage 0x000020b8 main + 102
24 SifyMyStorage 0x00002049 start + 53
)
terminate called after throwing an instance of 'NSException'
See if you have allocated the object and also get the count of dictionary , if the value is being added also see if u have declared NSmutabledictionary or just NSdictionary ... a view at your class having the code would be more helpful to sort out your problem
Ok, a couple things:
-the code you posted is fine. That's not the issue. The (NSString *) cast is unnecessary, but not an issue.
-there is an issue with your NSArray tablelist. If you are really adding only NSMutableDictionary to the array, then either you are doing that wrong, or your array is going out of scope and when you think you are accessing your array, you are accessing something else in memory at that location.
-How are you retaining your reference to tablelist within the controller?
-Change your second code block to this and I'll bet you find your problem (retainCount on one of these object == 0):
NSLog(#"retain count=%d",[tableList retainCount]);
NSMutableDictionary *rowDict = [tableList objectAtIndex:arrayindex];
NSLog(#"retain count=%d",[rowDict retainCount]);
NSString *SelectedState = [rowDict objectForKey:#"downloadstatus"];
you r not alloc the NSMutableDictionary so the NSMutableDictionary is empty and your app crashes.
NSMutableDictionary *rowDict = [[NSMutableDictionary alloc]init];
rowDict = [tableList objectAtIndex:arrayindex];
NSString *SelectedState = [rowDict objectForKey:#"downloadstatus"];
best of luck
I have one tabbar with several views, one with a tableview connected to Core Data. Now I've made one more tableview in a different project, and I want to merge it to my first project. This isn't new to me, I've done it before in another project where I had three tableviews with different core data tables, all working good. So I thought this would be a walk in the park.
In my AppDelage.m and .h I've added and copied all the code for the managedObjectContext to managedObjectContext2. And made a new navigation controller, "navigationController2".
ProtokollList *protokollList = (ProtokollList *)[navigationController2 topViewController];
// Set its managedObjectContext property to the managed object context
protokollList.managedObjectContext2 = self.managedObjectContext2;
// Get the root view controller; it's in the topViewController property of the navigation controller
KortKategori *kortKategori = (KortKategori *)[navigationController topViewController];
// Set its managedObjectContext property to the managed object context
kortKategori.managedObjectContext = self.managedObjectContext;
And then in my ProtokollList.m I've changed managedObjectContext to managedObjectContext2. And made necessary connections in MainWindow.nib.
But when I try to run the project I get this error message:
2011-07-24 18:22:58.188 Kortspel[1346:207] Unknown class ProtokollList in Interface Builder file.
2011-07-24 18:22:58.198 Kortspel[1346:207] -[UIViewController setManagedObjectContext2:]: unrecognized selector sent to instance 0x4d13c40
2011-07-24 18:22:58.199 Kortspel[1346:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setManagedObjectContext2:]: unrecognized selector sent to instance 0x4d13c40'
*** Call stack at first throw:
(
0 CoreFoundation 0x00fab5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x010ff313 objc_exception_throw + 44
2 CoreFoundation 0x00fad0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00f1c966 ___forwarding___ + 966
4 CoreFoundation 0x00f1c522 _CF_forwarding_prep_0 + 50
5 Kortspel 0x00001f28 -[KortAppDelegate applicationDidFinishLaunching:] + 709
6 UIKit 0x002c4ce2 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1252
7 UIKit 0x002c6d88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
8 UIKit 0x002d1617 -[UIApplication handleEvent:withNewEvent:] + 1533
9 UIKit 0x002c9abf -[UIApplication sendEvent:] + 71
10 UIKit 0x002cef2e _UIApplicationHandleEvent + 7576
11 GraphicsServices 0x01903992 PurpleEventCallback + 1550
12 CoreFoundation 0x00f8c944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
13 CoreFoundation 0x00eeccf7 __CFRunLoopDoSource1 + 215
14 CoreFoundation 0x00ee9f83 __CFRunLoopRun + 979
15 CoreFoundation 0x00ee9840 CFRunLoopRunSpecific + 208
16 CoreFoundation 0x00ee9761 CFRunLoopRunInMode + 97
17 UIKit 0x002c67d2 -[UIApplication _run] + 623
18 UIKit 0x002d2c93 UIApplicationMain + 1160
19 Kortspel 0x00001c40 main + 102
20 Kortspel 0x00001bd1 start + 53
)
terminate called after throwing an instance of 'NSException'
I don't know it says that it doesn't recognize "ProtokollList" class, because it's defined in ProtokollList.h.
Does anyone have any idea? This is the last step before launching!
EDIT:
If I try to blank out:
/*
ProtokollList *protokollList = (ProtokollList *)[navigationController2 topViewController];
// Set its managedObjectContext property to the managed object context
protokollList.managedObjectContext2 = self.managedObjectContext2;
*/
I can open the project, but when I click on ProtokollList-tableview I get this new error message:
2011-07-25 20:06:56.588 Kortspel[3205:207] Unknown class ProtokollList in Interface Builder file.
2011-07-25 20:07:01.585 Kortspel[3205:207] -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x590f3f0
2011-07-25 20:07:01.587 Kortspel[3205:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x590f3f0'
*** Call stack at first throw:
(
0 CoreFoundation 0x00fb25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01106313 objc_exception_throw + 44
2 CoreFoundation 0x00fb40bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00f23966 ___forwarding___ + 966
4 CoreFoundation 0x00f23522 _CF_forwarding_prep_0 + 50
5 UIKit 0x004882b7 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 1834
6 UIKit 0x00485d88 -[UITableViewRowData numberOfRows] + 108
7 UIKit 0x00339677 -[UITableView noteNumberOfRowsChanged] + 132
8 UIKit 0x00346708 -[UITableView reloadData] + 773
9 UIKit 0x00343844 -[UITableView layoutSubviews] + 42
10 QuartzCore 0x01f52a5a -[CALayer layoutSublayers] + 181
11 QuartzCore 0x01f54ddc CALayerLayoutIfNeeded + 220
12 QuartzCore 0x01efa0b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
13 QuartzCore 0x01efb294 _ZN2CA11Transaction6commitEv + 292
14 QuartzCore 0x01efb46d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
15 CoreFoundation 0x00f9389b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
16 CoreFoundation 0x00f286e7 __CFRunLoopDoObservers + 295
17 CoreFoundation 0x00ef11d7 __CFRunLoopRun + 1575
18 CoreFoundation 0x00ef0840 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x00ef0761 CFRunLoopRunInMode + 97
20 GraphicsServices 0x019091c4 GSEventRunModal + 217
21 GraphicsServices 0x01909289 GSEventRun + 115
22 UIKit 0x002d9c93 UIApplicationMain + 1160
23 Kortspel 0x00002524 main + 102
24 Kortspel 0x000024b5 start + 53
)
terminate called after throwing an instance of 'NSException'
Best regards,
xqtr
EDIT:
I understand that the critical point is the warning about IB (did not notice it at start)...
Could you check that ProtokollList.h and ProtokollList.m are effectively assigned to the target you are building? (I think so, otherwise you would have more linking problems, anyway, this is a basic check).
If this is ok, then I would simply try a clean and rebuild all.
If this does not fix the problem, then this might mean that the linker is not including ProtokollList.m in the final binary because of some optimization (the class is possibly never referenced in the rest of your code, just in Interface Builder). The fix for this is adding -all_load to the linker flags of your project.
If this does not help, I am very sad but I have no more suggestions...
You are calling:
protokollList.managedObjectContext2 = self.managedObjectContext2;
and no property named managedObjectContext2 is found in protokollList. This can be inferred by the line:
-[UIViewController setManagedObjectContext2:]: unrecognized selector sent to instance 0x4d13c40
So, you should possilby define managedObjectContext2 in protokollList (which should be a UIViewController).
EDIT;
interface ProtokollList : UITableViewController <NSFetchedResultsControllerDelegate> {
NSFetchedResultsController *fetchedResultsController2;
NSManagedObjectContext *managedObjectContext2;
}
#property (nonatomic, retain) NSManagedObjectContext *managedObjectContext2;
#end
i use this code to check if any objects exist in my NSMutableArray
if yes i remove them all but it crashes although there are objects why?
if([NSMutableArray1 count]==1)
{
[poemoptionslist removeAllObjects];
}
if ([NSMutableArray1 count]==0)
{
[poemoptionslist addObject: final1];
}
CONSOLE OUTPUT
2010-10-18 03:42:13.166
app1[33398:207] * Terminating app
due to uncaught exception
'NSInternalInconsistencyException',
reason: '-[__NSCFArray
removeObjectAtIndex:]: mutating method
sent to immutable object'
* Call stack at first throw: ( 0 CoreFoundation
0x02e55b99 exceptionPreprocess + 185
1 libobjc.A.dylib
0x02fa540e objc_exception_throw + 47
2 CoreFoundation
0x02e0e238 +[NSException
raise:format:arguments:] + 136 3
CoreFoundation
0x02e0e1aa +[NSException
raise:format:] + 58 4
CoreFoundation
0x02e4d3c1 -[__NSCFArray
removeObjectAtIndex:] + 193 5
CoreFoundation
0x02dfe973 -[NSMutableArray
removeAllObjects] + 83 6
poemsoflove
0x0004dc8d -[submitpoem submitpoem:] +
18560 7 UIKit
0x003b77f8 -[UIApplication
sendAction:to:from:forEvent:] + 119 8
UIKit
0x00442de0 -[UIControl
sendAction:to:forEvent:] + 67 9
UIKit
0x00445262 -[UIControl(Internal)
_sendActionsForEvents:withEvent:] + 527 10 UIKit
0x00443e0f -[UIControl
touchesEnded:withEvent:] + 458 11
UIKit
0x003db3d0 -[UIWindow
_sendTouchesForEvent:] + 567 12 UIKit
0x003bccb4 -[UIApplication sendEvent:]
+ 447 13 UIKit 0x003c19bf _UIApplicationHandleEvent +
7672 14 GraphicsServices
0x033e6822 PurpleEventCallback + 1550
15 CoreFoundation
0x02e36ff4
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION
+ 52 16 CoreFoundation 0x02d97807 __CFRunLoopDoSource1 + 215
17 CoreFoundation
0x02d94a93 __CFRunLoopRun + 979 18
CoreFoundation
0x02d94350 CFRunLoopRunSpecific + 208
19 CoreFoundation
0x02d94271 CFRunLoopRunInMode + 97 20
GraphicsServices
0x033e500c GSEventRunModal + 217 21
GraphicsServices
0x033e50d1 GSEventRun + 115 22 UIKit
0x003c5af2 UIApplicationMain + 1160
23 poemsoflove
0x00002728 main + 102 24 poemsoflove
0x000026b9 start + 53 25 ???
0x00000001 0x0 + 1 ) terminate called
after throwing an instance of
'NSException' Program received signal:
“SIGABRT”.
Guys there is no NSArray!
I save to NSUSerdefaults like this:
if ([mutable1 count]==0)
{
[mutable1 addObject: final1];
}
NSUserDefaults *list =[NSUserDefaults standardUserDefaults];
[list setObject:mutable1 forKey:#"favorites"];
[list synchronize];
and i load data like this
NSUserDefaults *prefs1 =[NSUserDefaults standardUserDefaults];
if ( [prefs1 objectForKey:#"favorites"] != nil)
{
mutable1 = [[NSMutableArray alloc] init];
mutable1 = [prefs1 objectForKey:#"favorites"];
and i get the objects! then when it runs the removeallobjects it crashes!
mutable1 = [[NSMutableArray alloc] init];
mutable1 = [prefs1 objectForKey:#"favorites"];
Even though you've declared mutable1 to be an NSMutableArray, you are reassigning it to the object returned by your NSUserDefaults object. This object is apparently an NSArray rather than an NSMutableArray, hence the crash.
You can load your NSMutableArray with the preferences array by doing something like this:
mutable1 = [[NSMutableArray alloc] init];
[mutable1 addObjectsFromArray:[prefs1 objectForKey:#"favorites"]];
The error messages indicate that you're sending the message to an immutable array, which raises an exception. Uncaught exceptions lead to program termination.
How are you creating the array? The most common error that can lead to this is doing something like:
[mutableArray copy]
Even if the thing you're copying is mutable, the copy will be immutable. In that randomly chosen example, use mutableCopy insted.
Somewhere you have set NSMutableArray1 to an instance of NSArray, not NSMutableArray or you declared NSMutableArray1 as a property of type NSArray vs. NSMutableArray.
Also, you should follow Cocoa / Objective-C naming conventions. Namely, class names start with upper case; variables take the form myArray1 (or something more descriptive, preferably).