版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、畢業(yè)設(shè)計(jì)外文資料翻譯學(xué) 院: 專(zhuān) 業(yè): 姓 名: 學(xué) 號(hào): 外文出處: BEGINNING iOS GAME DEVELOPMENT 附 件:1.外文資料翻譯譯文; 2.外文原文 指導(dǎo)教師評(píng)語(yǔ):該生的外文翻譯與本次的設(shè)計(jì)研究?jī)?nèi)容有一定的關(guān)聯(lián)性,翻譯文章通順,語(yǔ)法正確,工作量也達(dá)到了要求的內(nèi)容。 翻譯工作能夠嚴(yán)格按照規(guī)定,達(dá)到考核、提高學(xué)生英語(yǔ)應(yīng)用水平的目的,圓滿(mǎn)完成要求。簽名: 2015年10月14日1外文資料翻譯譯文objective - c編程語(yǔ)言 objective C是C語(yǔ)言的超集,一切你可以在C語(yǔ)言中,你也可以做在objective - C中。objective - C的大多數(shù)特性增
2、加了C程序使您能夠構(gòu)建利用面向?qū)ο?OO)的編程技術(shù)。在最后一章中,您了解到C是struc -約束編程語(yǔ)言。結(jié)構(gòu)化語(yǔ)言運(yùn)行以自頂向下的方式,鼓勵(lì)按部就班,基于函數(shù)的方法來(lái)解決問(wèn)題。 另一方面,面向?qū)ο蟮恼Z(yǔ)言鼓勵(lì)更抽象的方法,是你將在本章中學(xué)習(xí)到的。在objective - c等面向?qū)ο蟮恼Z(yǔ)言,你的軟件作為一個(gè)群體的對(duì)象模型。而不是寫(xiě)功s能做一個(gè)特定的操作,你將你的程序邏輯封裝到這些對(duì)象。對(duì)象的功能,或方法,操作對(duì)象中包含的數(shù)據(jù)。對(duì)象也可以包含自己的數(shù)據(jù)。通常,您將模型中的對(duì)象程序基于現(xiàn)實(shí)世界的對(duì)象。這可以使面向?qū)ο蟮某绦蚋菀桌斫?。面向?qū)ο蟮某绦蛞部梢愿菀渍{(diào)試和修改,因?yàn)槟惴庋b所有相關(guān)的功能
3、和數(shù)據(jù)對(duì)象在對(duì)象本身。類(lèi)和對(duì)象 功能面向?qū)ο蟪绦虻幕締挝皇菍?duì)象。當(dāng)你的程序運(yùn)行時(shí),可能有數(shù)百個(gè),也許成千上百萬(wàn)的對(duì)象活躍在任何給定的時(shí)間。你在項(xiàng)目中創(chuàng)建的所有對(duì)象都是來(lái)自于類(lèi)。 類(lèi)是創(chuàng)建對(duì)象的藍(lán)圖。就像一個(gè)構(gòu)建器使用一個(gè)藍(lán)圖來(lái)創(chuàng)建房屋,您使用類(lèi)來(lái)創(chuàng)建對(duì)象。每個(gè)房子都可能有不同的顏色,但是每個(gè)遵循相同的藍(lán)色打印。在圖4 - 1中,您可以看到藍(lán)圖一所房子,那所房子的三個(gè)實(shí)例:一個(gè)紅色,一個(gè)綠色,一個(gè)黃色。構(gòu)建器使每個(gè)房子的藍(lán)圖,但改變了顏色。你能想到的顏色作為房子的一個(gè)屬性。每個(gè)房子都有一個(gè)顏色,但是你可以設(shè)置顏色為每個(gè)實(shí)例為單獨(dú)的房子。圖4 - 1:建造房屋的藍(lán)圖 在你的代碼中,您定義的類(lèi)表示
4、的對(duì)象,將使用您的程序。然后,當(dāng)您需要使用一個(gè)對(duì)象,您將創(chuàng)建您的類(lèi)的一個(gè)實(shí)例。類(lèi)的實(shí)例,您已經(jīng)創(chuàng)建了被稱(chēng)為一個(gè)對(duì)象。一旦您創(chuàng)建了一個(gè)對(duì)象,它是獨(dú)立的,除了相同的類(lèi)型,它不與任何其他對(duì)象創(chuàng)建的類(lèi)?;氐郊依镱?lèi)比,每個(gè)房子都是一樣的類(lèi)型,但是您可以獨(dú)立改變?nèi)魏畏孔拥念伾挥绊懫渌姆孔?。你可以?chuàng)建一個(gè)房子類(lèi)代表房子在您的代碼中。模型說(shuō)明在圖4 - 1中,眾議院類(lèi)成員變量會(huì)有顏色。然后,你可以創(chuàng)建你想要盡可能多的房子的實(shí)例,每個(gè)都有自己的顏色。改變一個(gè)房子對(duì)象的顏色沒(méi)有影響您創(chuàng)建的其他房子。實(shí)例變量 成員或?qū)嵗兞烤S護(hù)對(duì)象的當(dāng)前狀態(tài)或條件。您在成員變量的值獨(dú)立地存儲(chǔ)在每一個(gè)類(lèi)的實(shí)例。正如您將看到的,
5、每一個(gè)類(lèi)型的對(duì)象創(chuàng)建的房子會(huì)有自己獨(dú)特的值存儲(chǔ)在實(shí)例變量的顏色。您可以訪問(wèn)類(lèi)的成員變量來(lái)實(shí)現(xiàn)。 實(shí)例變量有不同的范圍,這取決于你如何定義他們。這三個(gè)范圍值,您將使用最常private,protected, public。私有實(shí)例變量只提供給他們聲明的類(lèi)。保護(hù)可用變量是類(lèi)的聲明和任何子類(lèi)。你會(huì)了解更多關(guān)于子類(lèi)在本章后面。公共變量可用于任何代碼。默認(rèn)情況下,實(shí)例變量都有受保護(hù)的范圍。 你可以看到這個(gè)如圖4 - 2所示。圖中描繪了一個(gè)成立這個(gè)在不同課程中聲明的變量范圍的水平。一個(gè)私有變量的可見(jiàn)性,以綠色顯示,成立這個(gè)。課程只可見(jiàn)保護(hù)范圍,見(jiàn)黃色,表明變量成立這個(gè)和任何課程都可用這個(gè)。課程類(lèi)繼承自最后
6、,公眾范圍所示粉紅色。任何代碼可以訪問(wèn)公共實(shí)例變量。 面向?qū)ο蟪绦虻囊粋€(gè)優(yōu)點(diǎn)是封裝。封裝的概念是你可以包含所有功能的類(lèi)的類(lèi)本身沒(méi)有暴露的內(nèi)部細(xì)節(jié)用戶(hù)類(lèi)。這樣,類(lèi)看起來(lái)像一個(gè)黑盒,外面的世界。你們班的用戶(hù)應(yīng)該不需要知道他們也不應(yīng)該關(guān)心如何實(shí)現(xiàn)類(lèi)。你可以隱藏你的類(lèi)和實(shí)現(xiàn)的內(nèi)部細(xì)節(jié)封裝使用私有或受保護(hù)的成員變量。這樣,您的類(lèi)的用戶(hù)不能直接訪問(wèn)類(lèi)的成員。所有訪問(wèn)應(yīng)該通過(guò)消息或?qū)傩?。你?huì)了解更多關(guān)于屬性在本章后面。通過(guò)使用這種方法,您可以控制用戶(hù)如何獲取數(shù)據(jù)從您的類(lèi),而不是用戶(hù)直接內(nèi)部數(shù)據(jù)。圖4 - 2:成員變量范圍內(nèi)存管理 與垃圾收集語(yǔ)言不同,像Java和c#,objective - C不提供垃圾收集
7、在iOS平臺(tái)上。因此,當(dāng)你為創(chuàng)建的對(duì)象分配內(nèi)存,你負(fù)責(zé)釋放內(nèi)存,當(dāng)你完成它。如果不能正確地分配釋放內(nèi)存,您的應(yīng)用程序所消耗的內(nèi)存的總量將增長(zhǎng)作為應(yīng)用程序運(yùn)行。這未能清理未使用的內(nèi)存導(dǎo)致內(nèi)存泄漏。最后,如果您的程序使用太多內(nèi)存,操作系統(tǒng)將終止您的應(yīng)用程序。 這似乎困難和復(fù)雜,但只要你有在objective - c中內(nèi)存管理的工作方式的理解和記住一些簡(jiǎn)單的規(guī)則,你就會(huì)好起來(lái)的。在iOS 5,蘋(píng)果公司推出了一種新的語(yǔ)言特性稱(chēng)為自動(dòng)引用計(jì)數(shù)的objective - c,ARC。ARC簡(jiǎn)化了引用計(jì)數(shù)通過(guò)消除大部分為開(kāi)發(fā)加工工作,它仍然是重要的有一個(gè)基本的了解引用計(jì)數(shù)在objective - c中工作。在
8、下一節(jié)中您將了解更多關(guān)于ARC。 所有繼承NSObject objective - c類(lèi)保持保留計(jì)數(shù)。保留計(jì)數(shù)是一個(gè)計(jì)數(shù)器,顯示的代碼的比特?cái)?shù)感興趣的對(duì)象。當(dāng)一個(gè)對(duì)象分配利用alloc或新,其保留數(shù)設(shè)置為1。在圖4 - 3中,你的對(duì)象由藍(lán)色方塊表示,保留計(jì)數(shù)在粉紅色的圓。當(dāng)你用完對(duì)象后,你應(yīng)該調(diào)用釋放的方法。調(diào)用對(duì)象的釋放減少保留計(jì)數(shù)。保留計(jì)數(shù)為0時(shí),對(duì)象被回收和objective - c運(yùn)行時(shí)調(diào)用它的dealloc方法。你可以看到如圖4 3(a)所示。灰色的方塊代表了回收對(duì)象。 除了釋放,你可以調(diào)用生成方法。這表明,運(yùn)行時(shí)應(yīng)釋放對(duì)象在將來(lái)的一個(gè)點(diǎn),但不是馬上。有效地,這減少了保留數(shù)1就像調(diào)用
9、釋放。你可以看到如圖4 - 3(b)所示。ss 生成自動(dòng)釋放池來(lái)跟蹤所有生成對(duì)象。生成自動(dòng)有釋放池,大多數(shù)項(xiàng)目模板創(chuàng)建時(shí)自動(dòng)開(kāi)始構(gòu)建您的應(yīng)用程序。你可以自己創(chuàng)建本地池。您將看到autorelease池在動(dòng)作游戲中例子在這一章的結(jié)束。 對(duì)于從方法返回對(duì)象Autorelease尤其有用。你可以分配的對(duì)象你計(jì)劃返回的方法,生成自動(dòng)配置它,然后它返回給調(diào)用者。是調(diào)用者的責(zé)任保留對(duì)象。objective - c運(yùn)行時(shí)將發(fā)送一個(gè)生成對(duì)象釋放消息一次每次調(diào)用autorelease時(shí)autorelease池排水或回收。 當(dāng)你需要堅(jiān)持引用一個(gè)對(duì)象,就像一個(gè)生成對(duì)象,你從一個(gè)方法調(diào)用回來(lái),你增加保留數(shù)通過(guò)調(diào)用保留
10、對(duì)象上的方法。圖4 - 3(c)演示了這種情況。有責(zé)任的一個(gè)方法的調(diào)用者返回一個(gè)對(duì)象叫保留。默認(rèn)釋放池將取消生成對(duì)象通過(guò)應(yīng)用程序的運(yùn)行循環(huán)時(shí)間。所以,如果你得到一個(gè)生成對(duì)象從一個(gè)函數(shù),使用它,你不需要它方法調(diào)用完成后,您不需要擔(dān)心保留它。然而,如果你打算把一個(gè)生成對(duì)象實(shí)例變量的訪問(wèn)在稍后的時(shí)間,你必須打電話給保留它,否則它將回收的循環(huán)運(yùn)行,當(dāng)你試圖回收對(duì)象發(fā)送一條消息時(shí)應(yīng)用程序會(huì)崩潰。 你應(yīng)該盡量使用生成自動(dòng)釋放,而不是在調(diào)用釋放較少的開(kāi)銷(xiāo)。如果你要?jiǎng)?chuàng)建和生成許多對(duì)象,在一個(gè)循環(huán)中,或許你應(yīng)該生成自動(dòng)包裝的循環(huán)池。這可以通過(guò)創(chuàng)建NSAutoreleasePool的實(shí)例對(duì)象在你開(kāi)始循環(huán)時(shí)。然后,
11、你通過(guò)autorelease池釋放它:NSAutoreleasePool *pool = NSAutoreleasePool alloc init; loop a bunch of times pool release; 要記住的關(guān)鍵一點(diǎn)是內(nèi)存管理在objective - c中,你需要平衡調(diào)用新的alloc,或保留與調(diào)用發(fā)布或生成。如果你有太少的呼吁釋放/生成,保留計(jì)數(shù)的對(duì)象永遠(yuǎn)不會(huì)下降到0,對(duì)象不會(huì)銷(xiāo)毀,導(dǎo)致內(nèi)存泄漏。如果你調(diào)用生成自動(dòng)釋放或太多次,你會(huì)over-release對(duì)象,導(dǎo)致應(yīng)用程序崩潰。 一般來(lái)說(shuō),將一個(gè)對(duì)象添加到可可收集NSMutableArray等增量保留計(jì)數(shù)。同樣,刪除一
12、個(gè)對(duì)象從一個(gè)集合的精神性保留計(jì)數(shù)。僅僅獲得一個(gè)對(duì)象的集合通常返回一個(gè)生成對(duì)象。如果你需要持有一個(gè)生成對(duì)象的引用,您需要調(diào)用保留。你將學(xué)習(xí)更多關(guān)于使用Cocoa在下一章集合類(lèi)。 當(dāng)你創(chuàng)建一個(gè)對(duì)象通過(guò)調(diào)用一個(gè)類(lèi)alloc助手方法,新的、或復(fù)制它的名字,它是你的責(zé)任來(lái)釋放該對(duì)象。以這種方式創(chuàng)建的對(duì)象,按照慣例,保留計(jì)數(shù)為1。如果你得到一個(gè)對(duì)象使用一個(gè)類(lèi)的實(shí)例幫助器方法,它返回一個(gè)對(duì)象,沒(méi)有alloc,新的,在它的名字如stringWithString或復(fù)制,你應(yīng)該假設(shè)對(duì)象生成。 retainCount消息可以發(fā)送到任何NSObject獲取當(dāng)前保留計(jì)數(shù)的對(duì)象。你通常不會(huì)使用這種方法在生產(chǎn)應(yīng)用程序,但它
13、可以幫助日志對(duì)象的保留計(jì)數(shù)當(dāng)你試圖調(diào)試內(nèi)存問(wèn)題??偨Y(jié):如果你創(chuàng)建一個(gè)對(duì)象使用,新的、或復(fù)制,對(duì)象將保留數(shù)1,你負(fù)責(zé)調(diào)用釋放。如果你得到一個(gè)對(duì)象的引用在任何其他方式,你可以假設(shè)它有一個(gè)保留數(shù)1和已經(jīng)生成。如果你需要堅(jiān)持的引用對(duì)象,保留它。如果你打電話給保留一個(gè)對(duì)象,你必須平衡叫保留與釋放的電話。在內(nèi)存管理的更多信息,我建議閱讀蘋(píng)果的內(nèi)存管理編程指南自動(dòng)引用計(jì)數(shù) 正如我在前一節(jié)中提到的,蘋(píng)果iOS 5引入了自動(dòng)引用計(jì)數(shù)或ARC。ARC簡(jiǎn)化了引用計(jì)數(shù)通過(guò)編譯器插入自動(dòng)保留并發(fā)布到您的代碼。通過(guò)分析代碼和編譯器,這在編譯時(shí)確定對(duì)象的生命周期。 ARC的影響在你作為一個(gè)開(kāi)發(fā)者,你不需要擔(dān)心打字保留,釋放
14、,或在您的代碼生成。編譯器會(huì)插入正確的內(nèi)存管理,編制報(bào)表給你。你不需要擔(dān)心你的對(duì)象的生命周期,因?yàn)榫幾g器會(huì)為你照顧它。事實(shí)上,生成自動(dòng)調(diào)用保留,釋放,或?qū)?dǎo)致編譯器錯(cuò)誤如果你有ARC為項(xiàng)目啟用。 Xcode使ARC默認(rèn)為所有新項(xiàng)目在4.2版開(kāi)始。你可以關(guān)掉ARC與基礎(chǔ)上如果你決定你想要完全控制內(nèi)存管理。在這種情況下,您將需要恢復(fù)到使用保留和釋放我之前解釋道。這個(gè)特性允許您在您的新項(xiàng)目中使用ARC時(shí)保持兼容現(xiàn)有的庫(kù)沒(méi)有ARC啟用。 因?yàn)閄code使ARC默認(rèn)為新項(xiàng)目,我將在本書(shū)中使用它。然而,你需要知道,如果你禁用ARC,您將需要使用保留自己管理內(nèi)存和釋放。2.外文原文The Objective
15、-C Programming Language Objective-C is a superset of C. Everything that you can do in C, you can also do in Objective-C. The majority of features that Objective-C adds to C enable you to build your programs by using object-oriented (OO) programming techniques. In the last chapter, you learned that C
16、 is a struc- tured programming language. Structured languages run in a top down manner and encourage a step-by-step, function-based approach to solving problems. On the other hand, object-oriented languages encourage a more abstract approach, as youwill learn in this chapter. In an object-oriented l
17、anguage like Objective-C, you model your software as a group of objects. Instead of writing functions that do a particular operation, you encapsulate your program logic into these objects. The objects have functions, or methods, that operate on the data contained in the objects. The objects can also
18、 contain their own data. Often, you will model the objects in your programs based on real-world objects. This can make object-oriented programs easier to understand. Object-oriented programs can also be easier to debug and modify because you encapsulate all of the functionality and data related to a
19、n object in the object itself. CLASSES AND OBJECTS The basic unit of functionality in an object-oriented program is the object. When your program runs, there may be hundreds, thousands, or perhaps millions of objects active at any given time. You create all of the objects in your program from classe
20、s. A class is the blueprint for creating objects. Just as a builder uses a blueprint to create houses, you use classes to create objects. Each house may have a different color, but each follows the same blue- print. In Figure 4-1, you can see the blueprint for a house and three instances of that hou
21、se: one red, one green, and one yellow. The builder made each house from the same blueprint, but changed the color. You can think of color as a property of a house. Each house has a color, but you can set the color for each instance of a house individually. FIGURE 4-1: Building houses from a bluepri
22、ntIn your code, you define classes that represent the kinds of objects that you will use in your program. Then, when you need to use an object, you create an instance of your class. The instance of the class that you have created is called an object. Once you have created an object, it stands alone
23、in that, aside from being of the same type, it is not associated with any other objects that you have created from the class. To go back to the house analogy, each house is the same type, but you can independently change the color of any house without affecting any other house. You could create a Ho
24、use class to represent houses in your code. To model the illustration in Figure 4-1, the House class would have a color member variable. Then, you could create as many instances of the House as you want, each with its own color. Changing the color of one house object has no effect on any other house
25、s that you created. Instance Variables Member or instance variables maintain the state or current condition of your objects. The values that you place in member variables are stored independently for each instance of a class. As you will see, each object of type House that you create will have its o
26、wn unique value stored in the color instance variable. You can access the member variables of your class in the implementation. Instance variables have a different scope depending on how you define them. The three scope values that you will use most often are private, protected, and public. Private
27、instance variables are available only to the class in which they are declared. Protected variables are available to the class in which they are declared and any subclasses. You will learn more about subclasses later in this chapter. Public variables are available from any code. By default, instance
28、variables have protected scope. You can see this illustrated in Figure 4-2. The diagram depicts a variable declared in theClass at the various scope levels. The visibility of a private variable, shown in green, is only visible to theClass. Protected scope, illustrated in yellow, shows that the varia
29、ble is available to both theClass and any class that inherits from theClass. Finally, public scope is shown in pink. Any code can access public instance variables. One advantage of an object-oriented program isencapsulation. The concept of encapsulation is that youcan contain all of the functionalit
30、y of a class in the classitself without exposing the inner details to users ofthe class. That way, the class looks like a black box to theoutside world. Users of your class should not need to know nor should they care about how you implemented the class. You can hide the internal details of your cla
31、ss and achieve encapsulation by using private or protected member variables. That way, users of your class cannot access a classs members directly. All access should be through messages or properties. You will learn more about properties later in this chapter. By using this methodology, you can cont
32、rol how users get data from your class as opposed to users going directly to the internal data. FIGURE 4-2: Member variable scopeManaging Memory Unlike garbage-collected languages like Java and C#, Objective-C does not offer garbage collection on the iOS platform. Therefore, when you allocate memory
33、 for an object that you create, you are responsible for releasing that memory when you are finished with it. If you fail to properly free the memory that you allocate, the total amount of memory consumed by your application will grow as the application runs. This failure to clean up unused memory re
34、sults in a memory leak. Eventually, if your program consumes too much memory, the OS will terminate your application. This may seem difficult and complicated, but as long as you have an understanding of how memory management works in Objective-C and remember a few simple rules, you will be fine. In
35、iOS 5, Apple has introduced a new language feature to Objective-C called Automatic Reference Counting, or ARC. While ARC simplifies reference counting by eliminating most of the work for the devel- oper, it is still important for you to have a basic understanding of how reference counting works in O
36、bjective-C. You will learn more about ARC in the next section. All Objective-C classes that inherit from NSObject maintain a retain count. The retain count is a counter that indicates the number of bits of code that are interested in the object. When an object is allocated by using alloc or new, its
37、 retain count is set to 1. In Figure 4-3, your object is represented by the blue cube, and the retain count is in the pink circle. When you are finished using the object, you should call the release method. Calling release reduces the retain count of the object by one. When the retain count reaches
38、zero, the object is de-allocated and the Objective-C runtime calls its dealloc method. You can see this illustrated in Figure 4-3 (a). The gray cube represents the de-allocated object. In addition to release, you can call the autorelease method. This indicates that the runtime should release the obj
39、ect at a point in the future, but not right away. Effectively, this reduces the retain count by 1 just like calling release. You can see this illustrated in Figure 4-3 (b). FIGURE 4-3: Memory managementYou use autorelease pools to keep track of all autoreleased objects. There is an application-wide
40、autorelease pool that most project templates create automatically when you begin building your application. You can create local pools yourself as well. You will see the autorelease pool in action in the game example at the end of this chapter. Autorelease is particularly useful for returning object
41、s from methods. You can allocate the object that you plan to return from the method, configure it, and then autorelease it before returning it to the caller. It is the callers responsibility to retain the object. The Objective-C runtime will send an autoreleased object the release message one time f
42、or every time you call autorelease on it when the autorelease pool is drained or de-allocated. When you need to hold on to a reference to an object, like an autoreleased object that you got back from a method call, you increment the retain count by calling the retain method on the object. Figure 4-3
43、 (c) illustrates this situation. It is the responsibility of the caller of a method that returns an object to call retain. The default autorelease pool will de-allocate autoreleased objects eachtime through the applications run loop. So, if you get an autoreleased object from a function, use it righ
44、t away, and you do not need it after the method call is complete, you do not need to worry about retaining it. However, if you plan to put an autoreleased object into an instance variable for access at a later time, you have to call retain on it or else it will be de-allocated at the end of the run
45、loop and your application will crash when you try to send a message to the de-allocated object. You should use release instead of autorelease whenever possible as there is less overhead in calling release. If you are going to be creating and autoreleasing many objects, in a loop perhaps, you should
46、wrap the loop in its own autorelease pool. You do this by creating an instance of the NSAutoreleasePool object before you start looping. Then, you drain the autorelease pool by releasing it: NSAutoreleasePool *pool = NSAutoreleasePool alloc init; loop a bunch of times pool release; The key thing to
47、remember about memory management in Objective-C is that you need to balance calls to new, alloc, or retain with calls to release or autorelease. If you have too few calls to release/autorelease, the retain count for the object will never drop to 0 and the object will never be de-allocated, resulting
48、 in a memory leak. If you call release or autorelease too many times, you will over-release the object, causing an application crash. In general, adding an object to a Cocoa collection such as NSMutableArray, increments the retain count. Likewise, removing an object from a collection decrements the
49、retain count. Simply obtaining an object from a collection typically returns an autoreleased object. If you need to hold on to the reference to an autoreleased object, you need to call retain on it. You will learn more about working with Cocoa collection classes in the next chapter. When you create
50、an object by calling a class helper method that has alloc, new, or copy in its name, it is your responsibility to release that object. Objects created in this way, by convention, have a retain count of 1. If you get an instance of an object using a class helper method that returns an object that doe
51、s not have alloc, new, or copy in its name such as stringWithString, you should assume that the object is autoreleased. You can send the retainCount message to any NSObject to obtain the current retain count of that object. You generally will not use this method in a production application, but it c
52、an be helpful to log the retain count of an object when you are trying to debug memory problems. To summarize: If you create an object with alloc, new, or copy, the object will have a retain count of 1 and you are responsible for calling release. f you get a reference to an object in any other way, you can assume that it has a retain count of 1 and has
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年甘肅會(huì)展中心有限責(zé)任公司招聘筆試參考題庫(kù)含答案解析
- 2025版智慧城市運(yùn)營(yíng)項(xiàng)目融資協(xié)議合同范本3篇
- 2025年度個(gè)人小戶(hù)型房產(chǎn)買(mǎi)賣(mài)及裝修改造合同4篇
- 2025年個(gè)人森林撫育與更新承包合同4篇
- 2025年全球及中國(guó)醫(yī)用協(xié)作機(jī)器人行業(yè)頭部企業(yè)市場(chǎng)占有率及排名調(diào)研報(bào)告
- 2025-2030全球鄰氯苯腈(氯化法)行業(yè)調(diào)研及趨勢(shì)分析報(bào)告
- 2025-2030全球觸控?zé)粜袠I(yè)調(diào)研及趨勢(shì)分析報(bào)告
- 2025版拖拉機(jī)銷(xiāo)售與保險(xiǎn)服務(wù)合同范本6篇
- 2025年度房產(chǎn)租賃合同(含租金調(diào)整及違約責(zé)任)3篇
- 2025年度個(gè)人設(shè)備租賃貸款合同范本7篇
- 2024年全國(guó)職業(yè)院校技能大賽高職組(研學(xué)旅行賽項(xiàng))考試題庫(kù)(含答案)
- 2025年溫州市城發(fā)集團(tuán)招聘筆試參考題庫(kù)含答案解析
- 2025年中小學(xué)春節(jié)安全教育主題班會(huì)課件
- 2025版高考物理復(fù)習(xí)知識(shí)清單
- 除數(shù)是兩位數(shù)的除法練習(xí)題(84道)
- 2025年度安全檢查計(jì)劃
- 2024年度工作總結(jié)與計(jì)劃標(biāo)準(zhǔn)版本(2篇)
- 全球半導(dǎo)體測(cè)試探針行業(yè)市場(chǎng)研究報(bào)告2024
- 反走私課件完整版本
- 2024年注冊(cè)計(jì)量師-一級(jí)注冊(cè)計(jì)量師考試近5年真題附答案
- 四年級(jí)下冊(cè)數(shù)學(xué)知識(shí)點(diǎn)總結(jié)
評(píng)論
0/150
提交評(píng)論