最近,我是一名高中生,我对为 iPhone 制作应用很感兴趣。最近,我的一个应用程序问世了:NBlock。这是一个益智应用程序,非常具有挑战性。但是,它有一些问题。高分不保存。有人告诉我要使用 plist。有什么建议吗?
最佳答案
基于 URL 的方法:
// Get the URL for the document directory
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSURL *documentDirectoryURL = [[fileManager URLsForDocumentDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] objectAtIndex:0];
// Turn the filename into a string safe for use in a URL
NSString *safeString = [@"scores.plist" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
// Create an array for the score
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:[NSNumber numberWithInt:score]];
// Write this array to a URL
NSURL *arrayURL = [NSURL URLWithString:safeString relativeToURL:documentDirectoryURL];
[array writeToURL:arrayURL atomically:YES];
关于iphone - 如何在 iOS 编程中使用 pList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7059966/