objective c - iOS - NSFileManager file not exist -


i hosting in-app purchase content apple. have managed download contents , right want save in device.

[[nsfilemanager defaultmanager] removeitematpath:dstpath error:nil]; [[nsfilemanager defaultmanager] copyitematpath:srcpath topath:dstpath error:nil]; 

this code above how move content downloaded desired location.

it seems work fine , when try display content works. when stop , run app again files not exist.

what missing?

my code:

- (void)processdownload:(skdownload *)download {     nsstring *path = [download.contenturl path];      path = [path stringbyappendingpathcomponent:@"contents"];      nsfilemanager *filemanager = [nsfilemanager defaultmanager];     nserror *error;     nsarray *files = [filemanager contentsofdirectoryatpath:path error:&error];      nsmutablearray *stickersdownloadedarray = [[nsmutablearray alloc] init];      (nsstring *file in files)     {         nsstring *fullpathsrc = [path stringbyappendingpathcomponent:file];          nsstring *filename = [fullpathsrc lastpathcomponent];         nsstring *fullpathdst = [[nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0] stringbyappendingpathcomponent:[nsstring stringwithformat:@"/%@", filename]];          [filemanager removeitematpath:fullpathdst error:nil];         [filemanager moveitematpath:fullpathsrc topath:fullpathdst error:nil];          nslog(@"fullpathdst: %@", fullpathdst);         nslog(@"file: %@", file);         nslog(@"key: %@", download.transaction.payment.productidentifier);          [stickersdownloadedarray addobject:fullpathdst];     }      [[nsuserdefaults standarduserdefaults] setobject:stickersdownloadedarray                                               forkey:download.transaction.payment.productidentifier];     [[nsuserdefaults standarduserdefaults] synchronize]; } 

an example of fullpathdst is

/var/mobile/containers/data/application/e921add6-b022-4da2-8416-627db44e679a/documents/real4_12@2x.png 

an app's sandbox changes @ different times. must never store full paths files. store relative path.

in case, store path relative documents folder. when reload relative path when app starts up, recalculate full path again.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -