Skip to content

Instantly share code, notes, and snippets.

View Jon-Schneider's full-sized avatar

Jon Schneider Jon-Schneider

View GitHub Profile
```
root@5ff360c597d8:/TestApp# rails s -p 3333
=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://localhost:3333
=> Run `rails server -h` for more startup options
[Listen warning]:
Listen will be polling for changes. Learn more at https://github.com/guard/listen#polling-fallback.
Exiting
An exception occurred running bin/rails
@Jon-Schneider
Jon-Schneider / Get iOS contacts sorted by First Name or Last Name
Last active December 21, 2015 14:38
A bug in the iOS Address Book library returns contacts in the wrong alphabetical sort order when requesting them by First or Last name. I wrote this code as a way to do my own sort of all contacts. This method will sort by first or last name based on an NSUserDefault bool, falling back onto their company name if the contact has no first or last …
#pragma mark - All Contacts list sort handling function and method.
CFComparisonResult ABPersonComparePeopleByIdentifier (ABRecordRef person1, ABRecordRef person2, ABPersonSortOrdering ordering) {
NSString *firstName1 = (__bridge NSString *)ABRecordCopyValue(person1, kABPersonFirstNameProperty);
NSString *lastName1 = (__bridge NSString *)ABRecordCopyValue(person1, kABPersonLastNameProperty);
NSString *orgName1 = (__bridge NSString *)ABRecordCopyValue(person1, kABPersonOrganizationProperty);
NSString *identifier1;
BOOL firstNameSortingIsOn = [[NSUserDefaults standardUserDefaults] boolForKey:@"first-name-sort"];