The Objective-C Programming Language

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

@package●●●●●●●●●●●●●●●●●●@interface()@interface-(void)encodeWithCoder:(NSCoder*)coder{[superencodeWithCoder:coder];...}●●ididanObject;idintintnilid0idnilobjc/objc.hidtypedefstructobjc_object{Classisa;}*id;isaClasstypedefstructobjc_class*Class;isaisaididisaisaisa●●[receivermessage]myRectangledisplay[myRectangledisplay];;:[myRectanglesetWidth:20.0];myRectangle[myRectanglesetOriginX:30.0y:50.0];//Thisisagoodexampleof//multipleparameterssetOriginX:y:deffunc(a,b,NeatMode=SuperNeat,Thing=DefaultThing):passThingNeatModeRectanglesetOrigin::[myRectanglesetOrigin:30.0:50.0];//ThisisabadexampleofmultipleparameterssetOrigin::makeGroup:group[receivermakeGroup:group,memberOne,memberTwo,memberThree];isFilledYESmyRectangleNOBOOLisFilled;isFilled=[myRectangleisFilled];[myRectanglesetPrimaryColor:[otherRectprimaryColor]];.nilnil●nil0nilPerson*motherInLaw=[[aPersonspouse]mother];spousenilmothernilnil●sizeof(void*)floatdoublelongdoublelonglongnil0●structnil0.0structstruct●nilnilidanObjectMaybeNil=nil;//thisisvalidif([anObjectMaybeNilmethodThatReturnsADouble]==0.0){//implementationcontinues...}nilnilvoidsizeof(void*)nilnilnilstructnilsizeof(void*)primaryColorotherRectprimaryColorisFilleddisplayCircleRectangledisplayiddisplaycopycopyRectanglecopy.[]myInstance.value=10;printf(myInstancevalue:%d,myInstance.value);[myInstancesetValue:10];printf(myInstancevalue:%d,[myInstancevalue]);selfself.age=10;[selfsetAge:10];self.ageage=10;Graphic*graphic=[[Graphicalloc]init];NSColor*color=graphic.color;CGFloatxLoc=graphic.xLoc;BOOLhidden=graphic.hidden;inttextCharacterLength=graphic.text.length;if(graphic.textHidden!=YES){graphic.text=@Hello;//@HelloisaconstantNSStringobject.}graphic.bounds=NSMakeRect(10.0,10.0,20.0,120.0);Graphic*graphic=[[Graphicalloc]init];NSColor*color=[graphiccolor];CGFloatxLoc=[graphicxLoc];BOOLhidden=[graphichidden];inttextCharacterLength=[[graphictext]length];if([graphicisTextHidden]!=YES){[graphicsetText:@Hello];}[graphicsetBounds:NSMakeRect(10.0,10.0,20.0,120.0)];NSMutableDataNSMutableData*data=[NSMutableDatadataWithLength:1024];data.length+=1024;data.length*=2;data.length/=4;[datasetLength:[datalength]+1024];[datasetLength:[datalength]*2];[datasetLength:[datalength]/4];nilnil//Eachmemberofthepathisanobject.x=person.address.street.name;x=[[[personaddress]street]name];//ThepathcontainsaCstruct.//Thiswillcrashifwindowisnilor-contentViewreturnsnil.y=window.contentView.bounds.origin.y;y=[[windowcontentView]bounds].origin.y;//Anexampleofusingasetter.person.address.street.name=@OxfordRoad;[[[personaddress]street]setName:@OxfordRoad];●aPropertyaVariableaVariable=anObject.aProperty;aPropertyaVariable●setName:anObject@NewNameanObject.name=@NewName;setName:namesetName:void●boundsaViewxOriginorigin.xNSRectboundsxOrigin=aView.bounds.origin.x;●11integerPropertyanObjectfloatPropertyanotherObjectNSIntegeri=10;anObject.integerProperty=anotherObject.floatProperty=++i;setIntegerProperty:setFloatProperty:●warning:valuereturnedfrompropertynotused.anObject.retain;●setFooIfYouCan:(void)/*Methoddeclaration.*/-(BOOL)setFooIfYouCan:(MyClass*)newFoo;/*Codefragment.*/anObject.fooIfYouCan=myInstance;●lockFocusIfCanDrawflagflagflag=aView.lockFocusIfCanDraw;●readonlyPropertyreadonlywarning:assignmenttoreadonlyproperty'readonlyProperty'/*Propertydeclaration.*/@property(readonly)NSIntegerreadonlyProperty;/*Methoddeclaration.*/-(void)setReadonlyProperty:(NSInteger)newValue;/*Codefragment.*/self.readonlyProperty=5;readwriteNSMatrixNSWindowNSDictionaryNSFontNSTextNSArrayNSWindowRectanglemyRectangleNSObjectImageTextNSObjectGraphicShapeLineCircleRectangleSquareSquareRectangleRectangleShapeShapeGraphicGraphicNSObjectSquareRectangleShapeGraphicNSObjectSquareSquareNSObjectNSObjectSquareNSObjectNSObjectNSObjectNSObjectNSObjectNSObjectisaNSObjectisaRectangleClassNSPointNSColorPattern...floatfloatBOOLNSColor...declaredinShapedeclaredinRectangledeclaredinNSObjectdeclaredinGraphicisa;origin;*primaryColor;linePattern;width;height;filled;*fillColor;SquareSquareRectangleShapeGraphicNSObjectGraphicdisplayRectangledisplayGraphicGraphicRectangleRectangledisplayNSObjectNSObjectNSViewsizeofinti=sizeof(Rectangle);idRectangle*myRectangle;idididRectangleGraphicRectangleGraphicGraphic*myRectangle;RectangleGraphicShapeRectangleGraphicmyRectangleGraphicmyRectangleRectangleisMemberOfClass:NSObjectif([anObjectisMemberOfClass:someClass])...isKindOfClass:NSObjectif([anObjectisKindOfClass:someClass])...isKindOfClass:YESisKindOfClass:isMemberOfClass:●●●●RectangleNSObjectintversionNumber=[Rectangleversion];idclassidaClass=[anObjectclass];idrectClass=[Rectangleclass];idClassClassaClass=[anObjectclass];ClassrectClass=[Rectangleclass];ClassRectanglemyRectangleidmyRectangle;myRectangle=[Rectanglealloc];alloc0isainitmyRectangle=[[Rectanglealloc]init];myRectangleallocinitallocinitinitWithPosition:size:RectangleinitNSMatrixNSCellNSMatrixNSMatrixNSCellNSCellNSObjectNSCellNSActionCellNSTextFieldCellNSSliderCellNSButtonCellNSFormCellNSMenuCellNSBrowserCellNSCellNSButtonCellNSTextFieldCellN

1 / 116
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功