1
我已經在XCode &中創建了一個pList(myData.plist),但是當我運行該程序時,它沒有被複制到iphone模擬器目錄。因此,我無法讀取它。我已經記錄的文件名,這似乎是指向正確的地方,這裏還有沒有plist文件存在(在Finder中確認)iPhone SDK - plist沒有被複制到模擬器
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *pListFileName = [documentsDirectoryPath stringByAppendingPathComponent:@"myData.plist"];
NSLog(pListFileName);
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath: pListFileName]) {
self.pList = [[NSMutableDictionary alloc] initWithContentsOfFile:pListFileName];
//code for reading data in plist
}
完美,謝謝!它在捆綁中,但我沒有複製它。 – Gary 2010-10-02 23:39:49
謝謝,忘了把它也包含進去。 – Max 2013-08-10 20:33:28