Skip to content

Instantly share code, notes, and snippets.

View badeen's full-sized avatar

Jonathan Badeen badeen

View GitHub Profile
- (void)drawLinesInRect:(CGRect)rect forFont:(UIFont *)font
{
CGFloat maxLineHeight = 30.0f;
CGFloat fontLineHeight = roundf(font.lineHeight);
CGFloat fontBaselineAdjustment = roundf(-font.descender);
CGFloat startY = fmodf(yOffset, fontLineHeight);
CGFloat totalDrawnLines = (int)(floorf(CGRectGetHeight(rect) / fontLineHeight));
for (NSUInteger drawnLine = 0; drawnLine < totalDrawnLines; drawnLine++) {
[[FBSession activeSession] closeAndClearTokenInformation];
if (NSClassFromString(@"ACAccountStore")) {
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
if ([accountStore respondsToSelector:NSSelectorFromString(@"ACAccountStoreRemoveCompletionHandler")]) {
ACAccountType *fbType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSArray *accounts = [accountStore accountsWithAccountType:fbType];
ACAccount *account = [accounts lastObject];
if (account) {
[accountStore renewCredentialsForAccount:account completion:^(ACAccountCredentialRenewResult renewResult, NSError *error) {
@badeen
badeen / gist:5051302
Created February 27, 2013 20:16
Is this a valid fetched property predicate? If not, what am I doing wrong and/or can I actually do this with a fetched property? I'm guessing it's not because I believe I'm crashing when attempting to use it. The goal is to ask a Match instance for all of its messages which have not been viewed.
"match.matchID == $FETCH_SOURCE.matchID && viewed == NO".
-------------------MODEL DETAILS ---------------------
Match (entity)
messages (to-many relationship with Message entity)
viewed (boolean attribute)
matchID (string attribute)
unviewedMessages (fetched property with - see above)
PREDICATE = "match.matchID == $FETCH_SOURCE.matchID && viewed == NO"
@badeen
badeen / gist:5226053
Created March 23, 2013 01:51
This crashes as a result of line 3. Is this not how you perform searches using MagicalRecord.
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"match == nil && failedChoice == NO"];
NSArray *users = [TNDRUser MR_findAllWithPredicate:predicate inContext:localContext];
for (TNDRUser *user in users) {
[user MR_deleteEntity];
}
} completion:nil];
@badeen
badeen / gist:5278042
Created March 30, 2013 19:31
I'm guessing this is bad when multiple contexts are at play.
- (void)managedObjectContextDidChange:(NSNotification *)note
{
NSArray *updatedObjects = [note userInfo][NSUpdatedObjectsKey];
if ([updatedObjects containsObject:self.user]) {
[self updateView:YES];
}
}
@badeen
badeen / A Call for Tinder
Last active December 21, 2015 10:29
We are looking to fill some positions at Tinder.
A Call for Tinder
We at Tinder are looking to hire
Some fresh cool coals to fuel our fire.
That lump given proper compression,
a clear diamond revealed might make an impression.
A bit about us
As evidenced thus
The way that we roll