This file contains hidden or 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
NSFetchRequest *fetchRequest = [TGRTweet fetchRequestForAllTweets]; | |
NSArray *tweets = [self.managedObjectContext executeFetchRequest:fetchRequest error:NULL]; |
This file contains hidden or 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
@interface TGRManagedObject : NSManagedObject | |
+ (NSString *)entityName; | |
+ (NSFetchRequest *)fetchRequest; | |
+ (id)insertNewObjectInManagedObjectContext:(NSManagedObjectContext *)context; | |
+ (id)importFromDictionary:(NSDictionary *)dictionary inManagedObjectContext:(NSManagedObjectContext *)context; | |
- (void)importValuesFromDictionary:(NSDictionary *)dictionary; |
This file contains hidden or 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
+ (NSString *)entityName | |
{ | |
return NSStringFromClass([self class]); | |
} | |
+ (NSFetchRequest *)fetchRequest | |
{ | |
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:[self entityName]]; | |
[fetchRequest setFetchBatchSize:25]; | |
This file contains hidden or 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 "TGRManagedObject.h" | |
@class TGRTweet; | |
@interface TGRTwitterUser : TGRManagedObject | |
... |
This file contains hidden or 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
+ (NSFetchRequest *)fetchRequestForTwitterUserWithIdentifier:(NSNumber *)identifier; | |
+ (id)twitterUserWithIdentifier:(NSNumber *)identifier | |
inManagedObjectContext:(NSManagedObjectContext *)context; |
This file contains hidden or 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
+ (NSFetchRequest *)fetchRequestForTwitterUserWithIdentifier:(NSNumber *)identifier | |
{ | |
static dispatch_once_t onceToken; | |
static NSPredicate *predicateTemplate; | |
dispatch_once(&onceToken, ^{ | |
predicateTemplate = [NSPredicate predicateWithFormat:@"identifier == $IDENTIFIER"]; | |
}); | |
NSPredicate *predicate = [predicateTemplate predicateWithSubstitutionVariables: |
This file contains hidden or 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
+ (id)twitterUserWithIdentifier:(NSNumber *)identifier inManagedObjectContext:(NSManagedObjectContext *)context | |
{ | |
NSFetchRequest *fetchRequest = [self fetchRequestForTwitterUserWithIdentifier:identifier]; | |
return [[context executeFetchRequest:fetchRequest error:NULL] lastObject]; | |
} |
This file contains hidden or 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)importValuesFromDictionary:(NSDictionary *)dictionary | |
{ | |
self.identifier = dictionary[@"id"]; | |
self.name = dictionary[@"name"]; | |
self.screenName = dictionary[@"screen_name"]; | |
self.imageLink = dictionary[@"profile_image_url"]; | |
} |
This file contains hidden or 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 "TGRManagedObject.h" | |
@class TGRTwitterUser; | |
@interface TGRTweet : TGRManagedObject | |
... |
This file contains hidden or 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
+ (NSFetchRequest *)fetchRequestForAllTweets; | |
+ (id)firstTweetInManagedObjectContext:(NSManagedObjectContext *)context; | |
+ (id)lastTweetInManagedObjectContext:(NSManagedObjectContext *)context; |