I’ m creating a custom UITableViewCell view. I have a method for UITableViewCell and I have created UILabel memberLabel programmatically:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString * const cellIdentifier = @"cellMemberId";
CPNMemberCell *cell = (CPNMemberCell *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
[[NSBundle mainBundle] loadNibNamed:@"TeamCell" owner:self options:nil];
cell = baseCell;
}
memberLabel = [[UILabel alloc] initWithFrame:CGRectMake(32, 19, 183, 27)];
[cell addSubview:memberLabel];
NSString * const test = @"test input";
memberLabel.text = test;
return cell;
}
So this code works quite well. But when I change test string value to string containing JSON response in MutableDictionary, all fails. I specially output that string to console log in order to be sure it is not empty or whatever. And I have an except during assigning
that string to UILabel:
NSString * const test = [members valueForKey:@"modelId"];
NSLog(@"Output: %@", test);
memberLabel.text = test;
I don’t understand what’s wrong: response correctly prints to the console, UILabel correctly displays text strings as in the first code block, but when I try to display string with that response I have a SIGABRT exception in the main.
Check what is the data type of
testvariable. Use:Is it printing
data type = NSString? If not, that is the issue.Also try this,