dạy thực hành lập trình tốt và phát triển các chương trình miễn phí bị rò rỉ. Tùy thuộc vào loại ứng dụng mà bạn đang viết, khôn ngoan sử dụng bộ nhớ có thể là rất quan trọng. Ví dụ, nếu bạn đang viết một ứng dụng vẽ tương tác tạo ra nhiều đối tượng trong quá trình thực hiện chương trình, | Your First iPhone Application 463 Returning to your New Project window select Window-Based Application in the top rightmost pane and then click on the Choose next prompted to enter the project name in the Save As box enter the text iPhone_1 and click also becomes your application s name by you know from previous projects you created with Xcode a new project will now be created for you that contains templates for files you ll want to is shown in Figure . Figure New iPhone project iPhone_1 is created. Depending on your settings and previous uses of Xcode your window might not appear precisely as depicted in Figure can choose to follow along with whatever your current layout resembles or else try to make it match the figure more closely. In the top-left corner of your Xcode window you see a drop-down labeled with your current selection of SDK and Active Configuration. Because we re not developing your application to run directly on the iPhone you want the SDK set up to run with the iPhone simulator and the Configuration to be set to Debug. If the drop-down is not labeled Simulator Debug set the appropriate options as shown in Figure . Entering Your Code Now we re ready to modify some of your project files. Notice that a class called projectname and project-name were created for you where in this example project-name is work of handling the various buttons and labels in the type ofWindow-based application you re creating gets delegated to a class called projectname AppDelegate or in this case iPhone_1AppDelegate. In this class we ll define meth- 464 Chapter 21 Writing iPhone Applications Figure iPhone_1 project with SDK and Configuration options set. ods to respond to actions that occur in the iPhone s window such as the pressing of a button or the movement of a you ll see it s in the Interface Builder application that you make the actual connection .