site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com On 1 Apr 2010, at 16:17, Matt Neuburg wrote: The way I have my project setup is that I have a View Controller that contains a button and a TableView field. the App is first launched, the system calls "numberOfSectionsInTableView" and "tableView:numberOfRowsInSection:" with the Table View from the NIB file. So, my question is, what is the correct way to setup "mFactTableView" from the NIB file? Or is this the wrong way to go about this? All the Best Dave _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/site_archiver%40lists.apple... On or about 4/1/10 4:38 AM, thus spake "Dave" <dave@looktowindward.com>: No, you do not. I've spoken to you about this before (in your thread "How to instantiate a table view in existing view", about two weeks ago). As I said then, "A view controller is not interface so it can't contain a button." Perhaps what you have is a superview (A) that contains a button (B) and a UITableView (C), where the superview (A) is controlled by a view controller. If that's the case, that's what you should say. Ahhh, I see your distinction, yes it's as you state. This suggests that you must at some point have wired the table view's "data source" outlet to your view controller. That's good. It is not clear from your description above how the view controller is represented in the nib - is it the file's owner? The same as any ivar whose value is to be a nib-instantiated object: mFactTableView needs to be an outlet from the view controller, which you wire to the table view. Make sure you do appropriate memory management on this ivar. The usual thing is to make it a property using retain (and you must then of course synthesize its accessors, and explicitly release it in your dealloc). When the nib is loaded, the ivar will be set (because of the outlet) using retain (because of the property). m. Thanks a lot, that's the step that was missing, I just needed to connect File's Owner to "mFactTableView" in Interface Builder, I'd wired up the Delegate and the Outlet ok and I'd defined "mFactTableView" as an IBOutlet in XCode. But had missed the final step. Thanks again! This email sent to site_archiver@lists.apple.com
participants (1)
-
Dave