Can't write file into iPhone

Discussion in 'iOS Programming' started by Sui Jen, Jan 22, 2010.

  1. Sui Jen macrumors newbie

    Oct 14, 2009

    I can write file into simulator but can't write file into iPhone.

    This is how I write file:
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];

    // the path to write file
    NSString *appFile = [documentsDirectory stringByAppendingPathComponent:mad:"myFile"];

    [data writeToFile:appFile atomically:YES];

    Is this because of the Apple certification problem? Or is there any other reason that cause the application unable to write file into iPhone?

  2. skunkworker macrumors regular

    Sep 9, 2007
    It would have nothing to do with the "apple certification problem". How do you know that it is not being created on the device? are you doing a dump of the application's directory from the organizer?
  3. xsmasher macrumors regular


    Jul 18, 2008
    What type of object is "data" ? I tested your code on the phone and it worked fine with an NSData. Should work with strings, arrays, dicts too. Maybe data is nil, or your loading code is broken?

Share This Page