Note that there are some explanatory texts on larger screens.

plurals
  1. PODownloading files in two different folders ios
    primarykey
    data
    text
    <p>i have an iphone application, that downloads pdf file using a JSON file the JSON response looks like that</p> <pre><code>{ "resource_id":"1132", "name_en":"mpla mpla mpla", "name_cn":null, "product_id":"1064", "product":"mpla", "category":"mpla Literature", "fileURLString_en":"http://mpla.mpla.com/media/427/mpla.pdf", "fileURLString_en_date":"Mon, 03 Sep 2012 08:53:40 GMT", "fileURLString_cn":"http://mpla.mpla.com/media/427/mpla.pdf", "fileURLString_cn_date":"Mon, 03 Sep 2012 08:53:40 GMT", "thumbnailURLString_en":"http://mpla.mpla.com/media/1472/mpla.png", "emailURLString_en":null, "emailURLString_en_date":null, "descriptionString_en":null, "emailThumbnailURLString_en":null, "emailThumbnailURLString_en_date":null, "externalUrl":null }, </code></pre> <p>and i want to download the en files on Library/Caches/en folder and the Chinese files on the Library/Cashes/ch folder.</p> <p>i'm using ASIHTTPRequest for the communication part! What are your suggestion (in code) for downloading and saving the files an the particular folders?</p> <p>here is my code so far:</p> <pre><code> -(void)createDirectory:(NSString *)directoryName atFilePath:(NSString *)filePath { NSString *filePathAndDirectory = [filePath stringByAppendingPathComponent:directoryName]; NSLog(@"%@",filePathAndDirectory); NSError *error; if (![[NSFileManager defaultManager] createDirectoryAtPath:filePathAndDirectory withIntermediateDirectories:NO attributes:nil error:&amp;error]) { NSLog(@"Create directory error: %@", error); } } NSString* filePath=[NSString stringWithFormat:@""]; NSString *clanguage = [[NSLocale preferredLanguages] objectAtIndex:0]; if([clanguage isEqualToString:@"en"]) { NSString *cachesPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]; filePath = [NSString stringWithFormat:@"%@/en/%@",cachesPath,urlPath.lastObject]; } else if([clanguage isEqualToString:@"zh-Hans"]) { NSString *cachesPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]; filePath = [NSString stringWithFormat:@"%@/cn/%@",cachesPath,urlPath.lastObject]; } </code></pre> <p>i have tried creating two subfolders but can't save the files in them depending on the link. I also tried renaming the files in name for english and ch_name for chinese but that is not convenient!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload