-1
NSString *profilestring = [self.userDefaults objectForKey:@"profilestrings"];
NSDictionary *dicProfile = [profilestring propertyListFromStringsFileFormat];
NSLog(@"--->>%@",profilestring);
NSLog(@">>%@",dicProfile);

self.userDefaults is NSUserDefaults, and NSLog(@"--->>%@",profilestring); prints a string, such as

{
    useraddtime = 1401444211;
    userage = 11;
    usernickname = XJD;
    usersex = 1;
    userstatus = 1;
}

but NSLog(@">>%@",dicProfile); prints (null), can you help me?

Bin
  • 484
  • 1
  • 6
  • 18

2 Answers2

1

Apples documentation says the keys and values themselves are always strings enclosed in straight quotation marks. Your keys and values are not enclosed in quotation marks. The string i.e profilestring should look like this

{
"useraddtime" = "1401444211";
"userage" = "11";
"usernickname" = "XJD";
"usersex" = "1";
"userstatus" = "1";

}

Rohan Bhale
  • 1,323
  • 1
  • 11
  • 29
0

It looks like your [self.userDefaults objectForKey:@"profilestrings"] is actually a NSDictionary so you could do something like

NSDictionary *dicProfile = [NSDictionary dictionaryWithDictionary:[self.userDefaults objectForKey:@"profilestrings"]];
Pancho
  • 4,099
  • 1
  • 21
  • 32