How to store image in program (not in photo library)

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];

Answers


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.


Need Your Help

Best way to Handle Exceptions in C# Catch Block

exception exception-handling try-catch

Best way to Handle Exceptions in C# Catch Block.I have no other choice but to Log the error to SQL DB in Catch block.Howver i am wondering what is the best way to catch exception if caught in Catch...

Insert Unique Rows into Database Tables Using Java, Hibernate

java database hibernate table unique

I don't know this is already asked or not. But I don't find anyone. (Anyway this is not required for my project. But when I was working with database and Hibernate I had a doubt and now got time to...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.