iOS Interview Summary-2019

1. In addition to using UIWebView to interact with H5, have you tried or studied the interaction between WKWebView and H5? What problems will you encounter during use?

2. Briefly introduce Runtime

3. Can member variables be added to a class at runtime? Why not? (Why is the member variable list designed to be read-only? For what reasons?)

4. We all know that methods can be added to categories, but can member variables be added to categories? Why?

可以,通用Runtime重写成员变量的set和get方法

5. What are the advantages of using NSOperation over GCD in multi-threaded development?

6. What are the states of NSOperation?

7. When using NSOperationQueue, how to obtain the status of NSOperation in the queue?

8. What is the role of using atomic when adding attributes to a class? Can it guarantee thread safety?

确保属性四原子属性,不能保证线程安全

9. What issues need to be paid attention to when exchanging methods for class clusters?

10. Deep copy and shallow copy

深拷贝相当于开辟新的内存地址,将内容复制过来;浅拷贝是把对象的指针指向该内存地址

Is the +load method executed before or after the main function?

+load在main之前执行

11. In what order are the +load methods in the parent class, subclass, and subclass Category called?

执行顺序: 父类-->子类-->子类的Category

12. Let’s talk about KVO. Will assigning values ​​using KVC trigger KVO?

	 根据KVO的实现原理,是在运行时生成新的子类并重写其setter方法,在其内容发生改变时发送消息。但这只是对属性直接进行赋值会触发,如果属性是容器对象,对容器对象进行add或remove操作,则不会调用KVO的方法。可以通过KVC对应的API来配合使用,使容器对象内部发生改变时也能触发KVO。
	 在进行容器对象操作时,先调用下面方法通过key或者keyPath获取集合对象,然后再对容器对象进行add或remove等操作时,就会触发KVO的消息通知了。
	 key方法:
	 - (NSMutableArray *)mutableArrayValueForKey:(NSString *)key;
	 - (NSMutableOrderedSet *)mutableOrderedSetValueForKey:(NSString *)key API_AVAILABLE(macos(10.7), ios(5.0), watchos(2.0), tvos(9.0));
	 - (NSMutableSet *)mutableSetValueForKey:(NSString *)key;
	 - 
	 keyPath方法:
	 - (NSMutableArray *)mutableArrayValueForKeyPath:(NSString *)keyPath;
	 - (NSMutableOrderedSet *)mutableOrderedSetValueForKeyPath:(NSString *)keyPath API_AVAILABLE(macos(10.7), ios(5.0), watchos(2.0), tvos(9.0));
  	 - (NSMutableSet *)mutableSetValueForKeyPath:(NSString *)keyPath;

13. What performance optimizations have been made in the project?

14. MVC and MVVM

15. In RAC used in MVVM, hot signals and cold signals

16. How to communicate and call between modules at the same level when componentizing

17. What are the disadvantages of using CTMediator solution when componentizing?

18. Have you ever heard of other ways to communicate between modules? For example, URL is a method that will be briefly introduced.

19. Introduce the life cycle of UIViewController

20. Event delivery chain and event response chain

 事件的传递是从上到下(父控件到子控件),事件的响应是从下到上(顺着响应者链条向上传递:子控件到父控件。

21. Use GCD to implement asynchronous thread tasks A and B and execute task C after completion.

22. What should you pay attention to when using the - performSelector:afterDelay: method?

23. Binary tree traversal

24. How to quickly find the second largest number from a binary tree

25. For the caching strategy used in SDWebImage, how to ensure that the least used ones are cleared out of the cache first?

26. How to design a read-write lock

Guess you like

Origin blog.csdn.net/qq_31709953/article/details/98602786