EGYBlogPost 1.0.1

EGYBlogPost 1.0.1

测试已测试
语言语言 Objective-CObjective C
许可证 MIT
发布上次发布2014年12月

未知的 维护。



  • 作者
  • Mokhlas Hussein

EGYBlogPost 用 json 获取博客文章的简单方式。

Cocoapods

  • pod 'EGYBlogPost'

用法

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];

致谢

EGYBlogPost 由 Mokhles Hussien 带来 @iMokhles