ios - How to get the full file path of an UIImage -


this question has answer here:

i have ui image , want find path of it. how suppose ?

uiiimage *image ; // have saved image here nsstring *documentspath = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes)[0];   nsstring *filepath = [documentspath stringbyappendingpathcomponent: ????????? ]; // how image uiimage ? 

i tell solution question

  step 1: if have image in bundle,just follow below code        nsstring *stringimagepath = [[nsbundle mainbundle] pathforresource:@"your_image_name" oftype:@"jpg"]; // or oftype:@"png", etc.     step 2: if have image in particular place,just following code       nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory,                                                      nsuserdomainmask, yes);      nsstring *documentsdirectory = [paths objectatindex:0];      nsstring* path = [documentsdirectory stringbyappendingpathcomponent:                   @"yourimage.png" ]; //or yourimage.jpg      nslog(@"the image path is-%@",path);      nsdata* data = uiimagepngrepresentation(image);      [data writetofile:path atomically:yes];  

Comments

Popular posts from this blog

android - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -