このブログのチュートリアルを順に読み進めてくださった方なら、このチュートリアルがUITableVIewを優先的に取り組んできたことをご存知かと思います。
この理由としては、多くのアプリケーションが、このシンプルなコントロールを使って開発されているからです。
今回はUITableViewの最後のチュートリアルとして、今までのチュートリアルで学んできたことをすべて使い、SQLiteの技術を追加し、ToDoリストを作成していきます。
また、多くの機能を持ったテーブルセルを追加し、iPhoneが提供している他のコントロールについても学んでいきます。
過去の記事を既読の方を想定していますので、まだの方は、そちらの記事に先に目を通されることをおすすめします。
このチュートリアルは、いくつかのシリーズから成り立つので、過去の記事に比べ少し長くなります。この最初のチュートリアルで学ぶことは以下です。
今回学ぶこと:
Navigation-Based Application の新規作成
データベースの作成
プロジェクトにデータベースの追加
SQLite3のフレームワークを追加
ToDoクラスのオブジェクトの作成
データベースの初期化
…
– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @”Cell”; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } //ref of Addressbook ABAddressBookRef book = ABAddressBookCreate(); //Count of Addressbook //CFIndex cnt = ABAddressBookGetPersonCount(book); //NSLog(@”addressbook count is %d “,cnt); //AllRecords of Addressbook CFArrayRef records = ABAddressBookCopyArrayOfAllPeople(book); //record at index=i ABRecordRef person = CFArrayGetValueAtIndex(records,indexPath.row); NSString *firstName = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty); NSString *lastName = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty); if (firstName == nil) { firstName = @””; } if (lastName == nil) { lastName = @””; } cell.textLabel.text = [NSString stringWithFormat:@”%@ %@”,lastName,firstName]; return cell; }
この投稿へのコメント
コメントはまだありません。