説明なし

PageHeader.m 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // PageResponseInfo.m
  3. // FirstLink
  4. //
  5. // Created by unicode on 14-11-10.
  6. // Copyright (c) 2014年 FirstLink. All rights reserved.
  7. //
  8. #import "PageHeader.h"
  9. @implementation PageHeader
  10. + (PageHeader*)defaultPageHeader {
  11. PageHeader *header = [[PageHeader alloc] init];
  12. header.pageSize = [NSString stringWithFormat:@"%d", PAGE_RECORD_COUNT];
  13. return header;
  14. }
  15. + (PageHeader*)parserHeader:(NSDictionary *)json {
  16. if (json[@"data"][@"pager"] != [NSNull null]) {
  17. NSDictionary *pageData = json[@"data"][@"pager"];
  18. PageHeader *header = [[PageHeader alloc] init];
  19. if (pageData[@"index"] != [NSNull null]) {
  20. header.index = [NSString stringWithFormat:@"%@", pageData[@"index"]];
  21. }
  22. if (pageData[@"anchor_id"] != [NSNull null]) {
  23. header.anchorID = [NSString stringWithFormat:@"%@", pageData[@"anchor_id"]];
  24. }
  25. if (pageData[@"page_size"]) {
  26. header.pageSize = [NSString stringWithFormat:@"%@", pageData[@"page_size"]];
  27. }
  28. if (pageData[@"start_row"] != [NSNull null]) {
  29. header.startRow = [NSString stringWithFormat:@"%@", pageData[@"start_row"]];
  30. }
  31. return header;
  32. }
  33. return [PageHeader defaultPageHeader];
  34. }
  35. @end