I get the "thread 1 signal sigabrt" error for the line (return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));) in the main.m with following in the log:
2014-12-31 22:17:16.295 RowCounter[2994:110721] -[__NSCFString objectForKey:]: unrecognized
selector sent to instance 0x7fa0ea504300
2014-12-31 22:17:16.298 RowCounter[2994:110721] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector
sent to instance 0x7fa0ea504300'
*** First throw call stack:
(
0 CoreFoundation 0x0000000102e88f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000102b21bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000102e9004d -[NSObject(NSObject)
doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000102de827c ___forwarding___ + 988
4 CoreFoundation 0x0000000102de7e18 _CF_forwarding_prep_0 + 120
5 RowCounter 0x00000001025f1ebc -[RowCounterViewController
viewDidLoad] + 444
6 UIKit 0x000000010339aa90 -[UIViewController
loadViewIfRequired] + 738
7 UIKit 0x000000010339ac8e -[UIViewController view] + 27
8 UIKit 0x00000001033be507 -[UINavigationController
_startCustomTransition:] + 633
9 UIKit 0x00000001033ca3fe -[UINavigationController
_startDeferredTransitionIfNeeded:] + 386
10 UIKit 0x00000001033caf47 -[UINavigationController
__viewWillLayoutSubviews] + 43
11 UIKit 0x0000000103510509 -[UILayoutContainerView
layoutSubviews] + 202
12 UIKit 0x00000001032ee973 -[UIView(CALayerDelegate)
layoutSublayersOfLayer:] + 521
13 QuartzCore 0x0000000106b76de8 -[CALayer layoutSublayers] + 150
14 QuartzCore 0x0000000106b6ba0e
_ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
15 QuartzCore 0x0000000106b6b87e
_ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
16 QuartzCore 0x0000000106ad963e
_ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
17 QuartzCore 0x0000000106ada74a _ZN2CA11Transaction6commitEv + 390
18 UIKit 0x000000010327214d _UIApplicationHandleEventQueue +
2035
19 CoreFoundation 0x0000000102dbe551
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
20 CoreFoundation 0x0000000102db441d __CFRunLoopDoSources0 + 269
21 CoreFoundation 0x0000000102db3a54 __CFRunLoopRun + 868
22 CoreFoundation 0x0000000102db3486 CFRunLoopRunSpecific + 470
23 GraphicsServices 0x000000010646a9f0 GSEventRunModal + 161
24 UIKit 0x0000000103275420 UIApplicationMain + 1282
25 RowCounter 0x00000001025f23c3 main + 115
26 libdyld.dylib 0x0000000105418145 start + 1
27 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
As suggested by Sebastian Keller - I am calling [object objectForKey:]
on a string object in `[RowCounterViewController viewDidLoad].
Further suggested that NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"saveCount"];
=> is not really an NSDictionary.
For debugging purpose tried: NSDictionary *dict = @{};
and it did run.
This is code from that section, can you please point out what I am doing wrong?
- (void)viewDidLoad {
[super viewDidLoad];
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"saveCount"] ;
NSString *key = [NSString stringWithFormat:@"%ld", (unsigned long)_itemIndex] ;
NSNumber *numCounter = [dict objectForKey:key] ;
if (numCounter) {
counter = [numCounter intValue] ;
count.text = [NSString stringWithFormat:@"%d", counter] ;
} else {
counter = 0 ;
count.text = @"0" ;
}
}
another bit of code with NSUserDefaults:
- (void)saveCount {
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"saveCount"] ;
NSMutableDictionary *mDict = nil ;
if (dict == nil)
mDict = [NSMutableDictionary dictionary] ;
else
mDict = [dict mutableCopy] ;
NSString *key = [NSString stringWithFormat:@"%ld", (unsigned long)_itemIndex] ;
[mDict setObject:@(counter) forKey:key] ;
[[NSUserDefaults standardUserDefaults] setObject:mDict forKey:@"saveCount"] ;
[[NSUserDefaults standardUserDefaults] synchronize] ;
}
Reading for NSLog(@"%@", dict);
in console 10
Thank you