码迷,mamicode.com
首页 > 其他好文 > 详细

objective -c こだわり

时间:2014-12-24 19:47:19      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

You make an object by creating an instance of a particular class. You do this by allocating the object and initializing it with acceptable default values. When you allocate an object, you set aside enough memory for the object and set all instance variables to zero. Initialization sets an object’s initial state—that is, its instance variables and properties—to reasonable values and then returns the object. The purpose of initialization is to return a usable object. You need to both allocate and initialize an object to be able to use it.

A protocol defines a set of behaviors that are expected of an object in a given situation. A protocol comes in the form of a programmatic interface, one that any class may implement. Using protocols, two classes distantly related by inheritance can communicate with each other to accomplish a certain goal, such as parsing XML code or copying an object.

 Any class that can provide useful behavior to other classes can declare a programmatic interface for vending that behavior anonymously. Any other class can choose to adopt the protocol and implement one or more of the protocol’s methods, making use of the behavior.

 MVC
Model-View-Controller (MVC) is central to a good design for any iOS app. MVC assigns the objects in an app to one of three roles: model, view, or controller. In this pattern, models keep track of your app’s data, views display your user interface and make up the content of an app, and controllers manage your views. By responding to user actions and populating views with content from the data model, controllers serve as a gateway for communication between the model and views.

 As you’ve built your ToDoList app, you’ve followed an MVC-centric design. The interface you built in storyboards makes up the view layer. AddToDoItemViewController and ToDoListTableViewController are the controllers that manage your views. In Tutorial: Add Data, you’ll be incorporating a data model to work with the views and controllers in your app. When you begin designing your own app, it’s important to keep MVC at the center of your design.

objective -c こだわり

标签:

原文地址:http://www.cnblogs.com/vonk/p/4182915.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!