在设备上测试我的应用程序时出现奇怪的行为。这是我用来更新键值的函数,它在我的 iphone 模拟器上运行顺畅。确实很好。但是 plist 第 6 行的 nslog 在设备上返回 null。您对我做错的原因和原因有任何想法吗?先感谢您
-(void) updateData:(int)contacto campo:(int)campo {
NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *plistPath = [rootPath stringByAppendingPathComponent:@"Data.plist"];
NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
NSLog(@"%@",plistDict);
switch (campo) {
case 0:
veterinarioID = contacto;
[plistDict setValue:[NSNumber numberWithInt:veterinarioID] forKey:@"veterinario"];
NSLog(@"%d",veterinarioID);
break;
case 1:
peluqueriaID = contacto;
[plistDict setValue:[NSNumber numberWithInt:peluqueriaID] forKey:@"peluqueria"];
NSLog(@"%d",peluqueriaID);
break;
case 2:
residenciaID = contacto;
[plistDict setValue:[NSNumber numberWithInt:residenciaID] forKey:@"residencia"];
NSLog(@"%d",residenciaID);
break;
default:
break;
}
[plistDict writeToFile:plistPath atomically: YES];
}