linxinfei 2011-10-26
注:本文是一份学习笔记。
cocoa touch由苹果公司提供的软件开发api, 用于开发 iphone\ipod\ipad上的软件。也是苹果公司针对iPhone应用程序快速开发提供的一个类库。此库以一系列框架库的形式存在,支持开发人员使用用户界面元素构建图像化的事件驱动的应用程序。
CocoaTouch层由多个框架组成,他们为应用程序提供了核心功能。
UIKit负责启动和结束应用程序,控制界面和多触点事件
MapKit提供地图的相关服务
GameKit创建和使用网络机制
Message UI/Adress Book UI 提供操作电子邮件和联系人的信息A callback is a function that is triggered when an event occurs. Usually, this is an event that happens in response to user input. We don’t exactly know when this event might occur, but we set upa callback so that when it does occur, our code will be called. In some systems, callbacks are sent to objects that are known as listeners.
In Cocoa Touch, callbacks are implemented using a technique known as delegation.
There are two basic categories of delegate methods. Some are “for-your- information” methods. These methods are sent to a delegate to inform it that something has happened. For example, you would implement textViewDidChange: to be informed when the text in a UITextView changes.
Other delegate methods are “what-should-I-do?” methods. These methods expect a response back from the delegate that will dictate the behavior of the delegating object. For example, if a delegate implements textView:shouldChangeTextInRa nge:replacementText:, it can prevent an inappropriate edit by returning NO.
(Here’s a shortcut: in Xcode, hold down the Option and Command keys and double-click the name of the protocol. The documentation browser will appear displaying a list of every method for that protocol.)
A framework is a collection of related classes, and Cocoa Touch is a set of frameworks.
Add frameworks to your project:
Select Edit Active Target from the Project menu. In the Target Info window that appears, select the General tab. At the bottom of the window is a list of Linked Libraries. Click the + button on the bottom-left corner of the window. A sheet will drop down from this window listing all of the available frameworks for iPhone OS.
Location Services enables applications to determine the device’s geographical location. Core Location is the framework that you use to talk to Location Services. No matter what type of device is being used, the Core Location code you write does not change.
Most of the applications in this book have controller objects that exist the entire time an application is running. This is the behavior for many controller objects in real applications for two reasons:
•Controllerobjectsarethebrainsofanapplication.Theytakeonalotofrolesandtypicallyareneededthroughouttheexecutionofanapplication.
• Controller objects do not consume a lot of memory themselves. They only hold pointers to view and model objects, which are the two types of classes that consume the majority of memory. If memory is running low, the controller can get rid of the big objects it has pointers to (and, ideally, be able to reload those objects when needed).Now, this isn’t to say that all controller objects exist throughout an application’s lifetime. Some controller objects can exist temporarily for a specific task. In these circumstances, you will need to release the appropriate instance variables in the controller’s dealloc method.
The Core Location framework tells us where we are in the world; the MapKit framework shows us that world.