0

我在 xcode 中运行以下代码。当我在模拟器中运行它时,offlineData 中有内容,但在设备上运行时,内容为零。

NSString *offlinePlistDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) lastObject];
NSString *offlineFilePath = nil;
offlineFilePath = [offlinePlistDirectory stringByAppendingPathComponent:@"offline.plist"]; 
NSData *offlineData = [NSData dataWithContentsOfFile:offlineFilePath];

我在Library的documents文件夹中有offline.plist文件......

请帮忙。提前致谢。

4

1 回答 1

-1

试试下面的代码

#define USER_DATA_PLIST_PATH    [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"offline.plist"]
#define USER_DATA_PLIST [NSMutableDictionary dictionaryWithContentsOfFile:USER_DATA_PLIST_PATH]

NSMutableDictionary *d = USER_DATA_PLIST;
于 2012-07-18T11:48:33.680 回答