Hi Guys

Can I just suggest something more?

> @interface Controller : NSObject {
>    IBOutlet UIButton *beginButton;
>    IBOutlet UIButton *endButton;
>    IBOutlet UILabel *nameLabel;
>    IBOutlet UILabel *numberLabel;
>    MyModel *myModel;
> }
> 
> @property (nonatomic, retain) IBOutlet MyModel *myModel;
> 
> /* some methods defined here as well */
> @end


From what I have read, and from good object-oriented practice, it would be 
better to use Objective-C 2.0 properties for all your outlets. iVars really 
should be @private, if you are using them, but don't forget that properties 
will synthesize, not only the accessors, but the ivars as well.
@interface Controller : NSObject
{
}

@property IBOutlet UIButton *beginButton;

@property IBOutlet UIButton *endButton;

@property IBOutlet UILabel *nameLabel;

@property IBOutlet UILabel *numberLabel;


@property MyModel *myModel;

/* some methods defined here as well */

@end

@implementation Controller

@synthesize beginButton;

@synthesize endButton;

@synthesize nameLabel;

@synthesize numberLabel;

@synthesize myModel;

@end

Any outlets for controls (top level objects) in the Nib should be released in 
the dealloc method only for OS X apps but not for iPhone apps. Setting the 
properties to nil will ensure that the synthesized setter will be called, which 
releases the previous contents of the synthesized ivar before setting it to nil.

- (void) dealloc
{
  beginButton = nil;

  endButton = nil;

  nameLabel = nil;

  numberLabel = nil;

  myModel = nil;

  [super dealloc];
}

Joanna

--
Joanna Carter
Carter Consulting

_______________________________________________

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to