Я пишу данные для plist с помощью alwys возвращает мне значение nill. Мне также нужно добавить данные к предыдущим значениям массива. Но Значения alwys нуль .. Ниже приведен код:Написание/добавление данных в Plist возвращает nill
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
// get documents path
NSString *documentsPath = [paths objectAtIndex:0];
// get the path to our Data/plist file
NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"a.plist"];
// set the variables to the values in the text fields
// create dictionary with values in UITextFields
NSDictionary *plistDict = [NSDictionary dictionaryWithObject:@"c" forKey:@"Id"];
if ([[NSFileManager defaultManager] fileExistsAtPath:plistPath])
{
array = [[NSMutableArray alloc] initWithContentsOfFile:plistPath];
[array addObject:plistDict];
[array writeToFile:plistPath atomically:YES];
NSLog(@"array%@",array);
}
else
{
NSArray *array = [NSArray arrayWithObject:plistPath];
[array writeToFile:plistPath atomically:YES];
}
Ваш массив всегда равен нулю, даже в первый раз? Или где он возвращает nil в блоке 'if' или' else'? –
alwys returm в условии IF – user3226440