This code works everywhere else

Discussion in 'iOS Programming' started by zachsilvey, Jan 4, 2011.

  1. zachsilvey macrumors 6502

    Joined:
    Feb 5, 2008
    Location:
    Battle Ground
    #1
    This line
    Code:
    NSLog(@"%@", arrayOfNewsItems);
    will work in every method of my UITableViewController except
    Code:
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    The array is a synthesized property so it should be accessible anywhere in the class but when I use that line inside of the that method the app crashes without throwing an exception in the console.
     
  2. ulbador macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #2
    What does the rest of the method look like? Can you do just a regular "NSLog(@"I am here");" and have it work in there?
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    The NSLog you've posted is not using a synthesized property. It's using a variable named 'arrayOfNewsItems'. I can't tell you if it's a local variable or an instance variable or even a global variable without seeing more code. But it's definitely not a property.

    You can tell it's not a property because this is what a property reference looks like:
    Code:
    NSLog(@"%@", [COLOR="Red"]self.[/COLOR]arrayOfNewsItems);
    If you don't have the name of the object whose property it is, followed by a dot, then that arrayOfNewsItems is not a property.

    And no one here is a mind-reader. If you expect someone to help you with the code in the method, then you have to post the code of that method.
     
  5. zachsilvey thread starter macrumors 6502

    Joined:
    Feb 5, 2008
    Location:
    Battle Ground
    #5
    Yes that will work.


    Where would I find that, nothing shows up in the console.
     

Share This Page