I'm having serious problems with NSStrings, I have no idea what I'm doing wrong. Heres what I do.
Load a NSManagedObject out of core data - Works
Make a string object out of the key values of the NSManagedObject - Works
Add the string object to an NSMutableArray - Works
Pull the values out of the NSMutableArray and insert them into table view cells - Does not work, I cannot get proper values so I get an "EXC_BAD_ACCESS" error
The proper values are inserted into the NSMutableArray but they are NSCFString objects, this happens in other instances of my code but I get no problems. The problem happens when I try to pull the values out of the NSMutableArray to use in my table view. Can someone please explain what I'm doing wrong?
Load a NSManagedObject out of core data - Works
Make a string object out of the key values of the NSManagedObject - Works
Add the string object to an NSMutableArray - Works
Pull the values out of the NSMutableArray and insert them into table view cells - Does not work, I cannot get proper values so I get an "EXC_BAD_ACCESS" error
Code:
//LOADING THE VALUES AND PUTTING THEM INTO THE ARRAY
//NAME
NSString *fullName = [[object valueForKey:@"firstName"] stringByAppendingString:@" "];
fullName = [fullName stringByAppendingString:[object valueForKey:@"lastName"]];
NSString *string = fullName;
[data addObject:string];
[labelList addObject:@"Name:"];
[fullName release];
//EMAIL
NSString *email = [[object valueForKey:@"username"] stringByAppendingString:@
"@suffieldacademy.org"];
[data addObject:email];
[labelList addObject:@"Email:"];
[email release];
Code:
//INSERTING THE VALUES OF THE ARRAY INTO THE CELLS, THIS OCCURS DURING -cellAtRowForIndexPath
//NOTE: the textField variable is a UILabel that has been added to the cell, it works perfectly fine if I pass it a value manually (ex: textField.text = @"some string") so it is not the design of the textfield that is causing the problem
int row = [indexPath row];
NSString *value = [data objectAtIndex:row]; //CAUSES THE ERROR
textField.text = value;
textField.tag = row;
The proper values are inserted into the NSMutableArray but they are NSCFString objects, this happens in other instances of my code but I get no problems. The problem happens when I try to pull the values out of the NSMutableArray to use in my table view. Can someone please explain what I'm doing wrong?
Last edited: