我想初始化用户默认值,制作 NSDictionary,输入数据和 refisterDefaults。但是这段代码有错误。
//if UserFilter entry is nothing, create.
NSDictionary *defaultFilter = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:0] forKey:@"UserFilter"];
[userDefaults registerDefaults:defaultFilter];
//if UserBadgeColor entry is nothing, create.
UIColor *color = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];
NSValue *valColor = [NSValue value:&color withObjCType:@encode(UIColor)];
NSDictionary *defaultBadgeColor = [NSDictionary dictionaryWithObject:valColor forKey:@"UserBadgeColor"];
[userDefaults registerDefaults:defaultBadgeColor];
运行,UserFilter部分没有问题。但 UserBadgeFilter 部分有错误。错误行在最后。
谢谢。