本文整理常見 iOS 面試題,涵蓋 import、property、setter、記憶體管理、執行緒與英文題。
每個物件有參考計數,alloc、new、copy 會增加所有權;retain 增加計數;release 減少計數;計數為 0 時物件銷毀。若使用 ARC,編譯器會自動插入管理程式碼。
常見建立方式有 NSThread、NSOperationQueue、GCD。主線程可透過 performSelectorOnMainThread 或 dispatch_async 到主佇列。延遲可用 dispatch_after、performSelector afterDelay 或 NSTimer。
英文題常考 shallow/deep copy、categories vs inheritance、extensions、protocol vs interface、KVO/KVC、delegate、mutable/immutable、runtime、NSNotification、push notification、polymorphism、singleton、responder chain、frame/bounds、method/selector、garbage collection、NSOperation queue、lazy loading。