The following two examples are from the 20 Jan 2009 Cocoa-dev Digest. The first example is from the iPhone Dev SDK book. The second is a different approach that the author (mmalc) says is better. Who is right? And why?
Message: 13
Date: Tue, 20 Jan 2009 18:50:48 -0800
From: mmalc Crawford <mmalc_lists@me.com>
Subject: Re: Accessing interface elements (iPhone vs Mac)
To: Ashley Perrien <perrien@earthlink.net>
Cc:
cocoa-dev@lists.apple.com
Message-ID: <C7B58E0F-CB42-477A-A790-30BF7F462709@me.com>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
On Jan 20, 2009, at 12:41 PM, Ashley Perrien wrote:
... (Ashley Perrien writes) ...
In iPhone examples many or all of them have:
@interface myViewController : UIViewController
{
*****IBOutlet UILabel *myLabel;
}
@property (retain, nonatomic) UILabel *myLabel;
and then @synthesize myLabel in the implementation. I've even seen *
where the dealloc method will then release the object.
... (mmalc replies)...
This should actually be
@interface MyViewController : UIViewController
{
****UILabel *myLabel;
}
@property (retain, nonatomic) IBOutlet UILabel *myLabel;
The advantage of this approach is that it makes the memory management *
semantics explicit and clear, and it works consistently across all *
platforms for all nib files.
<http://stackoverflow.com/questions/61838>
<
Resource Programming Guide: Loading Nib Files Programmatically