收集了一些常見到問題,能夠用做面試題目,供你們參考。 面試
一、ObjC中,與alloc語義相反的方法是dealloc仍是release?與retain語義相反的方法是dealloc仍是release,爲何?須要與alloc配對使用的方法是dealloc仍是release,爲何? 函數
二、在一個對象的方法裏面: spa
self.name = 「object」;和 .net
name =」object」 對象
有什麼不一樣嗎? get
三、這段代碼有什麼問題嗎: string
@implementation Person it
- (void)setAge:(int)newAge { io
self.age = newAge; class
}
四、什麼是retain count?
五、如下每行代碼執行後,person對象的retain count分別是多少
Person *person = [[Person alloc] init];
[person retain];
[person release];
[person release];
六、爲何不少內置類如UITableViewController的delegate屬性都是assign而不是retain的?
七、定義屬性時,什麼狀況使用copy,assign,和retain
八、autorelease的對象是在何時被release的?
九、這段代碼有什麼問題,如何修改
十、for (int i = 0; i < someLargeNumber; i++) {
NSString *string = @」Abc」;
string = [string lowercaseString];
string = [string stringByAppendingString:@"xyz"];
NSLog(@「%@」, string);
}
十一、autorelease和垃圾回收機制(gc)有什麼關係?
十二、IPhone OS有沒有垃圾回收(gc)?
1三、什麼是Notification?
1四、何時用delegate,何時用Notification?
1五、什麼是KVC和KVO?
1六、Notification和KVO有什麼不一樣?
1七、KVO在ObjC中是怎麼實現的?
1八、ViewController 的 loadView, viewDidLoad, viewDidUnload 分別是在何時調用的?在自定義ViewController的時候這幾個函數裏面應該作什麼工做?
1九、ViewController 的 didReceiveMemoryWarning 是在何時被調用的?默認的操做是什麼?