iphone - @synthesize IBOutlet property -



iphone - @synthesize IBOutlet property -

i'm objective-c newbie , i'm reading "iphone programming" alasdair allan. while reading, found code:

@interface rootcontroller : uiviewcontroller <uitableviewdatasource, uitableviewdelegate> { uitableview *tableview; nsmutablearray *cities; } // warning: remember tableview @property (nonatomic, retain) iboutlet uitableview *tableview;

the relative implementation starts way:

@implementation rootcontroller @synthesize tableview;

now: learnt @synthesize sort of shortcut avoid boring getters , setters.

but i've question:

in code of implementation tableview is never explicitly called dealloc releases it; if never gets called explicitly why @synthesize?

is mandatory iboutlets synthesized?

from memory management of nib objects,

when nib file loaded , outlets established, nib-loading mechanism uses accessor methods if nowadays (on both mac os x , ios). therefore, whichever platform develop for, should typically declare outlets using objective-c declared properties feature.

for ios, should use:

@property (nonatomic, retain) iboutlet uiuserinterfaceelementclass *anoutlet;

you should either synthesize corresponding accessor methods, or implement them according declaration, , (in ios) release corresponding variable in dealloc.

iphone objective-c ios

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -