NSDictionary value replacing instead of adding in Plist

前端 未结 3 951
灰色年华
灰色年华 2020-12-20 02:30

hi i tried to add values(book id,page number,notes) from NSdictionary to Plist but each time the new value replacing the previous one?but i need all values in plist my code

3条回答
  •  心在旅途
    2020-12-20 03:09

    because plist can store value with unique key only. if you try to save value with same key it will replace old one with new value. so always save new value with new key (eg. item0, item1, item3 etc.)

    following line will store two usernote with key @"usernotes1" and @"usernotes2" respectively

    [final setValue:notes forKey:@"usernotes1"];
    [final setValue:notes forKey:@"usernotes2"];
    

提交回复
热议问题