У меня проблема с моим приложением, я пытаюсь сохранить данные в основных данных, скопировав метку, но это дает мне эту ошибку
Завершение работы приложения из-за необработанного исключения «NSInvalidArgumentException», причина: '- [__ NSCFString appendString:]: аргумент nil'
Это код
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
ClientDownload *currentClientDownload = [[xmlClientDownloadParser clientArray] objectAtIndex:indexPath.row];
CGRect contentFrame = CGRectMake(45, 2, 265, 30);
clientName = [[[UILabel alloc] initWithFrame:contentFrame] autorelease];
clientName.numberOfLines = 2;
clientName.font = [UIFont boldSystemFontOfSize:12];
clientName.text = [currentClientDownload NAME];
[cell.contentView addSubview:clientName];
CGRect detailFrame1 = CGRectMake(45, 40, 265, 30);
clientMobile = [[[UILabel alloc] initWithFrame:detailFrame1] autorelease];
CGRect detailFrame2 = CGRectMake(45, 40, 265, 30);
clientAccount = [[[UILabel alloc] initWithFrame:detailFrame2] autorelease];
clientAccount.font = [UIFont systemFontOfSize:10];
clientAccount.text = [currentClientDownload ACCOUNT];
clientMobile.font = [UIFont systemFontOfSize:10];
clientMobile.text = [currentClientDownload MOBILE];
[cell.contentView addSubview:clientAccount];
[cell.contentView addSubview:clientMobile];
NSLog(@"SaveData");
Clients *client = (Clients *)[NSEntityDescription insertNewObjectForEntityForName:@"Clients" inManagedObjectContext:managedObjectContext];
if( (clientName.text) || (clientAccount.text) || (clientMobile.text) != NULL)
{
client.ACCOUNT = clientAccount.text;
client.NAME = clientName.text;
client.MOBILE = clientMobile.text;
NSLog(@"CLIENT GENERATED");
NSError *error;
if (![managedObjectContext save:&error])
{
NSLog(@"Problem saving: %@", [error localizedDescription]);
}
}
NSError * error;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Clients" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];
NSArray *fetchedObjects = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
for (NSManagedObject *info in fetchedObjects)
{
NSLog(@"ACCOUNT: %@",[info valueForKey:@"ACCOUNT"]);
NSLog(@"NAME: %@",[info valueForKey:@"NAME"]);
NSLog(@"MOBILE: %@",[info valueForKey:@"MOBILE"]);
}
[fetchRequest release];
return cell;
}