首页 [iPhone和iPad开发书籍大全].Objective.C.Visual.QuickSta…

[iPhone和iPad开发书籍大全].Objective.C.Visual.QuickStart.Guide(Peachpit.Press.2010-02).pdf

[iPhone和iPad开发书籍大全].Objective.C…

上传者: lkgroidwdfwg 2011-03-18 评分1 评论0 下载43 收藏0 阅读量434 暂无简介 简介 举报

简介:本文档为《[iPhone和iPad开发书籍大全].Objective.C.Visual.QuickStart.Guide(Peachpit.Press.2010-02)pdf》,可适用于手机软件领域,主题内容包含ptgFromtheLibraryofWow!eBookptgVISUALQUICKStArtGUIDEobjectivecStevenHolzne符等。

ptgFromtheLibraryofWow!eBookptgVISUALQUICKStArtGUIDEobjectivecStevenHolznerPeachpitPressFromtheLibraryofWow!eBookptgVisualQuickStartGuideObjectiveCStevenHolznerPeachpitPressEighthStreetBerkeley,CA(fax)FindusontheWebatwwwpeachpitcomToreporterrors,pleasesendanotetoerratapeachpitcomPeachpitPressisadivisionofPearsonEducationCopyrightbyStevenHolznerEditor:JudyZiajkaProductionCoordinator:MyrnaVladicCompositor:DebRobertiProofreader:WendySharpIndexer:FireCrystalCommunicationsCoverDesign:PeachpitPressNoticeofrightsAllrightsreservedNopartofthisbookmaybereproducedortransmittedinanyformbyanymeans,electronic,mechanical,photocopying,recording,orotherwise,withoutthepriorwrittenpermissionofthepublisherForinformationongettingpermissionforreprintsandexcerpts,contactpermissionspeachpitcomNoticeofLiabilityTheinformationinthisbookisdistributedonan“AsIs”basis,withoutwarrantyWhileeveryprecautionhasbeentakeninthepreparationofthebook,neithertheauthornorPeachpitPressshallhaveanyliabilitytoanypersonorentitywithrespecttoanylossordamagecausedorallegedtobecauseddirectlyorindirectlybytheinstructionscontainedinthisbookorbythecomputersoftwareandhardwareproductsdescribedinittrademarksVisualQuickStartGuideisaregisteredtrademarkofPeachpitPress,adivisionofPearsonEducationAnyotherproductnamesusedinthisbookmaybetrademarksoftheirownrespectiveownersManyofthedesignationsusedbymanufacturersandsellerstodistinguishtheirproductsareclaimedastrademarksWherethosedesignationsappearinthisbook,andPeachpitwasawareofatrademarkclaim,thedesignationsappearasrequestedbytheownerofthetrademarkAllotherproductnamesandservicesidentifiedthroughoutthisbookareusedineditorialfashiononlyandforthebenefitofsuchcompanieswithnointentionofinfringementofthetrademarkNosuchuse,ortheuseofanytradename,isintendedtoconveyendorsementorotheraffiliationwiththisbookISBN:ISBN:PrintedandboundintheUnitedStatesofAmericaFromtheLibraryofWow!eBookptgDedicationToNancy,ofcourse!AcknowledgmentsThebookyouholdinyourhandsistheproductofmanypeople’sworkIwouldparticularlyliketothankWendySharpandJudyZiajkafortheirtirelesseffortstomakethisbookthebestitcanbeandDannyKalevforhiscarefultechnicalreviewoftheentiremanuscriptFromtheLibraryofWow!eBookptgivTableofContentsIntroductionviiiChapter:GettingStarted:EssentialObjectiveCCreatingYourFirstProgramCompilingandRunningYourFirstProgramUsingVariablesDisplayingValuesinVariablesWorkingwithDataTypesAddingCommentsUsingArithmeticOperatorsUsingAssignmentOperatorsUsingtheIncrementandDecrementOperatorsChangingTypewithCastOperatorsChapter:DirectingProgramFlowUsingtheifStatementUsingtheelseStatementUsingtheswitchStatementUsingComparisonOperatorsUsingLogicalOperatorsUsingtheConditionalOperatorUsingtheforLoopUsingthewhileLoopUsingthedowhileLoopUsingthebreakStatementChapter:HandlingDataAboutCreatingNSClassObjectsCreatingArraysInitializingArraysLoopingoverArraysCreatingTwoDimensionalArraysUsingPointersUsingPointerMathInterchangingPointersandArraysUsingStringsPassingMessagestoStringObjectsUsingEnumerationsTableofContentsFromtheLibraryofWow!eBookptgvTableofContentsTableofContentsChapter:CreatingFunctionsDefiningaFunctionDeclaringFunctionsUsingPrototypesPassingArgumentstoFunctionsReturningValuesfromFunctionsUsingFunctionScopePassingPointerstoFunctionsPassingArraystoFunctionsPassingConstantDatatoFunctionsUsingRecursionUsingPointerstoFunctionsChapter:ClassesandObjectsCreatingObjectiveCClassesandObjectsUsingClassMethodsCreatinganObjectCreatingObjectMethodsStoringDatainObjectsPassingMultipleArgumentstoMethodsStoringtheInterfaceinaHeaderFileAddingtheImplementationtotheHeaderFileLinkingMultipleFilesUsingConstructorsChapter:ObjectOrientedProgrammingAboutAccessSpecifiersUsingPublicAccessUsingPrivateAccessUsingProtectedAccessUsingClassVariablesAccessingtheCurrentObjectCreatingaVariableforMultipleObjectTypesVerifyingThatanObjectBelongstoaClassCheckinganObject'sClasswithisKindOfClassVerifyingThatanObjectSupportsaMethodCheckingWhetherObjectsSupportaMethodChapter:WorkingwithObjectOrientedInheritanceInheritingfromaClassInheritingBaseClassDataMembersInheritingBaseClassMethodsOverridingBaseClassMethodsOverloadingBaseClassMethodsFromtheLibraryofWow!eBookptgviTableofContentsTableofContentsUsingMultilevelInheritanceLimitingAccessRestrictingAccessUsingConstructorswithInheritanceUsingPolymorphismChapter:Categories,Posing,andProtocolsAboutCategoriesCategories:CreatingtheBaseClassCategories:CreatingCategoriesCategories:PuttingItAllTogetherAboutPosingPosing:CreatingtheBaseClassPosing:CreatingtheDerivedClassPosing:PuttingItAllTogetherAboutProtocolsProtocols:DefiningtheProtocolandInterfacesProtocols:CreatingtheClassImplementationsProtocols:PuttingItAllTogetherChapter:UsingArraysandDictionariesCreatinganArrayAccessingArrayElementsUsingEnumerationtoLoopoveranArrayCreatingaMutableArrayAddingElementstoaMutableArraySortinganArrayReleasingArrayMemoryCreatingaDictionaryEnumeratingaDictionaryCreatingaMutableDictionaryAddingObjectstoaMutableDictionaryChapter:ManagingMemoryinObjectiveCCreatingTestObjectsDisplayingtheRetainCountIncrementinganObject’sRetainCountDecrementinganObject’sRetainCountDeallocatingObjectsfromMemoryUsinganAutoreleasePoolUsingSelfManagedMemoryDeallocatingMemoryYourself:CreatingtheClassFromtheLibraryofWow!eBookptgviiTableofContentsTableofContentsviiDeallocatingMemoryYourself:StoringInternalObjectsDeallocatingMemoryYourself:CreatingthemainMethodDeallocatingMemoryYourself:PerformingDeallocationChapter:ExceptionHandlingCatchingExceptionsHandlingExceptionsUsingtheEndHandlerCreatinganExceptionCheckingWhatExceptionOccurredHandlingMultipleExceptionsPassingExceptionsUptheCallStackReturningValuesfromExceptionHandlersReturningvoidfromanExceptionHandlerCatchingUncaughtExceptionsIndexFromtheLibraryofWow!eBookptgviiiIntroductioniWelcometoObjectiveCThisbookisyourguidedtourofthisexcitinglanguage,anditgivesyouwhatyouneedtostartworkingwithObjectiveCatonceUsingObjectiveC,youcanwriteprofessionalprogramsthatmakeuseofmanyobjectorientedfeaturesfromthebasicsuptoadvancedclassinheritanceandexception(runtimeerror)handlingObjectiveCrunsonmanydifferentplatformsForthemostpart,yourcodeshouldworkunchangedonallplatformsthatObjectiveCsupports,butwheredifferencesinsupportexist,thisbookpointsthemouttoyouThisbookstartswiththebasicsandcontinuesonthroughadvancedtopicsYou’llbeginbylookingathowtogetObjectiveCstartedandhowtorunbasicprogramsFromthere,you’llexploredatahandling,againstartingwiththebasicsandmovingonthroughadvancedtopicsAfterlookingathowtowriteyourownfunctions,you’llwrapfunctionsanddatatogetherintoobjectsthecoreofObjectiveCprogrammingAndwhenyoustartworkingwithobjectorientedprogramming,thelidisoffandwe’llpushtheenvelopeasfarasitcangoIntroductionThat’stheplan,then:topresentaguidedtourofObjectiveC,takingyoufromthebeginningtothemostadvancedtopicsLet’sgetstartedwithChapternowFromtheLibraryofWow!eBookptgGettingStarted:EssentialObjectiveCThisbooktakesyouonaguidedtourofObjectiveC,fromthebasicsonupthroughthecoolstuffObjectiveCisacrossplatformlanguage,soyou’llfinditonmanysystems:theMac,ofcourse,butalsoLinux,UNIX,Windows,andmoreanditscoreprogrammingcodestaysthesameacrossallthoseplatformsObjectiveCisactuallyalayerbuiltontopoftheClanguage,andeverythingthatworksinstandard(thatis,ANSI)CworksinObjectiveCObjectiveCalsoaddstonsofobjectorientedfeaturestotheoriginalClanguageThewayitusesobjectsiswhatmakesObjectiveCsopopular,butjustwhatisanobjectObjectorientedprogrammingwasintroducedwhenprogramsbegantogetverylargeandthestructureofthecodebegantogetinthewayObjectorientedprogrammingletsprogrammerswrapwholesectionsoftheircodeintoeasilyhandled,selfcontainedobjectsandsoletthembreakuptheircodecontinuesonnextpageGettingStarted:EssentialObjectiveCFromtheLibraryofWow!eBookptgChapterGettingStarted:EssentialObjectiveCForexample,sayyouhaveabowlofpuddingthatyouwanttokeepcoldYoucouldsetupasystemofcoolantpipes,switches,anddialsthatcoolyourpuddingbutwhichtakeyourconstantattention:youhavetowatchthetemperature,andwhenthepuddinggetstoowarm,youhavetoturnonthecoolantcompressorandpumpandsoonwhenthepuddinggetscoldenough,youhaveswitchthosethingsoffThatwastheoldwayofprogramming,withthegutsofeveryiteminyourprogramlaidbaretothewholerestoftheprogramObjectorientedprogramming,bycontrast,letsyouwrapallthatfunctionalityintoasingleobject:arefrigeratorTherefrigerator’sjobistokeepthingslikepuddingcoldwithoutalotoffussonyourpartItisresponsibleformaintainingitsowninternalstatethatis,remainingcoldinsideIthasthermostatsandrelaysandtheliketoautomaticallyhandlethejobsyoupreviouslydidmanuallySoifyouwantyourpuddingkeptcold,simplyputitintherefrigeratorAllthedetailsarehiddenfromview,andyourkitchenbecomesamucheasierplacetohandleconceptuallySoitiswithobjectorientedprogrammingNowyoucanwrapcodeanddatatogetherintoobjectsthatareselfcontained,andbecauseallthedetailsarehidden,yourinteractionwiththoseobjectsbecomesalotsimplerThat’sthesecretbehindobjectorientedprogramming:divideandconquerInthisbook,you’llseewhatmakestheobjectsinObjectiveCtickThey’redifferentthantheobjectsinotherlanguagestheycommunicatewithmessagesyoudon’tcallthecodeinthemdirectlybutthey’rejustaspowerful,andoftenmoresoWe’llstartinthischapterwiththebasics:handlingbasicdataitems,printingresultsfromObjectiveCprograms,runningyourprograms,andmoreFromtheLibraryofWow!eBookptgGettingStarted:EssentialObjectiveCCreatingYourFirstProgramCreatingYourFirstProgramWe’regoingtojumprightintoObjectiveCbycreatingandrunningaprogram,whichwe’llnamefirstmWe’llstartbycreatingafunctionthatis,abitofcodethatyoucancallbynamenamedmain( ):int main(void){                        }Functionscanbepasseddata,asyou’llseelater,butthisfunctionisn’tpassedanydata,whichiswhyweusethekeywordvoidintheparenthesesFunctionscanalsoreturnvalues,andthemain( )functionreturnsanintegervaluetoObjectiveCindicatingwhethertheprogramsucceededTheintinfrontofmain( )tellsObjectiveCtoexpectanintegerreturnvalueThecodeforthemain( )functiongoesinsidecurlybraces:{and}Next,we’llusethebuiltinObjectiveCfunctionnamedprintf( )todisplaysometextWepassthetextwewantprintf( )todisplayinsideparentheses:int main(void){printf(“WelcometoObjectiveC!”)                        }continuesonnextpagetipTheextensionforObjectiveCcodefilesismFromtheLibraryofWow!eBookptgChapterCreatingYourFirstProgramTousetheprintf( )function,wehavetotellObjectiveCaboutthatfunctionwithafunctiondeclaration,asyou’llseewhenwediscusshowtocreatefunctionsThedeclarationsforthestandardIOfunctionslikeprintf( )arecontainedinanObjectiveCfilenamedstdioh,wherehstandsfor“headerfile”weincludestdiohinourprogramasshownheresoObjectiveCknowsabouttheprintf( )function:#include<stdioh>int main(void){  printf (“Welcome to ObjectiveC!”)                        }Whentheprogramends,ObjectiveCwillexpectsomeindicationofwhetherthefunctionsucceededWe’llreturnavalueoftoObjectiveC,whichmeanstherewerenoerrorsListingshowstheentireprogram,whichyouwillcreatestepbystepinthefollowingtaskstipNotethat#importand#includearethesameforourpurposesYoucanusetheminterchangeablyandinanyorder#include <stdioh>int main(void){  printf (“Welcome to ObjectiveC!”)return}ListingYourfirstObjectiveCprogramFromtheLibraryofWow!eBookptgGettingStarted:EssentialObjectiveCCreatingYourFirstProgramtocreateyourfirstObjectiveCprogramontheMac:Fromhttp:developerapplecomiphone,downloadandinstalltheXcodeIntegratedDevelopmentEnvironmentRunXcodeChooseFile>NewProjectIntheNewProjectwindow,chooseApplicationClicktheCommandLineToolicontoselectitFromtheTypedropdownmenu,chooseFoundationClicktheChoosebuttonEnterFirstasthenameofyourapplicationSelectasavelocatio

职业精品

打卡考勤管理制度(附各式详细申请表).doc

员工考勤与值班管理制度(全网最详细制度).doc

指纹打卡考勤细则.doc

办公设备、办公用品管理制度.doc

用户评论

0/200
    暂无评论
上传我的资料

精彩专题

相关资料换一换

资料评价:

/ 240
所需积分:1 立即下载

意见
反馈

返回
顶部