OC知識點

來源:互聯網
上載者:User

標籤:

1.@autoreleasepool  

     why1

2.retain

        O-C記憶體管理和點文法
1>OC記憶體管理正常情況要使用大量的retain和relrese操作
2>點文法可以減少使用retain和release的操作 

3.Runloop

[email protected](retain)編譯器如何申明

編譯器對於@property中的retain展開是不一樣的
主要是要釋放上一次的值,增加本次計數器
在dog.h中聲明的:
@property(retain)Dog *dog;
展開後為:
-(void) setDog:(Dog *)aDog;
-(Dog *)dog;

[email protected]編譯器如何?展開

在dog.m中實現:
@synthesize dog=_dog;
展開後為:
-(void) setDog:(Dog *)aDog{
if(_dog!=aDog){
[_dog release];
_dog=[aDog retain];
}
}
-(Dog *)dog{
return _dog;
}

6.dealloc需要注意內容

dealloc必須要釋放dog(retain)
在dog.m中
-(void) dealloc
{
self.dog=nil;
[super dealloc];
}

7.copy屬性的主要作用

copy屬性是完全把對象重新拷貝了一份,計數器從新設定為1,和之前拷貝的資料完全脫離關係。
@property(copy) NSString* str;
//表示屬性的getter函數
-(double) str
{
return str;
}
//表示屬性的setter函數
-(void) setStr:(NSString *)newStr
{
str=[newStr copy];
}

8.assign,retain,copy

1、foo=value;//簡單的引用賦值
2、foo=[value retain];//引用賦值,並且增加value的計數器
3、foo=[value copy];//將value複製了一份給foo,複製後,foo和value就毫無關係

9.Foundation架構

(學習Objective-C必備知識)

10.IOS開發中需要注意的一些問題11.Xcode6-beta3版本建立項目中沒有foundation

12.切圖常說的@[email protected]@3X是什麼意思?

OC知識點

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.