EGYBlogPost 1.0.1

EGYBlogPost 1.0.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.



  • By
  • Mokhlas Hussein

EGYBlogPost Easy Way To Fetch Blogs Posts Using json.

Cocoapods

  • pod 'EGYBlogPost'

Usage

NSURL *EGYBlog = [NSURL URLWithString:@"JSON-API-URL"];

NSData *EGYJSON = [NSData dataWithContentsOfURL:EGYBlog];

NSError *ERROR = nil;

NSDictionary *dataDictionary = [NSJSONSerialization JSONObjectWithData:EGYJSON options:0 error:&ERROR];

NSMutableArray *EGYBLOGPOSTS = [NSMutableArray array];

NSArray *blogPostsArray = [dataDictionary objectForKey:@"posts"];

for (NSDictionary *bpDictionary in blogPostsArray) {
    EGYBlogPost *blogPost = [EGYBlogPost egyBlogPostWithTitle:[bpDictionary objectForKey:@"title"]];
    blogPost.author = [bpDictionary objectForKey:@"author"];
    blogPost.thumbnail = [bpDictionary objectForKey:@"thumbnail"];
    blogPost.date = [bpDictionary objectForKey:@"date"];
    blogPost.url = [NSURL URLWithString:[bpDictionary objectForKey:@"url"]];
    [EGYBLOGPOSTS addObject:blogPost];

Credits

EGYBlogPost is brought to you by Mokhles Hussien @iMokhles