iphone - Image not loading from file path in iOS -


i want load image saved file path of image stored in iphone. getting path still says file not exist. code :

nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory,                                                              nsuserdomainmask, yes);         nsstring *documentsdirectory = [paths objectatindex:0];         nsstring *imagepath = [documentsdirectory stringbyappendingpathcomponent:[nsstring stringwithformat:@"%@",self.imagename]];         bool fileexists=[[nsfilemanager defaultmanager] fileexistsatpath:imagepath];         nslog(@"%@",imagepath);         uiimage *fetchimage = [uiimage imagewithcontentsoffile:imagepath]; 

fileexists returns no when path :

/var/mobile/applications/2ed5c185-8528-48d3-be0b-28582dc3d294/documents/img_0028.jpg

i ran problem well. save headache down road.

you can't rely on documents directory stay consistent 1 build next. when re-deploy app path change:

/var/mobile/applications/2ed5c185-8528-48d3-be0b-28582dc3d294/documents/ 

my problem was storing document path in json file , trying retrieve on subsequent builds. piece changes on every build:

2ed5c185-8528-48d3-be0b-28582dc3d294

store filename extension , pull document path dynamically. can proceed prefix path on filename.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -