Skip to content

Instantly share code, notes, and snippets.

@Daniel1of1
Last active August 29, 2015 13:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Daniel1of1/8937116 to your computer and use it in GitHub Desktop.
Save Daniel1of1/8937116 to your computer and use it in GitHub Desktop.
Add an accessory to cells in ABPeoplePickerNavigationController
Class ABMemberDataSourceClass = NSClassFromString(@"ABMembersDataSource");
SEL originalTableViewMethodSelector = @selector(tableView:cellForRowAtIndexPath:);
Method originalTableViewMethod = class_getInstanceMethod(ABMemberDataSourceClass, originalTableViewMethodSelector);
SEL newTableViewMethodSelector = @selector(dhc_tableView:cellForRowAtIndexPath:);
IMP newTableViewMethodImp = imp_implementationWithBlock(^UITableViewCell * (id __unused _self, UITableView *tableView, NSIndexPath *indexPath){
UITableViewCell *cell=[_self dhc_tableView:tableView cellForRowAtIndexPath:indexPath];
//add to the cell :) eg.
cell.accessoryType = UITableViewCellAccessoryCheckmark;
//
return cell;
});
class_addMethod(ABMemberDataSourceClass, newTableViewMethodSelector, newTableViewMethodImp, method_getTypeEncoding(originalTableViewMethod));
method_exchangeImplementations(originalTableViewMethod, class_getInstanceMethod(ABMemberDataSourceClass, @selector(dhc_tableView:cellForRowAtIndexPath:)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment