Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Optimization: don't issue GET for every row displayed
Browse files Browse the repository at this point in the history
Get the value of the 'check' and 'text' properties from the row's value rather than fetching the whole document.
  • Loading branch information
snej committed Sep 13, 2011
1 parent 1741144 commit 5a278fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Resources/CouchDemo-Info.plist
Expand Up @@ -50,7 +50,7 @@
<key>CFBundleSignature</key>
<string>codm</string>
<key>CFBundleVersion</key>
<string>103</string>
<string>105</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSMainNibFile</key>
Expand Down
9 changes: 5 additions & 4 deletions Source/RootViewController.m
Expand Up @@ -129,12 +129,13 @@ - (void)couchTableSource:(CouchUITableSource*)source
cell.textLabel.font = [UIFont fontWithName: @"Helvetica" size:18.0];
cell.textLabel.backgroundColor = [UIColor clearColor];

// Configure the cell contents:
NSDictionary* properties = row.document.properties;
BOOL checked = [[properties valueForKey:@"check"] boolValue];
// Configure the cell contents. Our view function (see above) copies the document properties
// into its value, so we can read them from there without having to load the document:
NSDictionary* properties = row.value;
BOOL checked = [[properties objectForKey:@"check"] boolValue];

UILabel *labelWithText = cell.textLabel;
labelWithText.text = [properties valueForKey:@"text"];
labelWithText.text = [properties objectForKey:@"text"];
labelWithText.textColor = checked ? [UIColor grayColor] : [UIColor blackColor];

[cell.imageView setImage:[UIImage imageNamed:
Expand Down

0 comments on commit 5a278fb

Please sign in to comment.