Skip to content

Instantly share code, notes, and snippets.

@ccarse
Created September 5, 2012 19:35
Show Gist options
  • Save ccarse/3643199 to your computer and use it in GitHub Desktop.
Save ccarse/3643199 to your computer and use it in GitHub Desktop.
kvcMagic: for more than just strings....
- (void)enhancedKvcMagic:(id)object {
int columnCount = sqlite3_column_count([_statement statement]);
int columnIdx = 0;
for (columnIdx = 0; columnIdx < columnCount; columnIdx++) {
id c = [self objectForColumnIndex:columnIdx];
// check for a null row
if (c) {
[object setValue:c forKey:[NSString stringWithUTF8String:sqlite3_column_name([_statement statement], columnIdx)]];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment