Skip to content

Instantly share code, notes, and snippets.

__block XXCurrentUser * user = nil;
dispatch_group_t group = dispatch_group_create();
[[XXClient sharedManager] setObserverDidSignInBlock:^(XXAccessCredential *accessCredential, NSError *error) {
[[LUKeychainAccess standardKeychainAccess] setObject:accessCredential forKey:NSStringFromClass([self class])];
if(error)theBlock(nil,error);
else dispatch_group_leave(group);
}];
//Hmm lets not clear up the blocks because lol. ~ Seivan.
__block XXCurrentUser * user = nil;
dispatch_group_t groupRequestMyProfile = dispatch_group_create();
dispatch_group_t groupSaveMyProfile = dispatch_group_create();
dispatch_group_t groupRequestMyApplications = dispatch_group_create();
dispatch_group_t groupRequestMyNotifications = dispatch_group_create();
[[XXClient sharedManager] setObserverDidSignInBlock:^(XXAccessCredential *accessCredential, NSError *error) {
@seivan
seivan / 0_reuse_code.js
Created January 30, 2014 13:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
[SINavigationControllerAccompanyTransition accompanyFromController:self
withNavigationController:self.navigationController];
[self.txtFieldPhoneNumber SH_addControlEvents:UIControlEventEditingChanged withBlock:[ETPhoneHandlers handlePhoneWithController:self]];
[self.txtFieldCountryName SH_setShouldBeginEditingBlock:[ETPhoneHandlers handleCountryWithController:self]];
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;{
CGFloat heightForRowAtIndexPath = 44.f;
NSString * cellID = [self cellIdForIndexPath:indexPath];
UITableViewCell <XXApplicationTableViewCellConfiguring> * cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if([cell conformsToProtocol:@protocol(XXApplicationTableViewCellConfiguring)]) {
[cell configureCellWithApplicationModel:self.application];
[cell layoutSubviews];
heightForRowAtIndexPath = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
}
if(self.accessCredential.isAboutToExpire) [self refreshToken];
dispatch_group_notify(self.signalWaitingForRefresh, dispatch_get_main_queue(), ^{
[self.apiClient requestWithResourcePath:theResourcePath parameters:theParameters HTTPMethod:theHTTPMethod onComplete:^(NSDictionary *responseObject, NSError *error, NSHTTPURLResponse *HTTPURLResponse) {
theBlock(responseObject,error, HTTPURLResponse);
}];
});
@seivan
seivan / gist:8793649
Last active August 29, 2015 13:56
Because it's 23:30 and I'm tired as fuck.
-(NSString *)platformsAsOxfordComma; {
NSArray * platforms = (NSArray *)self.platforms;
return [platforms SH_reduceValue:@"".mutableCopy withBlock:^id(NSMutableString * memo, NSString * obj) {
if(platforms.lastObject == obj) {
if(platforms.count > 1) [memo appendString:NSLocalizedString(@"AND", nil)]; // Do other languages even work like this?
[memo appendString:obj];
}
else {
[memo appendString:obj];
[memo appendString:@", "];
self.navigationController.transitioningDelegate = self;
[self SH_setAnimationDuration:0.5 withPreparedTransitionBlock:^(UIView *containerView, UIViewController *fromVC, UIViewController *toVC, NSTimeInterval duration, id<SHViewControllerAnimatedTransitioning> transitionObject, SHTransitionAnimationCompletionBlock transitionDidComplete) {
if (transitionObject.isReversed) {
toVC.view.layer.affineTransform = CGAffineTransformMakeTranslation(-CGRectGetWidth(toVC.view.frame), 0);
}
else {
toVC.view.layer.affineTransform = CGAffineTransformMakeTranslation(CGRectGetWidth(toVC.view.frame), 0);
}
+(instancetype)me; {
XXXCurrentUser * me = [XXXCurrentUser MR_findFirst];
[XXXClient sharedManager].accessCredential = [[LUKeychainAccess standardKeychainAccess]
objectForKey:NSStringFromClass([self class])];
if(me == nil || [XXXClient sharedManager].accessCredential == nil) {
me = nil;
Proper naming
completion: for callbacks that are complete (option)
completionHandler: callbacks that are complete but need action (required)
handler: callbacks that need action but are not necessarily completion (required)