在模型部分,我有一些数据类型,其属性都是属性列表数据类型。最终,用户将通过网络向服务器发送和读取这些数据项。问题是,我应该使用 NSCoding 和 NSKeyedArchiver (如下面的第二个代码块,这使得 XML 恕我直言丑陋)还是我应该做一些类似于子类 NSDict 的事情,以便我可以使用dictionaryWithContentsOfFile:
并writeToFile:atomically:
获得漂亮的 XML?
@interface Word : NSObject <NSCoding>
@property (strong, nonatomic) NSString *language;
@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) NSDictionary *detail;
@property (strong, nonatomic) NSString *userName;
@property (strong, nonatomic) NSString *userId;
@property (strong, nonatomic) NSArray *files;
- (void)copyFromTemporaryFiles:(NSArray *)temporaryFiles; // populates self.files
@end
和
@interface Category : NSObject <NSCoding>
@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) NSDictionary *detail;
@property (strong, nonatomic) NSDate *updated;
@property (strong, nonatomic) NSArray *words;
+ (Category *)categoryWithName:(NSString *)name;
- (void)saveWithName:(NSString *)name;
@end