beginning iphone 3 development exploring the iphone sdk phần 2

Mô hình MVC phân chia tất cả các chức năng thành ba loại khác nhau: Tạo thành các cửa sổ, điều khiển, và các yếu tố khác mà người sử dụng có thể xem và tương tác với các liên kết mô hình và xem lại với nhau và logic ứng dụng quyết định làm thế nào để xử lý đầu vào của người dùng | 32 CHAPTER 3 Handling Basic Interaction all object-oriented frameworks pay a certain amount of homage to MVC but few are as true to the MVC model as Cocoa Touch. The MVC model divides up all functionality into three distinct categories Model The classes that hold your application s data View Made up of the windows controls and other elements that the user can see and interact with Controller Binds the model and view together and is the application logic that decides how to handle the user s inputs The goal in MVC is to make the objects that implement these three types of code as distinct from one another as possible. Any object you write should be readily identifiable as belonging in one of the three categories with little or no functionality within it that could be classified within either of the other two. An object that implements a button for example shouldn t contain code to process data when that button is tapped and code that implements a bank account shouldn t contain code to draw a table to display its transactions. MVC helps ensure maximum reusability. A class that implements a generic button can be used in any application. A class that implements a button that does some particular calculation when it is clicked can be used only in the application for which it was originally written. When you write Cocoa Touch applications you will primarily create your view components using Interface Builder although you will sometimes also modify your interface from code or you might subclass existing views and controls. Your model will be created by crafting Objective-C classes designed to hold your application s data or by building a data model using Core Data which you ll learn about in Chapter 11. We won t be creating any model objects in this chapter s application because we have no need to store or preserve data but we will introduce model objects as our applications get more complex in future chapters. Your controller component will typically be composed of .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
45    69    2    28-04-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.