I have a UITableView whose controller looks like this:
@interface FLWorkspaceViewController : UITableViewController
@property(nonatomic,retain) NSMutableArray* workspaces;
@end
I try to set that array in another controller:
for(NSDictionary* workspace in workspaces)
{
NSLog(@"%@",workspace);
[workspaceViewController.workspaces addObject:workspace];
}
[self.navigationController pushViewController:workspaceViewController animated:YES];
I’ve checked the values and they exist. When I count workspaces in viewDidLoad, it’s 0. Why is this?
@propertystatements create the pointers for you, but not the actual content. Since I don’t see it in your code: Do youalloc inityourNSMutableArray *workspacessomewhere?EDIT: Probably the best way to initialise your
workspacesarray would be in a getter method in the class where you define the@property. Lazy initialisation is preferrable. Best amend your@synthesizestatement to read something like@synthesize workspaces = i_workspaces;, then you can write your getter like this:The capacity statement just helps the compiler optimise, it doesn’t have to be exact.