iOS核心面试题 ~

来源:互联网 发布:电脑滚动字幕软件 编辑:程序博客网 时间:2024/05/16 06:58
1. 什么是arc?(arc是为了解决什么问题诞生的?)
2. 请解释以下keywords的区别: assign vs weak, __block vs __weak
3. __block在arc和非arc下含义一样吗?
4. 使用atomic一定是线程安全的吗?
5. 描述一个你遇到过的retain cycle例子。(别撒谎,你肯定遇到过)
6. +(void)load; +(void)initialize;有什么用处?
7. 为什么其他语言里叫函数调用, objective c里则是给对象发消息(或者谈下对runtime的理解)
8. 什么是method swizzling?
9. UIView和CALayer是啥关系?
10. 如何高性能的给UIImageView加个圆角?(不准说layer.cornerRadius!)
11. 使用drawRect有什么影响?(这个可深可浅,你至少得用过。。)
12. ASIHttpRequest或者SDWebImage里面给UIImageView加载图片的逻辑是什么样的?(把UIImageView放到UITableViewCell里面问更赞)
13. 麻烦你设计个简单的图片内存缓存器(移除策略是一定要说的)
14. 讲讲你用Instrument优化动画性能的经历吧(别问我什么是Instrument)
15. loadView是干嘛用的?
16. viewWillLayoutSubView你总是知道的。。
17. GCD里面有哪几种Queue?你自己建立过串行queue吗?背后的线程模型是什么样的?
18. 用过coredata或者sqlite吗?读写是分线程的吗?遇到过死锁没?咋解决的?
19. http的post和get啥区别?(区别挺多的,麻烦多说点)

20. 我知道你大学毕业过后就没接触过算法数据结构了,但是请你一定告诉我什么是Binary search tree? search的时间复杂度是多少?我很想知道!


解题:

1. 什么是arc?(arc是为了解决什么问题诞生的?)

http://mobile.51cto.com/iphone-313122.htm


2. 请解释以下keywords的区别: assign vs weak, __block vs __weak

assign和weak都是不会retain的,但是assign用在基本数据类型,而weak用在OC的对象中。

__block vs __weak:http://stackoverflow.com/questions/11773342/what-is-the-difference-between-a-weak-and-a-block-reference

__block variables live in storage that is shared between the lexical scope of the variable and all blocks and block copies declared or created within the variable’s lexical scope. Thus, the storage will survive the destruction of the stack frame if any copies of the blocks declared within the frame survive beyond the end of the frame (for example, by being enqueued somewhere for later execution). Multiple blocks in a given lexical scope can simultaneously use a shared variable.

__block变量生存在共享于变量的词法域的储存器和所有的blocks和block的拷贝值被声明或者创建在变量的词法域,因此,储存器将持续堆栈结构的销毁如果任何的blocks的拷贝声明于这个结构且超过了堆栈结构的结尾(例如,堆栈结构列入队列而在不知道哪里再执行)。多个blocks在给定的词法域可以同时使用共享的变量。





待续...


0 0
原创粉丝点击