昨天我通过iOS进行了一次面试,面试官问道,在MVC设计模式中有哪些OOP概念是适用的,而我对此一无所知。
发布于 2013-11-28 15:03:15
引用Developer.Apple.com的话说,基本的iOS设计模式是:
“无论你正在创建哪种类型的应用程序,在开始编写代码之前,你都必须了解一些基本的设计模式和技术。在iOS中,系统框架为你的应用程序提供了关键的基础结构,在大多数情况下是访问底层硬件的唯一途径。反过来,这些框架使用许多特定的设计模式,并假设你熟悉它们。因此,理解这些设计模式是理解系统如何帮助你开发应用程序的重要第一步。”
你必须知道的最重要的设计模式是:
Model-View-Controller—This design pattern governs the overall structure of your app.
Delegation—This design pattern facilitates the transfer information and data from one object to another.
Target-action—This design pattern translates user interactions with buttons and controls into code that your app can execute.
Block objects—You use blocks to implement callbacks and asynchronous code.
Sandboxing—All iOS apps are placed in sandboxes to protect the system and other apps. The structure of the sandbox affects the placement of your app’s files and has implications for data backups and some app-related features.
准确和高效的内存管理对于iOS应用程序非常重要。由于iOS应用程序的可用内存通常比可比的台式计算机少,因此应用程序需要积极删除不需要的对象,并在一开始就懒于创建对象。应用程序使用编译器的自动引用计数(ARC)功能来有效地管理内存。虽然不需要使用ARC,但强烈建议使用ARC。另一种方法是通过显式地保留和释放对象来自己管理内存。“
编辑:
有关编程示例,请参阅:
http://www.cs.colorado.edu/~kena/classes/5448/f12/presentation-materials/myrose.pdf
发布于 2013-11-28 14:37:31
不是一个详尽的列表..
继承: UIView通常是子类化的。
多义性。请参见继承。
设计模式模型-查看器-控制器:这就是MVC所代表的。
设计模式观察者:在MVC中广泛使用。
设计模式在iOS实现中的具体应用:
复合和命令链:窗口和视图将消息传递给子视图。
适配器:常用于UIView等的延迟加载。
Flyweight:在UITable中使用
https://stackoverflow.com/questions/20259211
复制相似问题