objective c - save UIImage to disk with simulator ios 8 doesn't work -


the following code works great on ios < 8 doesn't work xcode 6.1.1 , ios 8 device simulator

nsdata *imagedata = uiimagepngrepresentation(sharesnapshot); [imagedata writetofile:@"/users/myuser/desktop/123.png" atomically:yes]; 

does know if simulator issue don't have real device ios8 check on.

so you're running permission issue here. i'm not sure why worked before 8.0, i'm seeing (something changed):

the operation couldn't completed. (cocoa error 513)

https://developer.apple.com/library/ios/documentation/cocoa/conceptual/errorhandlingcocoa/errorobjectsdomains/errorobjectsdomains.html#//apple_ref/doc/uid/tp40001806-ch202-cjbgaibj

as stands, you'll run problems when running on actual device. better way handle save data application's document directory.

  1. fetch directory path via nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes)
  2. append filename using stringbyappendingpathcomponent

you can verify it's saving visiting simulators application directory:

  • /users/user/library/developer/coresimulator/devices//documents/

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -