如何在Nsuserdefault中保存为特定值的子值

时间:2015-11-17 14:42:27

标签: ios nsuserdefaults

    Work  
      - Speak with Client
      -Staff meeting
      -Project Delivery

    Home
      -Buy Milk
      -Pickup Your Son
      -Fill Out Water Tank

    Personal

      -Check Diabetes
      -Eat medicines
      -Do Exercise

[[NSUserDefaults standardUserDefaults]setValue:@"Speak with Client"forKey:@“Work"];

我想保存它,就像我需要["Speak with Client","Staff meeting","Project Delivery"]

的工作一样

示例

在工作任务列表中,我应[与客户,员工会议,项目交付]进行沟通

In Home task list I should have [Buy Milk,Pickup your son, fill out water tank]

如何在Nsuser Default中保存?

1 个答案:

答案 0 :(得分:0)

您可以将其设置为对象,而不是设置值。

[[NSUserDefaults standardUserDefaults] setObject:yourWorkArray forKey:"Work"];

来自NSUserDefaults

的文档
- (void)setObject:(id)value
           forKey:(NSString *)defaultName
  

value参数只能是属性列表对象:NSData,   NSString,NSNumber,NSDate,NSArray或NSDictionary。对于NSArray和   NSDictionary对象,其内容必须是属性列表对象。