-1

I'm trying to do a UITableView, but I'm totally stuck. My problem is I'm trying to do the method -tableView:cellForRowAtIndexPath: and for filling the cells I have a NSArray of myObject, which is set by another class via a setter in my UITableViewController.

My problem is that when I'm going to use that array, it is totally empty, and I don't know why -- when I do the setter, the object has data, but when I try to do the getter inside the method above, it is empty. Can someone tell me why, and how can I fix it?

My setter:

- (void)setmyObjectList:(NSArray *)list{          
      _myObjectList = list;
}

MyObjectList is declared in the .h:

@property (nonatomic, strong) NSArray *myObjectList;

And this code is in the Controller that call my TableViewController via a segue:

myTableViewController *myTVC = segue.destinationViewController;
[myTVC setPharmaciesList:self.list];

Maybe I didn't explain well: I have a class that has a NSArray with the the objects I want to show in my TableView. So via a segue I set this NSArray in the TableViewController. In the setter when I do a NSLog all the data is in the NSArray in the property of the NSTableViewController, but when I try to access in the method tableView:cellForRowAtIndexPath: the info is empty. Why? I have no idea.

Thanks

5
  • Post the setter method, and the code where you call the setter.
    – edc1591
    Commented Mar 29, 2012 at 16:43
  • Stacky i m a bit confused buddy. i dont really understand what u are trying to do.. For basic it is always handy to NSLog the NSArray to see what is really inside the Array. but first can u please enlighten me more Thanks :) Commented Mar 29, 2012 at 17:14
  • For one thing, the "m" in setmyObjectList should be capitalized.
    – rdelmar
    Commented Mar 29, 2012 at 17:18
  • I'm gonna tried to explain :) I have a class that has a NSArray with the the objects I wanna show in my TableView. So via a segue I set this NSArray in the TableViewController. In the setter when I do a NSLog all the data is in the NSArray in the property of the NSTableViewController, but when I try to access in the method tableView:cellForRowAtIndexPath: the info is empty. Why? I have no idea. Thanks :P
    – Stacky
    Commented Mar 29, 2012 at 17:21
  • Ok, guys, I fixed it. It was cuz the properties of the objects that my NSArray contains, were weak. So i lost the pointer to the data. Thanks for your interest and help :)
    – Stacky
    Commented Mar 29, 2012 at 18:12

1 Answer 1

0

First, don't override the setter method since youre not doing anything special there. Second, where do you create the array that you later set your property to by calling [myTVC setPharmaciesList:self.list];

I.e. where do you populate self.list?

1
  • I fixed it. It was cuz i declared weak the properties of the object inside the NSArray. Beginner's mistake!!! :) Thanks for your help
    – Stacky
    Commented Mar 29, 2012 at 21:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.