TAILIEUCHUNG - Phát triển ứng dụng cho iPhone và iPad - part 5

Tham khảo tài liệu 'phát triển ứng dụng cho iphone và ipad - part 5', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Building a Simple Data-Driven Application 9 Implementing Your Data Model Class In order for your class to serve data to the Tableview you ll need a method to return the requested data. So let s create an interface method called getNameAtlndex that will return the name from the model that corresponds with the index that is passed in. Bring up your header file by selecting it in the left-hand browser pane in Xcode. Below the right brace that closes the interface definition add the following line of code to declare the getNameAtlndex interface method - NSString getNameAtIndex int index You ll also need an interface method that tells users of the class how many rows you ll be returning. So add another method to the interface called getRowCount. Below the declaration for getNameAtlndex add the declaration for getRowCount - int getRowCount Your header file should look like this Available for download on import Foundation interface DataModel NSObject - NSString getNameAtIndex int index - int getRowCount end Now let s switch over to the data model implementation file and implement the new methods. You can quickly switch between a header and implementation file in Xcode by using the shortcut key combination CTRL-OPT-UP ARROW. f You will be well served to learn the keyboard shortcuts in Xcode. The small amount ir of time that you invest in learning them will more than pay off in time saved. Below the import statement in your implementation file add a local variable to hold the data list. Typically the data in your application will come from a database or some other datasource. To keep this example simple you ll use an NSArray as the datasource. Add the following line to the file below the import statement NSArray myData 10 CHAPTER 1 INTRODUCING DATA-DRIVEN APPLICATIONS Now inside the implementation block you add the implementation of the getNameAtIndex method. Add the following code stub between the .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.