i want to save an array of objects in a property list.
i done it by using this method:
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"Data.plist"];
DataObj *obj1 = [[DataObj alloc]initWithDataObj:@"Facebook" :@"yosi" :@"1234" :[UIImage imageNamed:@"blogger.png"] ];
DataObj *obj2 = [[DataObj alloc]initWithDataObj:@"Facebook2" :@"yosi2" :@"12345" :[UIImage imageNamed:@"blogger.png"] ];
self.list = [[NSMutableArray alloc]initWithObjects:obj1,obj2,nil ];
[self.list writeToFile:finalPath atomically:YES];
the fourth object in the DataObj is a image and i cant save it in a property list,there is any solution for this problem?
If you are using imageNamed, then I’m assuming the image is in your main bundle, in which case I would put the image name in the plist, and use imageNamed: again when when you read it.
The other option is to turn your image into something that is encodable, like an NSData object. When you read the property list back in, convert the data back into a UIImage.
Take a look at
UIImagePNGRepresentation.
and -initWithData: