How to save the image as a profile of one user?

I am starting to develop an iphone app. I made an iphone application that it contains a registration page, login page and profile, using the sql database as a save field. I want to save pic as pic profile. I made a pic selection from already saved photos from the simulator. I want to keep this pic as it is, when again, if I run this ... plz help me ...

+7
source share
2 answers

You can save the image in the application, and you can get the image during application loading:

Here is a tutorial for you:

http://www.friendlydeveloper.com/2010/02/using-nsfilemanager-to-save-an-image-to-or-loadremove-an-image-from-documents-directory-coding/

+2
source

Use this when retrieving an image of an image selected from the gallery using imagepicker:

-(void)saveImageInDirectoryAndStoreInDatabase { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES); NSString *documentsDir = [paths objectAtIndex:0]; NSString *imgFilePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",youruserName]; NSData *data = UIImagePNGRepresentation(youruserImage) //which is obtained from imagepicker [data writeToFile:imgFilePath atomically:YES]; //query here into database with imageFile(A string) which is[NSString stringWithFormat:@"%@.png",youruserName]; } 

Similarly, when extracting the image, use documentDirectory + imageFile.png (which is obtained from the database by querying the username with its image file) to set pic user profile

0
source

All Articles