Monday, 19 August 2013

Loading image from MAC system using NSBundle and plist

Loading image from MAC system using NSBundle and plist

Trying to Display the load the image from the folder present on MAC
desktop using path like (/Users/sai/Desktop/images/aaa.jpg) Which is
created in plist file called Data.plist at item0. As im using NSBundle it
is diaplying the image path but not loading the image from the desktop .I
have done a lots of research still couldn't find the solution .Plz help me
.Here is the code
NSString *path=[[NSBundle mainBundle]pathForResource:@"Data"
ofType:@"plist"];
NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:path];
NSString *errorDesc = nil;
NSPropertyListFormat format;
NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization
propertyListFromData:plistXML
mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format
errorDescription:&errorDesc];
NSArray *array=[NSArray arrayWithArray:[temp objectForKey:@"images"]];
NSString *object=[array objectAtIndex:0];
NSLog(@"object at index i %@",[object lastPathComponent]);
NSString *image=[object lastPathComponent];
mImageView.image=[UIImage imageNamed:image];
[self.view addSubview:mImageView];
Here is the screen shot of Data.plist

No comments:

Post a Comment