Skip to content

Instantly share code, notes, and snippets.

@gonzalezreal
Created October 24, 2012 07:18
Show Gist options
  • Select an option

  • Save gonzalezreal/3944525 to your computer and use it in GitHub Desktop.

Select an option

Save gonzalezreal/3944525 to your computer and use it in GitHub Desktop.
- (void)importValuesFromDictionary:(NSDictionary *)dictionary
{
self.identifier = dictionary[@"id"];
NSDictionary *retweetedStatus = dictionary[@"retweeted_status"];
NSString *dateString = nil;
NSDictionary *userDictionary = nil;
NSDictionary *retweetedByDictionary = nil;
if (retweetedStatus) {
self.text = retweetedStatus[@"text"];
dateString = retweetedStatus[@"created_at"];
userDictionary = retweetedStatus[@"user"];
retweetedByDictionary = dictionary[@"user"];
}
else {
self.text = dictionary[@"text"];
dateString = dictionary[@"created_at"];
userDictionary = dictionary[@"user"];
}
self.publicationDate = [[self class] dateFromTwitterDate:dateString];
TGRTwitterUser *user = [TGRTwitterUser twitterUserWithIdentifier:userDictionary[@"id"]
inManagedObjectContext:self.managedObjectContext];
if (!user) {
user = [TGRTwitterUser importFromDictionary:userDictionary
inManagedObjectContext:self.managedObjectContext];
}
self.user = user;
if (retweetedByDictionary) {
TGRTwitterUser *retweetedBy = [TGRTwitterUser twitterUserWithIdentifier:retweetedByDictionary[@"id"]
inManagedObjectContext:self.managedObjectContext];
if (!retweetedBy) {
retweetedBy = [TGRTwitterUser importFromDictionary:retweetedByDictionary
inManagedObjectContext:self.managedObjectContext];
}
self.retweetedBy = retweetedBy;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment