Hi,
I have a problem, how can we retrieve the array data stored in plist file.
The plist file and source code is as shown below,
------------------------plist File-------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Name</key>
<string>abcxxx</string>
<key>Phones</key>
<array/>
<key>item1</key>
<string>121327777</string>
<key>item2</key>
<string>333333333</string>
</dict>
</plist>
---------------------------------------------------------
-(id) init
{
NSString *errorDesc = nil;
NSPropertyListFormat format;
phoneNumbers =[[NSMutableArray alloc]init];
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"testfile" ofType:@"plist"];
NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization
propertyListFromData:plistXML
mutabilityOption:NSPropertyListMutableContainersAndLeaves
format:&format errorDescription:&errorDesc];
if(!temp){
NSLog(errorDesc);
[errorDesc release];
}
self.personName = [temp objectForKey:@"Name"];
self.phoneNumbers = [NSMutableArray arrayWithArray:[temp objectForKey:@"Phones"]];
NSLog(@"Label executed %@",[phoneNumbers objectAtIndex:0]);
UILabel *name = [[UILabel alloc]initWithFrame:CGRectMake(-180, 100, 100, 20)];
name.text = [phoneNumbers objectAtIndex:1];
[self addChild:name];
NSLog(@"Label executed %@",name);
Anyone help me on this.
Thanks in Advance,