资源描述:
《IOS程序开发语言教程--Objective-C.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、WriteObjective-CCodeIfyou’renewtoprogrammingforiOSorMacOSX,youneedtobecomeacquaintedwiththeprimaryprogramminglanguage,Objective-C.Objective-Cisanotadifficultlanguage,andonceyouspendsometimewithityou’llappreciateitselegance.TheObjective-Clanguageenablessophistica
2、tedobject-orientedprogramming.ItextendsthestandardANSICprogramminglanguagebyprovidingsyntaxfordefiningclassesandmethods.Italsopromotesdynamicextensionofclassesandinterfacesthatanyclasscanadopt.IfyouarefamiliarwithANSIC,thefollowinginformationshouldhelpyoulearnth
3、ebasicsyntaxofObjective-C.Andifyouhaveprogrammedwithotherobject-orientedlanguages,you’llfindthatmanyofthetraditionalobject-orientedconcepts,suchasencapsulation,inheritance,andpolymorphism,areallpresentinObjective-C.IfyouarenotfamiliarwithANSIC,westronglyencourag
4、eyoutoatleastreadanoverviewoftheClanguagebeforeyouattempttoreadthisarticle.TheObjective-Clanguageisfullyexplainedin TheObjective-CProgrammingLanguage.AboutObjective-CTheObjective-Clanguagespecifiesasyntaxfordefiningclassesandmethods,aswellasotherconstructsthatpr
5、omotedynamicextensionofclassesandadaptiveinterfaces.ASupersetofCAsasupersetoftheCprogramminglanguage,Objective-CsupportsthesamebasicsyntaxasC.Yougetallofthefamiliarthings,suchasprimitivetypes(int, float,andsoon),structures,functions,pointers,andcontrol-flowconst
6、ructssuchas if...else andfor statements.YoualsohaveaccesstothestandardClibraryroutines,suchasthosedeclaredin stdlib.h and stdio.h.Objective-CaddsthefollowingfeaturestoANSIC:·Syntacticalconventionsfordefiningnewclasses·Conventionsforclassandinstancemethods·Syntax
7、formethodinvocation(calledmessaging)·Syntaxfordeclaringpropertiesandsynthesizingaccessormethodsfromthem·Conventionsforstaticanddynamictyping·Blocks—encapsulatedsegmentsofcodethatcanbeexecutedatanytime·ExtensionstothebaselanguagesuchasprotocolsandcategoriesDon’tw
8、orryiftheseaspectsofObjective-Careunfamiliartoyounow.Asyouprogressthroughtheremainderofthisarticle,youwilllearnaboutthem.Ifyou’reaproceduralprogrammernewtoobject-orie