我需要向我的plist中写入一个字符串,但是找不到plist,为什么?

在.h中

NSMutableDictionary *cameras;


.m文件

#define DOCUMENTS [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]


在ViewDidLoad中

NSString *plistPath = [DOCUMENTS stringByAppendingPathComponent:@"Сamera.plist"];
    if([[NSFileManager defaultManager] fileExistsAtPath:plistPath])
    {
        NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
        cameras = [NSMutableDictionary dictionaryWithDictionary:[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:nil errorDescription:nil]];
    }

最佳答案

//改为:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *plistPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Сamera.plist"];

关于ios - 找不到我的.plist,为什么?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18233706/

10-13 02:16