Sunday 15 April 2012

objective c - iOS code skipping over dispatch_async -


I need to download data from URL (this data is printed in JSON format) and stored in "configuration" file extend to app AppDelegate.m file app when I run the app, it is only one reason left to Preshn_asink address why and I can how to fix it?

  - (BOOL) application: (UIApplication *) application had FinishLaunchingWithOptions: (NSDictionary *) file config.json download launchOptions {// dispatch_async (Dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^ { NSString * configFileUrl = @ "http: // webserviceurl"; // NSString * downloadToFile = @ "configuration. Jason"; NSData * data = [NSData dataWithContentsOfURL: [NSURL URLWithString: configFileUrl]]; [own performance Cynkrtamantthred: @ selector ( WriteDataTfigrGriJsonFile :) with object: data waitingUnitone: yes];});   

More code below and this is where I am writing data to a file in the app's document directory:

  - (zero ) WriteDataToConfigurationJsonFile: (Ansdita *) jsonData {NSString * content = [[NSString alloc] initWithData: jsonData encoding: NSUTF8StringEncoding]; // Get the document directory: NSArray * paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString * document directory = [path item overindexx: 0]; // Create a file name to write data to use documents directory: NSString * fileName = [NSString stringWithFormat: @ "% @ / configuration. Jason" Documents directory]; // Save the content to the document directory [content content file: filename atom: yes encoding: NSUTF8 string encoding error: zero]; }    

performSelectorOnMainThread is a run loop method, you need To use:

  sending_assink (send_gate_man_clline (), ^ {/ * code * /});    

No comments:

Post a Comment