ios 常見錯誤整理 持續更新

來源:互聯網
上載者:User

標籤:des   style   blog   http   io   os   使用   java   ar   

本文轉載至 http://blog.csdn.net/yesjava/article/details/8086185 1. mutating method sent to immutable object‘

從字面上理解:可變的訊息發給了不可變的對象。比如NSDictionary類型的對象調用setValue方法.應該把NSDictionary 改成NSMutableDictionary類型。

 

2.Local declaration of ‘content‘ hides instance variable

 

一般是函數裡面定義的變數和class屬性變數重名了。很少有和系統變數重名的情況。

 

3.unrecognized selector sent to instance 

大部分情況下是因為對象被提前release了,在不希望他release的情況下,指標還在,對象已經不在了。

很多時候,是因為init初始化函數中,對屬性賦值沒有使用self.foo賦值,而是直接對foo賦值,導致屬性對象沒有retain(心裡以為retain了),而提前釋放。

4.使用ASIHTTPRequest編譯不通過

原因是一些類庫沒有加進去。把這些庫加進去CFNetwork, SystemConfiguration, MobileCoreServices, and libz.dylib

5.添加在UIView中的UIButton   單擊不起作用

原因是UIbutton的frame超出了UIView的frame範圍。事實上UIView並沒有設定frame,設定完後( 範圍一定要在UIButton之外),UIButton單擊就可以了

6.當使用presentViewController和dismissPresentViewController時,如果報這個錯 : while  presentation is in progress ,修改方法為[mainView dismissModalViewControllerAnimated:NO];  將參數Animated改為NO;如果報這個錯while a presentation or dismiss is in progress,試試這樣

 if (![[mainView modalViewController] isBeingDismissed]) {
        [mainView dismissModalViewControllerAnimated:NO];
    }
7.調用系統相簿的時候,非常容易出現記憶體警告,加入紅色代碼就會好點:

 
        UIImagePickerController * picker = [[UIImagePickerController alloc]init];
        picker.delegate = self;
        picker.allowsEditing = NO;  //是否可編輯
        picker.videoQuality=UIImagePickerControllerQualityTypeLow;
        //網路攝影機
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [self presentModalViewController:picker animated:YES];
        [picker release];


8.ios開發人員都遇見過得錯誤:EXC_BAD_ACCESS 。這個和第二個比較類似。通常的調試方法就是加入NSZombieEnabled變數,加入方法自行百度。

並且開發過程中使用

 [[NSNotificationCenterdefaultCenter]

來發布本地訊息,這個也經常會出現EXC_BAD_ACCESS錯誤。這個時候只需要在你的view活著viewControllers的dealloc的方法裡面加入

[[NSNotificationCenterdefaultCenter]removeObserver:selfname:@"yourNotification"object:nil];就ok了


9.遇見一個蛋疼的問題"linker command failed with exit code 1 (use -v to see invocation)" 。翻遍了找不到原因。然後還有這樣的警告

duplicate symbol _OBJC_CLASS 。原來是在匯入某個類的時候匯入.m檔案,而不是.h檔案

 

 

ios 常見錯誤整理 持續更新

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.