RATreeNodeInfo.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //The MIT License (MIT)
  2. //
  3. //Copyright (c) 2013 Rafał Augustyniak
  4. //
  5. //Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. //this software and associated documentation files (the "Software"), to deal in
  7. //the Software without restriction, including without limitation the rights to
  8. //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9. //the Software, and to permit persons to whom the Software is furnished to do so,
  10. //subject to the following conditions:
  11. //
  12. //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  14. //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  15. //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  16. //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  17. //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  18. //
  19. #import "RATreeNodeInfo.h"
  20. #import "RATreeNodeInfo+Private.h"
  21. #import "RATreeNode.h"
  22. @interface RATreeNodeInfo ()
  23. @property (nonatomic, getter = isExpanded, readwrite) BOOL expanded;
  24. @property (nonatomic, readwrite) NSInteger treeDepthLevel;
  25. @property (nonatomic, readwrite) NSInteger siblingsNumber;
  26. @property (nonatomic, readwrite) NSInteger positionInSiblings;
  27. @property (weak, nonatomic, readwrite) RATreeNodeInfo *parent;
  28. @property (strong, nonatomic, readwrite) NSArray *children;
  29. @property (strong, nonatomic, readwrite) RATreeNode *parentTreeNode;
  30. @property (strong, nonatomic, readwrite) NSArray * childrenTreeNodes;
  31. @property (strong, nonatomic, readwrite) id item;
  32. @end
  33. @implementation RATreeNodeInfo
  34. #pragma mark Properties
  35. - (RATreeNodeInfo *)parent
  36. {
  37. if (_parent == nil) {
  38. _parent = [self.parentTreeNode treeNodeInfo];
  39. }
  40. return _parent;
  41. }
  42. - (NSArray *)children
  43. {
  44. if (_children == nil) {
  45. NSMutableArray *treeNodesInfos = [NSMutableArray array];
  46. for (RATreeNode *treeNode in self.childrenTreeNodes) {
  47. [treeNodesInfos addObject:[treeNode treeNodeInfo]];
  48. }
  49. _children = treeNodesInfos;
  50. }
  51. return _children;
  52. }
  53. @end