Two basic questions regarding UITableViewController and ObjC-2.0
Two basic questions regarding UITableViewController and ObjC-2.0
- Subject: Two basic questions regarding UITableViewController and ObjC-2.0
- From: Stefan Wolfrum <email@hidden>
- Date: Wed, 18 Jun 2008 11:27:23 +0200
Hi all,
I hope this is the correct mailing list for iPhone OS questions, too?
If not, please redirect me to a more appropriate forum/list.
I'm currently learning some basic Cocoa touch stuff and my first app
is to be a very simple table view with a detail view for each row.
I'm studying the code samples "SimpleDrillDown", "TheElements" and
"SimpleTableView" (from the TableViewSuite) and came across a few
questions:
(1) In the demo projects like "SimpleDrillDown", "TheElements",
"SimpleTableView" (from the TableViewSuite) the array that holds the
strings/titles of the table view's rows is implemented as a member in
the AppDelegate class -- not in the subclassed TableViewController
class. Why? The "View Controller Programming Guide", Version from
2008-06-09, says (on page 43) that the data source for the table view
IS the UITableViewController class and in the code snippets I see a
member "anArrayOfStrings" of the view controller class. So, where
should I put my data source for the table view rows' titles?
(2) Have a look at the SimpleDrillDown example code. The file
SimpleDrillDownAppDelegate.h defines a member "NSMutableArray *list"
in the @interface section.
After this section there's a @property directive that declares the
member "list" as readonly:
@property (nonatomic, copy, readonly) NSArray *list;
Now take a look at the implementation file
SimpleDrillDownAppDelegate.m. Unusual, there's another @interface
section and now the "list" member is declared as readwrite:
@property (nonatomic, copy, readwrite) NSArray *list;
What's the reason behind this? And why is the member a NSMutableArray
while in the @property statement it's a NSArray?
Also, I understood that the @synthesize directive actually creates the
accessor methods (setter & getter) for members. Right? There is a
corresponding line for the "list" member in the .m file:
@synthesize list;
But, additionally, there's another implementation of the setter method
for the "list" member later in this file (which is, btw, not declared
in the .h file):
- (void)setList:(NSArray *)newList {
if (list != newList) {
[list release];
list = [newList mutableCopy];
}
}
Why this?
Thanks a lot for your help in advance!! :-)
Stefan.
_______________________________________________
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