iOS关于登录注册信息保存沙盒的问题

// 读取沙盒中存储用户信息的plist

NSString * path = [NSString stringWithFormat:@"%@/Documents/userInfor.plist", NSHomeDirectory()];


NSMutableDictionary *userInfor = [NSMutableDictionary dictionaryWithContentsOfFile:path];


if (!userInfor) {

    userInfor = [[NSMutableDictionary alloc]init];

}


// 把用户名和密码写到沙盒字典

[userInfor setValue:@"&*iuhng*&" forKey:@"password"];

[userInfor setValue:@"1111" forKey:@"username"];

[userInfor writeToFile:path atomically:NO];


// 登录的时候遍历沙盒字典便可

NSString * path = [NSString stringWithFormat:@"%@/Documents/userInfor.plist", NSHomeDirectory()];

NSMutableDictionary *userInfor = [NSMutableDictionary dictionaryWithContentsOfFile:path];

你可能感兴趣的:(ios,沙盒的读写)