Re: Adding Rows to a Table View
Re: Adding Rows to a Table View
- Subject: Re: Adding Rows to a Table View
- From: Dave <email@hidden>
- Date: Thu, 1 Apr 2010 18:36:44 +0100
On 1 Apr 2010, at 16:17, Matt Neuburg wrote:
On or about 4/1/10 4:38 AM, thus spake "Dave"
<email@hidden>:
The way I have my project setup is that I have a View Controller that
contains a button and a TableView field.
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.
the App is first launched, the system calls
"numberOfSectionsInTableView" and "tableView:numberOfRowsInSection:"
with the Table View from the NIB file.
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?
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?
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!
All the Best
Dave
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden