我的代码是这样的。而且ret的值始终是NO,我认为写路径是不允许的。但是我可以在哪里为我的应用程序在 MAC OS X 上存储我的信息?你能帮我找到正确的路径来存储我的应用程序设置吗?非常感谢~:)
NSString* writePath = [[[NSBundle mainBundle] resourcePath]
stringByAppendingPathComponent:@"Brain.plist"];
NSLog(@"%@",writePath);
NSMutableDictionary* dictForRet = [[NSMutableDictionary alloc]init];
NSNumber* applicationNumber = [[NSNumber alloc]initWithInt:0];
NSMutableDictionary* root = [[NSMutableDictionary alloc]init];
NSArray* propertyArray = [[NSArray alloc]initWithObjects:kPropertyArrayApplicationPath,kPropertyArrayApplicationCS, nil];
NSMutableDictionary* brain = [[NSMutableDictionary alloc]init];
[root setObject:propertyArray forKey:kPropertyArrayName];
[dictForRet setObject:applicationNumber forKey:kPropertyKeyApplicationNumber];
[dictForRet setObject:root forKey:kPropertyArrayDictName];
[dictForRet setObject:brain forKey:kPropertyDictBrainName];
NSLog(@"%@",dictForRet);
ret = [dictForRet writeToFile:writePath atomically:YES];
NSLog(@"%d",ret);