1

I what to store images with below code but occur error,How should i store images(not in photo library in program like this method)?

NSMutableArray *array=[[NSMutableArray alloc]init];
[array addObject:[UIImage imageNamed:@"a"]];
[array addObject:[UIImage imageNamed:@"b"]];
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [path objectAtIndex:0];
NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:@"SaveCartoons"];
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
[dict setObject:array forKey:@"1"];
[NSKeyedArchiver archiveRootObject:dict toFile:fullPath];

1 Answers1

1

The code up there is likely not to save.

For starters, UIImage is not something that can be easily archived.

Look at the answer to this question and convert your UIImage to NSData and then you can add that to your mutable array.

Community
  • 1
  • 1
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215