我的应用在启动时崩溃。请给我指路。非常感激。
- (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];
}
最佳答案
plist中的键必须是字符串。这里有数字。
参见Property list documentation:“尽管NSDictionary和CFDictionary对象允许它们的键成为任何类型的对象,但是如果键不是字符串对象,则集合也不是属性列表对象”。
关于ios - iOS:registerDefaults导致崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15451927/