This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSFetchedResultsController *frc = [[NSFetchedResultsController alloc] initWithFetchRequest:[TGRTweet fetchRequestForAllTweets] | |
managedObjectContext:managedObjectContext | |
sectionNameKeyPath:nil | |
cacheName:nil]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView | |
{ | |
return [[self.fetchedResultsController sections] count]; | |
} | |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | |
{ | |
return [[[self.fetchedResultsController sections] objectAtIndex:section] numberOfObjects]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "TGRTweetCell.h" | |
. | |
. | |
. | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface TGRProfileImageView : UIView | |
- (void)setProfileImageURL:(NSURL *)url; | |
- (void)cancelCurrentImageLoad; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (ACAccountStore *)tgr_sharedAccountStore | |
{ | |
static dispatch_once_t onceToken; | |
static ACAccountStore *accountStore; | |
dispatch_once(&onceToken, ^{ | |
accountStore = [[ACAccountStore alloc] init]; | |
}); | |
return accountStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TGRProfileImageView.m | |
// TwitterTimeline | |
// | |
// Created by guille on 27/10/12. | |
// Copyright (c) 2012 Guillermo Gonzalez. All rights reserved. | |
// | |
#import "TGRProfileImageView.h" | |
#import "SDWebImageManagerDelegate.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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 | |
} |