iphone - how to save image in subfolder (AnyName) in document in phone help me -


her i'm using coding in program

nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes);  nsstring *docspath = [paths objectatindex:0];  nsstring *imagecachedirpath = [docspath stringbyappendingpathcomponent:@"image"]; nsstring *imagecachepath = [imagecachedirpath stringbyappendingpathcomponent:@"1.jpg"];  [[nsfilemanager defaultmanager] createfileatpath:imagecachepath contents:dataobj attributes:nil]; 

what problem in coding.send sample code .

one potential problem 'image' directory not exist when try create file in - it's required createfileatpath method run properly. check if image folder exists , create if required:

nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes);  nsstring *docspath = [paths objectatindex:0];  nsstring *imagecachedirpath = [docspath stringbyappendingpathcomponent:@"image"]; nsstring *imagecachepath = [imagecachedirpath stringbyappendingpathcomponent:@"1.jpg"];   if (![[nsfilemanager defaultmanager] fileexistsatpath: imagecachedirpath])       [[nsfilemanager defaultmanager] createdirectoryatpath:imagecachedirpath                                  withintermediatedirectories:no                                                   attributes:nil                                                       error:null];  [[nsfilemanager defaultmanager] createfileatpath:imagecachepath                                          contents:dataobj                                        attributes:nil]; 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -