简体   繁体   中英

Update Supporting Files from Web Server

I am writing an IPhone application in witch I downloaded files and photos locally in the Supporting Files folder ( in the right panel of xcode ), these files are downloaded also in a web server, what I want is that if the application detect that these files are updated in the web server , it replace them with the new content in the Supporting Files I used

NSArray* pathArray = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,NSUserDomainMask, YES);  
documentsDirectory = [pathArray objectAtIndex:0];
NSString* localFile = [documentsDirectory stringByAppendingPathComponent:@"test.txt"];
[data writeToFile:localFile options:NSDataWritingAtomic  error:&error];

the code works well but the problem is that it replaces content of files in
Library/Application Support folder and not the Supporting Files so when I do :

NSBundle *thisBundle = [NSBundle mainBundle];
NSString *TextURL = [thisBundle pathForResource:@"test" ofType:@"txt"];
NSURL *instructionsURL = [NSURL fileURLWithPath:TextURL];
NSString *TextString = [NSString stringWithContentsOfURL:instructionsURL];
mayText.text = TextString;  

the old content is displayed and not the updated one How can I change my code to replace files in Supporting files directory every time Application Support files are changed ? And what is the difference between these two folders? Thank you.

You can't. iOS Apps on the device are signed, changing the bundle's content would break that signing. And as all files that are managed by Xcode and added to a target go to the bundle, they must not be changed.

Instead download the files to a sandbox directory, such as Documents and access it there.

Also note that Supporting Files iin Xcode is not a directory but a group. It juste groups it content inside the Xcode project but does not organize the files in a directory on file system level.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM