[英]when starting to use NSUserDefaults for a custom classes is this time to move to Core Data?
When starting to use NSUserDefaults for a custom classes, with multiple levels, is this time to move to Core Data? 当开始对具有多个级别的自定义类使用NSUserDefaults时,这次是否要移至核心数据?
Background: 背景:
So given the above I'm really wondering whether I'd be better off going to Core Data here. 因此,鉴于以上所述,我真的很想知道我是否最好在这里使用Core Data。 Don't you conceptually here get to define the structure in XCode then have access saving/loading the data directly into the classes XCode creates for you?
您不是在概念上在XCode中定义结构,然后可以将数据直接保存/加载到XCode为您创建的类中吗?
Rough examples of structure: 结构的粗略示例:
- Items ( NSMutableArray )
物品( NSMutableArray )
- aString: NSString
aString:NSString
- aString2: NSString
aString2:NSString
- aDate: NSDate
日期:NSDate
- aDate2: NSDate
aDate2:NSDate
- aBool: BOOL
aBool:布尔
- aTI1: NSTimeInterval
aTI1:NSTimeInterval
- aTI2: NSTimeInterval
aTI2:NSTimeInterval
- Keywords ( NSMutableArray )
关键字( NSMutableArray )
- keyword: NSString
关键字:NSString
- keyword: NSString
关键字:NSString
Core Data or property lists or straight up object archival, yes. 是的,核心数据或属性列表或直接的对象归档。 As soon as you have any kind of data beyond very simple key/value pairs, you need to think about your model layer.
一旦拥有非常简单的键/值对之外的任何类型的数据,就需要考虑模型层。
Convenient though it is, user defaults -- as the name implies -- just isn't a place to persist user data! 尽管很方便,但用户默认值(顾名思义)不是保留用户数据的地方! It is for configuration, preferences, etc...
它用于配置,首选项等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.