My app crash on start. Please point me the way. Much appreciated.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
NSDictionary *temp = @{@(0): NSStringFromCGPoint(CGPointZero),
@(1): NSStringFromCGPoint(CGPointZero),
@(2): NSStringFromCGPoint(CGPointZero),
@(3): NSStringFromCGPoint(CGPointZero),
};
// Pro
NSDictionary *defaults = @{ // ... other PrefKeys
// No crash if I comment out this line
GMListVCOffsetsPrefKey:temp,
};
[[NSUserDefaults standardUserDefaults] registerDefaults: defaults];
}
Keys in plist must be strings. Here you have numbers.
See Property list documentation : "And although NSDictionary and CFDictionary objects allow their keys to be objects of any type, if the keys are not string objects, the collections are not property-list objects".
You are using non-NSString keys for the temp array which is causing the crash. The code below does not crash.
NSDictionary *temp = @{@"0": NSStringFromCGPoint(CGPointZero),
@"1": NSStringFromCGPoint(CGPointZero),
@"2": NSStringFromCGPoint(CGPointZero),
@"3": NSStringFromCGPoint(CGPointZero),
};
// Pro
NSDictionary *defaults = @{ // ... other PrefKeys
// No crash if I comment out this line
GMListVCOffsetsPrefKey:temp,
};
[[NSUserDefaults standardUserDefaults] registerDefaults: defaults];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.