{"id":1067,"date":"2011-01-17T16:19:02","date_gmt":"2011-01-17T07:19:02","guid":{"rendered":"http:\/\/yamazon.org\/?p=1067"},"modified":"2011-01-17T16:19:02","modified_gmt":"2011-01-17T07:19:02","slug":"addressbook%e5%86%85%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92tableview%e3%81%ab%e8%a1%a8%e7%a4%ba%e3%81%95%e3%81%9b%e3%82%8b","status":"publish","type":"post","link":"https:\/\/apr20.net\/?p=1067","title":{"rendered":"addressbook\u5185\u306e\u30c7\u30fc\u30bf\u3092tableView\u306b\u8868\u793a\u3055\u305b\u308b"},"content":{"rendered":"<blockquote><p>&#8211; (UITableViewCell *)tableView:(UITableView *)tableView<\/p>\n<p>cellForRowAtIndexPath:(NSIndexPath *)indexPath {<\/p>\n<p>static NSString *CellIdentifier = @&#8221;Cell&#8221;;<\/p>\n<p>UITableViewCell *cell = [tableView<\/p>\n<p>dequeueReusableCellWithIdentifier:CellIdentifier];<\/p>\n<p>if (cell == nil) {<\/p>\n<p>cell = [[[UITableViewCell alloc]<\/p>\n<p>initWithStyle:UITableViewCellStyleDefault<\/p>\n<p>reuseIdentifier:CellIdentifier]<\/p>\n<p>autorelease];<\/p>\n<p>}<\/p>\n<p>\/\/ref of Addressbook<\/p>\n<p>ABAddressBookRef book = ABAddressBookCreate();<\/p>\n<p>\/\/Count of Addressbook<\/p>\n<p>\/\/CFIndex cnt = ABAddressBookGetPersonCount(book);<\/p>\n<p>\/\/NSLog(@&#8221;addressbook count is %d &#8220;,cnt);<\/p>\n<p>\/\/AllRecords of Addressbook<\/p>\n<p>CFArrayRef records = ABAddressBookCopyArrayOfAllPeople(book);<\/p>\n<p>\/\/record at index=i<\/p>\n<p>ABRecordRef person = CFArrayGetValueAtIndex(records,indexPath.row);<\/p>\n<p>NSString *firstName = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);<\/p>\n<p>NSString *lastName = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);<\/p>\n<p>if (firstName == nil) {<\/p>\n<p>firstName = @&#8221;&#8221;;<\/p>\n<p>}<\/p>\n<p>if (lastName == nil) {<\/p>\n<p>lastName = @&#8221;&#8221;;<\/p>\n<p>}<\/p>\n<p>cell.textLabel.text = [NSString stringWithFormat:@&#8221;%@ %@&#8221;,lastName,firstName];<\/p>\n<p>return cell;<\/p>\n<p>}<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>&#8211; (UITableViewCell *)tableView:(UI&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-1067","post","type-post","status-publish","format-standard","hentry","category-old-blog"],"_links":{"self":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/1067","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1067"}],"version-history":[{"count":0,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/1067\/revisions"}],"wp:attachment":[{"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1067"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1067"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1067"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}