Skip to content

Instantly share code, notes, and snippets.

View gonzalezreal's full-sized avatar

Guille Gonzalez gonzalezreal

View GitHub Profile
@gonzalezreal
gonzalezreal / UIView+QuickLook.m
Created March 12, 2014 16:54
Quick look UIViews in Xcode
View UIView+QuickLook.m
@import UIKit;
@interface UIView (QuickLook)
@end
@implementation UIView (QuickLook)
- (id)debugQuickLookObject {
return self;
@gonzalezreal
gonzalezreal / TGRAsyncTestHelper.m
Last active August 29, 2015 13:58
TGRAsyncTestHelper
View TGRAsyncTestHelper.m
#import <Foundation/Foundation.h>
#define TGR_RUNLOOP_INTERVAL 0.05
#define TGR_TIMEOUT_INTERVAL 1.0
#define TGR_RUNLOOP_COUNT TGR_TIMEOUT_INTERVAL / TGR_RUNLOOP_INTERVAL
#define TGR_CAT(x, y) x ## y
#define TGR_TOKCAT(x, y) TGR_CAT(x, y)
#define __runLoopCount TGR_TOKCAT(__runLoopCount,__LINE__)
View TGRTimeline.h
#import <Foundation/Foundation.h>
#import <Accounts/Accounts.h>
#import <CoreData/CoreData.h>
@interface TGRTimeline : NSObject
@property (strong, nonatomic, readonly) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, readonly, getter = isLoading) BOOL loading;
- (id)initWithAccount:(ACAccount *)account;
View TGRTwitterUser.m
- (void)importValuesFromDictionary:(NSDictionary *)dictionary
{
self.identifier = dictionary[@"id"];
self.name = dictionary[@"name"];
self.screenName = dictionary[@"screen_name"];
self.imageLink = dictionary[@"profile_image_url"];
}
View TGRTimeline.m
@implementation TGRTimeline
- (id)initWithAccount:(ACAccount *)account
{
self = [super init];
if (self) {
_account = account;
}
return self;
}
View TGRTimeline.m
- (BOOL)loadNewTweetsWithCompletionHandler:(void (^)(NSError *error))completionHandler
{
if (self.loading) {
return NO;
}
SLRequest *request = [self requestForNewTweets];
[self loadTweetsWithRequest:request completionHandler:completionHandler];
return YES;
View TGRTimeline.m
- (SLRequest *)requestForNewTweets
{
return nil;
}
- (SLRequest *)requestForOldTweets
{
return nil;
}
View TGRTwitterUser.h
+ (NSFetchRequest *)fetchRequestForTwitterUserWithIdentifier:(NSNumber *)identifier;
+ (id)twitterUserWithIdentifier:(NSNumber *)identifier
inManagedObjectContext:(NSManagedObjectContext *)context;
View TGRTwitterUser.m
+ (NSFetchRequest *)fetchRequestForTwitterUserWithIdentifier:(NSNumber *)identifier
{
static dispatch_once_t onceToken;
static NSPredicate *predicateTemplate;
dispatch_once(&onceToken, ^{
predicateTemplate = [NSPredicate predicateWithFormat:@"identifier == $IDENTIFIER"];
});
NSPredicate *predicate = [predicateTemplate predicateWithSubstitutionVariables:
View TGRTweet.h
#import "TGRManagedObject.h"
@class TGRTwitterUser;
@interface TGRTweet : TGRManagedObject
...