Skip to content

Instantly share code, notes, and snippets.

@kuetsuhara kuetsuhara/gist:8111082
Last active Jan 1, 2016

What would you like to do?
- (void)loadAllDocuments{
// appDelegate呼び出し
AppDelegate *ap = ApplicationDelegate;
// ArrayをClear
[dataArray removeAllObjects];
// すべてのクエリを読み込む
CBLQuery *allQuary = [ap.database queryAllDocuments];
// appDelegate呼び出し
AppDelegate *ap = ApplicationDelegate;
for (CBLQueryRow* row in query.rows) {
// document取得
CBLDocument* doc = [ap.database documentWithID: row.key];
LOG(@"dic :: %@",;
if ([[ objectForKey:@"type"] isEqualToString:@"spItem"]) {
// モデルクラスの生成
ShoppingItem *item = [ShoppingItem modelForDocument:doc];
[dataArray addObject:item];
// 時間順に並び替えをする
NSSortDescriptor *sortDispNo = [[NSSortDescriptor alloc] initWithKey:@"created_at" ascending:NO];
NSArray *sortDescArray = [NSArray arrayWithObjects:sortDispNo, nil];
[dataArray setArray:[dataArray sortedArrayUsingDescriptors:sortDescArray]];
[table reloadData];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.