Xcode “Use of undeclared identifier”

I know many people ask this but all the answers are specific apps so I don’t understand how to work it for my app.

        tableData = [NSArray arrayWithObjects:@"Chocolate Brownie", @"Mushroom Risotto", nil];
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section
    {
        return [tableData count];
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *simpleTableIdentifier = @"SimpleTableItem";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
        }

        cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
        return cell;` 
    }

  • How to distribute ios application wirelessly without managing UDIDs and recompilation
  • fatal error: init(coder:) has not been implemented error despite being implemented
  • Check if UIColor is dark or bright?
  • How to send text from text field to another view controller
  • Getting status “REQUEST_DENIED” after fetching data from google places API
  • open file from local file system with default application iOS
  • 3 Solutions Collect From Internet About “Xcode “Use of undeclared identifier””

    the reason being ut tableData variable is not retained and you have assigned it via factory method with is already autoreleased.

    in .h file, make it retain property and use this variable with self. in ur code.

    @property(nonatomic,retain) NSArray *tableData;
    

    in .m,

    @synthesize tableData;
    

    then use it like:

    self.tableData = [NSArray arrayWithObjects:@"Chocolate Brownie", @"Mushroom Risotto",      nil];
    

    now you wont get any error as tableData is now retained.

    do not forget to release it in dealloc if you are not using ARC.

    You have to declare your NSArray as a property and synthetize it.
    In your class definition:

    @property (retain, nonatomic) NSArray *tableData;
    

    And in the implementation:

    @synthetize tableData = _tableData;
    

    Alright then, this is a simple fix. You are receiving the error on every line that references “tableData” because it is undeclared. In other words, your app was never told what “tableData” is.

    You can declare “tableData” in your .h file, it should look something like this…

    @interface yourClassName : UITableViewController 
    {
        NSArray *tableData;
    }
    

    EDIT: Go with @grasGendarme’s answer if you will only be calling for this array from within this function, if you wish to use it across the controller use this answer.

    EDIT 2: In regards to your updated question, check for this on the line thats giving you the error.

    enter image description here

    This blue arrow indicates that you have set a break point in your code on this line. You can right click the error and select delete breakpoint.