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
@import UIKit;
@interface UIView (QuickLook)
@end
@implementation UIView (QuickLook)
- (id)debugQuickLookObject {
return self;
Pod::Spec.new do |s|
s.name = "ReactiveCocoa"
s.version = "2.0.0dev"
s.summary = "A framework for composing and transforming sequences of values."
s.homepage = "https://github.com/blog/1107-reactivecocoa-is-now-open-source"
s.author = { "Josh Abernathy" => "josh@github.com" }
s.source = { :git => "https://github.com/ReactiveCocoa/ReactiveCocoa.git", :branch => '2.0-development' }
s.license = 'Simplified BSD License'
s.description = "ReactiveCocoa offers:\n" \
"1. The ability to compose operations on future data.\n" \
@gonzalezreal
gonzalezreal / gist:4194038
Created December 3, 2012 10:12
Como evitar referencias circulares cuando usamos ARC con bloques
// Este código crea una referencia circular entre 'operation' y self
self.operation = [NSBlockOperation blockOperationWithBlock:^{
[self doSomething];
}];
// Para evitarlo tenemos pasarle al bloque una referencia débil a self
typeof(self) __weak w_self = self;
#import <UIKit/UIKit.h>
@class TGRTweet;
@class TGRProfileImageView;
@interface TGRTweetCell : UITableViewCell
@property (strong, nonatomic) TGRProfileImageView *profileImageView;
@property (strong, nonatomic) UILabel *nameLabel;
@property (strong, nonatomic) UILabel *dateLabel;
#import <UIKit/UIKit.h>
@interface TGRProfileImageView : UIView
- (void)setProfileImageURL:(NSURL *)url;
- (void)cancelCurrentImageLoad;
@end
@gonzalezreal
gonzalezreal / gist:4007534
Created November 3, 2012 14:31
Utilizando NSFetchedResultsController
- (void)controller:(NSFetchedResultsController *)controller
didChangeObject:(id)anObject
atIndexPath:(NSIndexPath *)indexPath
forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath *)newIndexPath
{
// Aquí podemos utilizar los métodos de UITableView para
// actualizar nuestra tabla
}
@gonzalezreal
gonzalezreal / gist:4007532
Created November 3, 2012 14:30
Utilizando NSFetchedResultsController
NSFetchedResultsController *frc = [[NSFetchedResultsController alloc] initWithFetchRequest:[TGRTweet fetchRequestForAllTweets]
managedObjectContext:managedObjectContext
sectionNameKeyPath:nil
cacheName:nil];
@gonzalezreal
gonzalezreal / gist:4007531
Created November 3, 2012 14:29
Utilizando NSFetchedResultsController
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = ...;
TGRTweet *tweet = [self.fetchedResultsController objectAtIndexPath:indexPath];
// Configuramos la celda usando los atributos del tweet
// ...
return cell;
}
@gonzalezreal
gonzalezreal / gist:4007527
Created November 3, 2012 14:28
Utilizando NSFetchedResultsController
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [[self.fetchedResultsController sections] count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[[self.fetchedResultsController sections] objectAtIndex:section] numberOfObjects];
}
+ (ACAccountStore *)tgr_sharedAccountStore
{
static dispatch_once_t onceToken;
static ACAccountStore *accountStore;
dispatch_once(&onceToken, ^{
accountStore = [[ACAccountStore alloc] init];
});
return accountStore;