Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
SQLite tiếp tục (go on) Bài này sẽ tiếp ục giới thieuj về cách sử dụng SQLite trong iPhone để tạo một UITableView với DL được lấy từ CSDL SQLite. | Bài 8 SQLite tiếp tục go on Bài này sẽ tiếp ục giới thieuj về cách sử dụng SQLite trong iPhone để tạo một UlTableView với DL được lấy từ CSDL SQLite. This tutorial is part 2 in our series of creating a to-do list. I will assume that you have completed the following tutorial and its prequisites. . iPhone Programming Tutorial - Creating a ToDo List Using SQLite Part 1 I will be using the code produced from that tutorial as a base for this one. When you are finished with this tutorial your application will look something like this Collection By traibingo 79 Collection By traibingo 79 In this section I will not only teach you how to display the SQL data in UITablewView but I will be detailing how to display it in multiple columns with images and text. For this tutorial you will need to download the following images. We will be using these images to denote the priority Green low Yellow medium Red high . Bring Your Code Up To Speed Before we begin we need to add some code to the Todo.h and Todo.m class to support the priority field in the database. Open up Todo.h and add the following code 3interface Todo NSObject sqliteS database NSString text NSInteger primaryKey NSInteger priority property assign nonatomic readonly NSInteger primaryKey property nonatomic retain NSString Hext property nonatomic NS Integer priority All that is new here is the added NSInteger priority property. We will be using this to get and set the priority for a given todo object. Next open Todo.m and add the following code. @synthesi ze pr imaryKey text priority - id initWithPrimaryKey NSInteger pk database sqIite3 db if self super init - primaryKey pk database db Compile the query for retrieving book data. See insertNewBooklntoDatabase for more detail if init_statement nil Note the at the end of the query. This is a parameter which can be replaced by a bound variable. This is a great way to optimize because frequently used queries can be compiled once then with each use new variable values can be .