IOS - plist使用

//1 可读取,不可写入工程下的plist文件;

//    NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"OfficialDoc" ofType:@"plist"];

    

    //2 Document 沙盒中的文件(没有文件可自动创建)

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    NSString *documentsDirectory = [paths objectAtIndex:0];

    _plistPath = [documentsDirectory stringByAppendingPathComponent:@"OfficialDoc.plist"];

    _docPlist = [[NSMutableDictionary alloc] initWithContentsOfFile:_plistPath];

    if (!_docPlist) {

        NSLog(@"new list");

        _docPlist = [NSMutableDictionary dictionary];

    }

    NSLog(@"init-----%@",_docPlist);

你可能感兴趣的:(plist)