FLEXArrayExplorerViewController.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // FLEXArrayExplorerViewController.m
  3. // Flipboard
  4. //
  5. // Created by Ryan Olson on 5/15/14.
  6. // Copyright (c) 2014 Flipboard. All rights reserved.
  7. //
  8. #import "FLEXArrayExplorerViewController.h"
  9. #import "FLEXRuntimeUtility.h"
  10. #import "FLEXObjectExplorerFactory.h"
  11. @interface FLEXArrayExplorerViewController ()
  12. @property (nonatomic, readonly) NSArray *array;
  13. @end
  14. @implementation FLEXArrayExplorerViewController
  15. - (NSArray *)array
  16. {
  17. return [self.object isKindOfClass:[NSArray class]] ? self.object : nil;
  18. }
  19. #pragma mark - Superclass Overrides
  20. - (NSString *)customSectionTitle
  21. {
  22. return @"Array Indices";
  23. }
  24. - (NSArray *)customSectionRowCookies
  25. {
  26. // Use index numbers as the row cookies
  27. NSMutableArray *cookies = [NSMutableArray arrayWithCapacity:[self.array count]];
  28. for (NSUInteger i = 0; i < [self.array count]; i++) {
  29. [cookies addObject:@(i)];
  30. }
  31. return cookies;
  32. }
  33. - (NSString *)customSectionTitleForRowCookie:(id)rowCookie
  34. {
  35. return [rowCookie description];
  36. }
  37. - (NSString *)customSectionSubtitleForRowCookie:(id)rowCookie
  38. {
  39. return [FLEXRuntimeUtility descriptionForIvarOrPropertyValue:[self detailObjectForRowCookie:rowCookie]];
  40. }
  41. - (BOOL)customSectionCanDrillIntoRowWithCookie:(id)rowCookie
  42. {
  43. return YES;
  44. }
  45. - (UIViewController *)customSectionDrillInViewControllerForRowCookie:(id)rowCookie
  46. {
  47. return [FLEXObjectExplorerFactory explorerViewControllerForObject:[self detailObjectForRowCookie:rowCookie]];
  48. }
  49. - (BOOL)shouldShowDescription
  50. {
  51. return NO;
  52. }
  53. #pragma mark - Helpers
  54. - (id)detailObjectForRowCookie:(id)rowCookie
  55. {
  56. NSUInteger index = [rowCookie unsignedIntegerValue];
  57. return self.array[index];
  58. }
  59. @end