在我的 iPhone 应用程序中,我需要将 NSMutable 字典保存在文件中。字典包含 NSString 键和 NSString 值。
-(NSString*)datafilePath{
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
return [documentsDirectory stringByAppendingPathComponent:@"resourceItemProperties.txt"];
}
- (void)applicationDidEnterBackground:(UIApplication *)application{
if(resourceItemProperties && rootViewController.selectedIndex == 0)
{
BOOL test = [resourceItemProperties writeToFile:[self datafilePath] atomically:YES];
}}
但测试总是返回 NO;我该如何解决这个问题?