开发者

Since purchasing developer license iphone app can't write .plist

I recently paid the $99 for the dev license to be able to load my app on my iPhone. Prior to doing that my app was able to write a simple 'names.plist' file to the Documents directory of my app in the simulator. I was able to launch the app at a later time in the开发者_开发问答 simulator and some text would be retained inside the file. Since purchasing the license and installing the app on my phone, the app does write to the sandbox Documents directory in the simulator or phone. It seems like the developer license changed something.

The code for when it worked has not changed and correctly returned the sandbox Documents directory. It is below. I've also included an NSLog print of what the app shows now for the directory and filename with the same code. It is for a file named 'Documentsname.plist', not the 'names.plist' I am wanting. I greatly appreciate any help! Thanks.

//.h
#define username @"name.plist"

// .m -- Define and return this App's sandbox iOS Documents Directory
- (NSString *)userFilePath {

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    NSString *documentsDirectory = [paths objectAtIndex:0];

    return [documentsDirectory stringByAppendingFormat:username];

}

An NSLog of the path that is trying to write to and then read from is below:

/Users/<user>/Library/Application Support/iPhone Simulator/4.3.2/Applications/AF36A4E1-5387-4B10-8F3A-A69AAA307FE4/Documentsname.plist


return [documentsDirectory stringByAppendingPathComponent:username];

You are just appending a string, not a path. By appending a "path component", it automatically adds/removes needed/unneeded slashes.

I would also recommend not combining the username and ".plist".

#define username @"name"

return [[documentsDirectory stringByAppendingPathComponent:username]stringByAppendingString:@".plist"];


What about simply adding the missing "/"?

#define username @"/name.plist"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜