In plist,I want to keep an array in each dictionary (Item).And if it is created,how I can send elements to that array.For example,If I created an account for an user,I will keep name,sex,email,password everything in a dictionary(item),in the similar way an array which contains inbox messages.Then I want to know that how I can store coming messages to that inbox array.
Asked
Active
Viewed 96 times
5
-
Yes I took array as Mutable but,facing difficult when I adding element to that array .It is that when we adding ,we should have to declare dictionary at entering details.similarly when we have to send a message,again we have to declare a dictionary and have to save it.Then it becoming ,in plist another dictionary is creating and messages are going to it.It not joining in already existed account. – Rajkumar Jun 20 '12 at 12:21
2 Answers
0
NSArray *array=[NSArray arrayWithObjects:<#(id), ...#>, nil];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *libraryDirectory = [paths objectAtIndex:0];
NSString *location = [libraryDirectory stringByAppendingString:@"/somefilename.plist"];
[array writeToFile:location atomically:YES];
Array can be loaded as below:
path = [bundle pathForResource:@"file" ofType:@"plist"];
array = (path != nil ? [NSArray arrayWithContentsOfFile:location] : nil);