Skip to content

Instantly share code, notes, and snippets.

View gonzalezreal's full-sized avatar

Guille Gonzalez gonzalezreal

View GitHub Profile
@interface ACAccountStore (Twitter)
+ (ACAccountStore *)tgr_sharedAccountStore;
- (BOOL)tgr_twitterAccountAccessGranted;
- (void)tgr_requestAccessToTwitterAccountsWithCompletionHandler:(void (^)(BOOL granted, NSError *error))completionHandler;
- (NSArray *)tgr_twitterAccounts;
#import "TGRTweetCell.h"
.
.
.
- (void)viewDidLoad
{
[super viewDidLoad];
//
// TGRTweetCell.m
// TwitterTimeline
//
// Created by guille on 23/10/12.
// Copyright (c) 2012 Guillermo Gonzalez. All rights reserved.
//
#import "TGRTweetCell.h"
#import "TGRTweet.h"
//
// TGRProfileImageView.m
// TwitterTimeline
//
// Created by guille on 27/10/12.
// Copyright (c) 2012 Guillermo Gonzalez. All rights reserved.
//
#import "TGRProfileImageView.h"
#import "SDWebImageManagerDelegate.h"
#import "TGRTimelineViewController.h"
#import "TGRTimeline.h"
#import "TGRTweet.h"
#import "TGRTwitterUser.h"
#import "ACAccountStore+Twitter.h"
static NSString * const kTweetCellIdentifier = @"TweetCell";
@interface TGRTimelineViewController ()
// Based on Standford's CoreDataTableViewController
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
@interface TGRFetchedResultsTableViewController : UITableViewController <NSFetchedResultsControllerDelegate>
@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
@property (nonatomic) BOOL ignoreContentChanges;
- (NSManagedObjectContext *)managedObjectContext
{
if (!_managedObjectContext) {
_managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
[_managedObjectContext setPersistentStoreCoordinator:self.persistentStoreCoordinator];
}
return _managedObjectContext;
}
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (!_persistentStoreCoordinator) {
NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
path = [path stringByAppendingPathComponent:self.account.username];
NSURL *url = [NSURL fileURLWithPath:path];
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:self.managedObjectModel];
- (NSManagedObjectModel *)managedObjectModel
{
if (!_managedObjectModel) {
NSString *path = [[NSBundle mainBundle] pathForResource:@"Twitter" ofType:@"mom"];
if (!path) {
path = [[NSBundle mainBundle] pathForResource:@"Twitter" ofType:@"momd"];
}
NSURL *url = [NSURL fileURLWithPath:path];
@interface TGRTimeline ()
@property (nonatomic, readwrite) BOOL loading;
@property (strong, nonatomic) ACAccount *account;
// Core Data stack
@property (strong, nonatomic, readwrite) NSManagedObjectContext *managedObjectContext;
@property (strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;