1 //Create a folder named Launchimage in the documents directory2NSString *path = [[Nshomedirectory () stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"Launchimage"];3NSLog (@"%@", path);4 5Nsfilemanager *filemanager =[Nsfilemanager Defaultmanager];6BOOL Isdir =FALSE;7BOOL isdirexist = [FileManager fileexistsatpath:path isdirectory:&Isdir];8 if(! (Isdirexist &&isdir))9 Ten { OneBOOL Bcreatedir =[FileManager createdirectoryatpath:path withintermediatedirectories:yes attributes:nil Error:nil]; A if(!Bcreatedir) { -NSLog (@"failed to create folder! "); - } theNSLog (@"folder created successfully, file path%@", path); - } - -UIImage *image=[uiimage Imagewithcontentsoffile:@"Testimage.png"]; +NSData *data =uiimagepngrepresentation (image); - //Save the Testimage.png to the Launchimage folder with the new name Image1.png +BOOL issaved= [FileManager createfileatpath:[path stringbyappendingstring:@"/image1.png"] Contents:data Attributes:nil]; ANSLog (@"picture Save Status:%d", issaved); at - //get a saved picture -UIImage *newimage=[uiimage Imagewithcontentsoffile:[path stringbyappendingstring:@"/image1.png"]]; - - //Deleting Files -BOOL isdelete=[FileManager Removeitematpath:path error:nil]; inNSLog (@"%d", Isdelete);
iOS creates folders, saves, reads, and deletes files in the document directory