欢迎来到天天文库
浏览记录
ID:41551029
大小:103.23 KB
页数:4页
时间:2019-08-27
《objective-c属性_计算机软件及应用_IT计算机_专业资料》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、@property与@synthesize配对使用1、@property和@synthesize都是0bjective-c关键字。2、@property和@synthesize使用都是配对使用的。3、在@property:声明用于自动创建property属性变量的getter和setter.在@Synthesize:声明实现了property属性变量的getter和setter.4、@property声明放在.h头文件屮。在interface:@property[(attributel,attribute2,attribute3)]dataType
2、(数据类型)variableName(变量名)@Synthesize声明放在.m实现文件中在implementation:@synthesizevariableName例子:创建Attribute工程添力「IGetterAndSetter类内容如图:4、Attribute@MyMac已压Q00壬O目hGetterAndSetter.hL・、mGetterAndSetter.m▼ler.Attrlbuteu2targets,OSXSOK10.9▼MAttribute▼TGetterAndSetterhAppDelogate.hmAppDelegate
3、.m印Images.xcassetsMainMenu.xib>i_SupportingFiles►AttributeTests>ProductsFinishedrunningAttribute:AttnbuteAAttribute国MyMacAnishedrunningAttributeAttribute已脇Qaeiiio㊂
4、<倉Attribute_A.>TG.GetterAndSetter,mNoSelection
5、6、Q)CounterpartshGetterAndSetter.hNoSelection7、-f6Attribute2ta8、rgets.OSXSOK10.9▼(IAttribute▼GetterAndSetterGetterAndSetter.mAttributeGetterAndSetter.hAttributeCreatedby拾TMI寂奠的烟on16ZCopyright(c)2016年AS.Al^^ightsreserved.9.hAppDelegate.h#importMGetterAndSetteCreatedby泊tMi妄莫的烟onCopyright(c)2016年AS・4/8/29.rightsreserved・■import9、ndj10、rion.h>mAppDelegate.m三lmages.xcassetsMainMenu.xib►二SupportingFiles>LAttrlbuteTests>I_Products10n1213!<•IS//^synthesizea;//©synthesizeb;rAndSetter6^AppDelegate类中的代码如下:jA,Attribute目MyMacFinishedrunningAttribute:Attributegg11、<回Attribute>口AttritxitehAppDelegateh>NoSelection丨12、6Attribute2targets.OSXSOK10.9▼rBAttribute▼13、L_GotterAndSctterhGetterAndSetter.hhAppOelegato.hr^AppOelegatani■Imags.xcasseUMainMenu.xib►LSupportingFiles►AnributoTosts►■Products7、101!1Z^interfaceGetterAndSet14、bute////Createdby抽f寂宾的烟on16/8/29.//Copyright(c)2"6年AS・Allrightsreserved.#import◎SportMGetterAndSetter.hM超interfaceAppDelegate:NSObject}arf-(IBAction)ClickInit:(id)sender;-(I8Action)ClickSetter:(id)serKier;-(IBAction)ClickCettcr:(id)sender;15、NoSelectionon16/8/29.AllrightsfuiportMAppOele^dte-h"(weak)电pr
6、Q)CounterpartshGetterAndSetter.hNoSelection
7、-f6Attribute2ta
8、rgets.OSXSOK10.9▼(IAttribute▼GetterAndSetterGetterAndSetter.mAttributeGetterAndSetter.hAttributeCreatedby拾TMI寂奠的烟on16ZCopyright(c)2016年AS.Al^^ightsreserved.9.hAppDelegate.h#importMGetterAndSetteCreatedby泊tMi妄莫的烟onCopyright(c)2016年AS・4/8/29.rightsreserved・■import9、ndj10、rion.h>mAppDelegate.m三lmages.xcassetsMainMenu.xib►二SupportingFiles>LAttrlbuteTests>I_Products10n1213!<•IS//^synthesizea;//©synthesizeb;rAndSetter6^AppDelegate类中的代码如下:jA,Attribute目MyMacFinishedrunningAttribute:Attributegg11、<回Attribute>口AttritxitehAppDelegateh>NoSelection丨12、6Attribute2targets.OSXSOK10.9▼rBAttribute▼13、L_GotterAndSctterhGetterAndSetter.hhAppOelegato.hr^AppOelegatani■Imags.xcasseUMainMenu.xib►LSupportingFiles►AnributoTosts►■Products7、101!1Z^interfaceGetterAndSet14、bute////Createdby抽f寂宾的烟on16/8/29.//Copyright(c)2"6年AS・Allrightsreserved.#import◎SportMGetterAndSetter.hM超interfaceAppDelegate:NSObject}arf-(IBAction)ClickInit:(id)sender;-(I8Action)ClickSetter:(id)serKier;-(IBAction)ClickCettcr:(id)sender;15、NoSelectionon16/8/29.AllrightsfuiportMAppOele^dte-h"(weak)电pr
9、ndj
10、rion.h>mAppDelegate.m三lmages.xcassetsMainMenu.xib►二SupportingFiles>LAttrlbuteTests>I_Products10n1213!<•IS//^synthesizea;//©synthesizeb;rAndSetter6^AppDelegate类中的代码如下:jA,Attribute目MyMacFinishedrunningAttribute:Attributegg
11、<回Attribute>口AttritxitehAppDelegateh>NoSelection丨
12、6Attribute2targets.OSXSOK10.9▼rBAttribute▼
13、L_GotterAndSctterhGetterAndSetter.hhAppOelegato.hr^AppOelegatani■Imags.xcasseUMainMenu.xib►LSupportingFiles►AnributoTosts►■Products7、101!1Z^interfaceGetterAndSet14、bute////Createdby抽f寂宾的烟on16/8/29.//Copyright(c)2"6年AS・Allrightsreserved.#import◎SportMGetterAndSetter.hM超interfaceAppDelegate:NSObject}arf-(IBAction)ClickInit:(id)sender;-(I8Action)ClickSetter:(id)serKier;-(IBAction)ClickCettcr:(id)sender;15、NoSelectionon16/8/29.AllrightsfuiportMAppOele^dte-h"(weak)电pr
14、bute////Createdby抽f寂宾的烟on16/8/29.//Copyright(c)2"6年AS・Allrightsreserved.#import◎SportMGetterAndSetter.hM超interfaceAppDelegate:NSObject}arf-(IBAction)ClickInit:(id)sender;-(I8Action)ClickSetter:(id)serKier;-(IBAction)ClickCettcr:(id)sender;
15、NoSelectionon16/8/29.AllrightsfuiportMAppOele^dte-h"(weak)电pr
此文档下载收益归作者所有