fetchedResultsController and Integer

Discussion in 'iPhone/iPad Programming' started by xaphann, Apr 30, 2012.

  1. macrumors newbie

    Joined:
    Oct 22, 2011
    #1
    Hi

    I am updating a TableViewController from entity that contains two strings and one integer. The strings work correctly the integer does not. Here is my code;
    Code:
     - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";
        UsersCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        
        if (!cell) {
            cell = [[GolfersCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
        }
        
        Users *users = [_fetchedResultsController objectAtIndexPath:indexPath];
        
        cell.firstName.text = users.firstName;
        cell.lastName.text = users.lastName;
            int i = [users.gendID intValue] ;
        cell.genID.text = [NSString stringWithFormat:@"%d", i];
        
        [self configureCell:cell atIndexPath:indexPath];
       
        return cell;
    }
    
    Now this does work, commenting out the line "int i = [users.gendID intValue] ;" and it will work correctly. Stepping though the program this the error that it returns;
    Code:
     2012-04-30 16:49:02.369 My App [9757:fb03] -[Users gendID]: unrecognized selector sent to instance 0x6b8a6c0
    2012-04-30 16:49:02.373 My App[9757:fb03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Users gendID]: unrecognized selector sent to instance 0x6b8a6c0'
    *** First throw call stack:
    (0x16b0022 0x1841cd6 0x16b1cbd 0x1616ed0 0x1616cb2 0x3a6d 0xb5c54 0xb63ce 0xa1cbd 0xb06f1 0x59d21 0x16b1e42 0x2068679 0x2072579 0x1ff74f7 0x1ff93f6 0x1ff8ad0 0x168499e 0x161b640 0x15e74c6 0x15e6d84 0x15e6c9b 0x15997d8 0x159988a 0x1b626 0x28bd 0x2825)
    terminate called throwing an exception(lldb) 
    Thanks for the help
     
  2. macrumors 603

    Joined:
    Aug 9, 2009
    #2
    What type is the gendID property? Post the code from interface Users that shows the @property line for gendID.

    If the Users class doesn't have a gendID property, then that's the problem: you've misspelled the property name. I mention this because the UsersCell class has a genID property, or possibly that's the GolfersCell class, which may or may not have an inheritance relationship with the UsersCell class.

    It's difficult to tell what's going on because you haven't shown any @interfaces for any of your classes. Without seeing types, no one knows what objects you're really talking about. It's like saying your pet is sick, but without saying whether it's a bird, a fish, a dog, or an iguana.
     
  3. thread starter macrumors newbie

    Joined:
    Oct 22, 2011
    #3
    thanks, I am thinking this is due to lack of sleep.
     
  4. macrumors 603

    Joined:
    Aug 9, 2009
    #4
    There should have been a compiler warning at the misspelled line. If you're ignoring warnings, you're doing it wrong, especially if you're also tired.
     

Share This Page