面试题

1. ObjC中,与alloc语义相反的方法是dealloc还是release?与retain语义相反的方法是dealloc还是release,为什么?需要与alloc配对使用的方法是dealloc还是release,为什么?
2. 在一个对象的方法里面:
self.name<http://self.name/> = “object”;

name =”object”
有什么不同?
3. 这段代码有什么问题:
@implementation Person
- (void)setAge:(int)newAge {
self.age = newAge;
}
@end
4. 什么是retain count?
5. 以下每行代码执行后,person对象的retain count分别是多少
Person *person = [[Person alloc] init];
[person retain];
[person release];
[person release];
6. 为什么很多内置类如UITableViewController的delegate属性都是assign而不是retain的?
7. 定义属性时,什么情况使用copy,assign,和retain
8. autorelease的对象是在什么时候被release的?
9. 这段代码有什么问题,如何修改
for (int i = 0; i < someLargeNumber; i++)
{
NSString *string = @”Abc”;
string = [string lowercaseString];
string = [string stringByAppendingString:@"xyz"];
NSLog(@“%@”, string);
}
10. autorelease和垃圾回收机制(gc)有什么关系?IPhone OS有没有垃圾回收(gc)?
11. Objective C中的protocal是什么?
12. Objective C中的selector 是什么?
13. Objective C中的category是什么?
14. 什么是Notification?什么时候用delegate,什么时候用Notification?
15. 什么是KVC和KVO?Notification和KVO有什么不同?KVO在ObjC中是怎么实现的?
16. ViewController 的 loadView, viewDidLoad, viewDidUnload 分别是在什么时候调用的?在自定义ViewController的时候这几个函数里面应该做什么工作?
17. ViewController 的 didReceiveMemoryWarning 是在什么时候被调用的?UIViewController类中didReceiveMemoryWarning默认的操作是什么?
18. UITableViewController 中,创建UITableViewCell时,initWithSytle:resuseIdentifier 中,reuseIdentifier有什么用?简述UITableViewCell的复用原理.
19. UIView 和CALayer 有什么区别?
20. 以 UIView 类 animateWithDuration:animations: 为例,简述UIView动画原理

posted @ 2013-11-08 18:05  浪人这梦  阅读(199)  评论(0编辑  收藏  举报