標籤: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 常見錯誤整理 持續更新