motion-yapper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (348) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +5 -0
  5. data/Gemfile.lock +63 -0
  6. data/README.md +16 -0
  7. data/Rakefile +20 -0
  8. data/app/app_delegate.rb +5 -0
  9. data/lib/yapper.rb +30 -0
  10. data/lib/yapper/attachment.rb +48 -0
  11. data/lib/yapper/bson.rb +20 -0
  12. data/lib/yapper/config.rb +18 -0
  13. data/lib/yapper/db.rb +151 -0
  14. data/lib/yapper/document.rb +54 -0
  15. data/lib/yapper/document/attachment.rb +26 -0
  16. data/lib/yapper/document/callbacks.rb +86 -0
  17. data/lib/yapper/document/persistance.rb +171 -0
  18. data/lib/yapper/document/relation.rb +84 -0
  19. data/lib/yapper/document/selection.rb +100 -0
  20. data/lib/yapper/extensions.rb +80 -0
  21. data/lib/yapper/log.rb +5 -0
  22. data/lib/yapper/sync.rb +134 -0
  23. data/lib/yapper/sync/data.rb +12 -0
  24. data/lib/yapper/sync/event.rb +194 -0
  25. data/lib/yapper/sync/queue.rb +164 -0
  26. data/lib/yapper/timestamps.rb +16 -0
  27. data/lib/yapper/version.rb +3 -0
  28. data/lib/yapper/yapper.rb +2 -0
  29. data/spec/helpers/time_helper.rb +3 -0
  30. data/spec/integration/all_spec.rb +40 -0
  31. data/spec/integration/callback_spec.rb +87 -0
  32. data/spec/integration/db_spec.rb +40 -0
  33. data/spec/integration/find_spec.rb +51 -0
  34. data/spec/integration/persistance_spec.rb +118 -0
  35. data/spec/integration/relation_spec.rb +174 -0
  36. data/spec/integration/sync_spec.rb +42 -0
  37. data/spec/integration/timestamps_spec.rb +34 -0
  38. data/spec/integration/types_spec.rb +23 -0
  39. data/spec/integration/when_spec.rb +29 -0
  40. data/spec/integration/where_spec.rb +132 -0
  41. data/vendor/Podfile.lock +24 -0
  42. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +641 -0
  43. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +1396 -0
  44. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +133 -0
  45. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +327 -0
  46. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +113 -0
  47. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +321 -0
  48. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +71 -0
  49. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +150 -0
  50. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
  51. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +157 -0
  52. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +43 -0
  53. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +68 -0
  54. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +143 -0
  55. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +370 -0
  56. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +848 -0
  57. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +89 -0
  58. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +167 -0
  59. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +78 -0
  60. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +191 -0
  61. data/vendor/Pods/AFNetworking/LICENSE +19 -0
  62. data/vendor/Pods/AFNetworking/README.md +208 -0
  63. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +641 -0
  64. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +133 -0
  65. data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +113 -0
  66. data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +71 -0
  67. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
  68. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +43 -0
  69. data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +68 -0
  70. data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +370 -0
  71. data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +89 -0
  72. data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +78 -0
  73. data/vendor/Pods/BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
  74. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +41 -0
  75. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
  76. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +334 -0
  77. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +601 -0
  78. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +167 -0
  79. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
  80. data/vendor/Pods/BuildHeaders/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
  81. data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +109 -0
  82. data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +90 -0
  83. data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +20 -0
  84. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +547 -0
  85. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +447 -0
  86. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnectionState.h +29 -0
  87. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +37 -0
  88. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtension.h +15 -0
  89. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
  90. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
  91. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
  92. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +108 -0
  93. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
  94. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
  95. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
  96. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
  97. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
  98. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
  99. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
  100. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
  101. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseLogging.h +158 -0
  102. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseManager.h +17 -0
  103. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +424 -0
  104. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseQuery.h +42 -0
  105. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
  106. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
  107. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
  108. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
  109. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
  110. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseStatement.h +13 -0
  111. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseString.h +121 -0
  112. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +541 -0
  113. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +186 -0
  114. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +272 -0
  115. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
  116. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +115 -0
  117. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +825 -0
  118. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
  119. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +56 -0
  120. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPage.h +36 -0
  121. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
  122. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +153 -0
  123. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
  124. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
  125. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +447 -0
  126. data/vendor/Pods/BuildHeaders/YapDatabase/YapMemoryTable.h +74 -0
  127. data/vendor/Pods/BuildHeaders/YapDatabase/YapNull.h +17 -0
  128. data/vendor/Pods/BuildHeaders/YapDatabase/YapSet.h +41 -0
  129. data/vendor/Pods/BuildHeaders/YapDatabase/YapTouch.h +15 -0
  130. data/vendor/Pods/CocoaLumberjack/LICENSE.txt +18 -0
  131. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +41 -0
  132. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +99 -0
  133. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +102 -0
  134. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +727 -0
  135. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +334 -0
  136. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1353 -0
  137. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +601 -0
  138. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +1083 -0
  139. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +167 -0
  140. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1479 -0
  141. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
  142. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
  143. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
  144. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
  145. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +7 -0
  146. data/vendor/Pods/CocoaLumberjack/README.markdown +37 -0
  147. data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +641 -0
  148. data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +133 -0
  149. data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +113 -0
  150. data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +71 -0
  151. data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
  152. data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +43 -0
  153. data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +68 -0
  154. data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +370 -0
  155. data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +89 -0
  156. data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +78 -0
  157. data/vendor/Pods/Headers/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
  158. data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +41 -0
  159. data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
  160. data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +334 -0
  161. data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +601 -0
  162. data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +167 -0
  163. data/vendor/Pods/Headers/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
  164. data/vendor/Pods/Headers/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
  165. data/vendor/Pods/Headers/Reachability/Reachability.h +109 -0
  166. data/vendor/Pods/Headers/YapDatabase/YapCache.h +90 -0
  167. data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +20 -0
  168. data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +547 -0
  169. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +447 -0
  170. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +29 -0
  171. data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +37 -0
  172. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtension.h +15 -0
  173. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
  174. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
  175. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
  176. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +108 -0
  177. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
  178. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
  179. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
  180. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
  181. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
  182. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
  183. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
  184. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
  185. data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +158 -0
  186. data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +17 -0
  187. data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +424 -0
  188. data/vendor/Pods/Headers/YapDatabase/YapDatabaseQuery.h +42 -0
  189. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
  190. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
  191. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
  192. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
  193. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
  194. data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +13 -0
  195. data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +121 -0
  196. data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +541 -0
  197. data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +186 -0
  198. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +272 -0
  199. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
  200. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +115 -0
  201. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +825 -0
  202. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
  203. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +56 -0
  204. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +36 -0
  205. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
  206. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +153 -0
  207. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
  208. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
  209. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +447 -0
  210. data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +74 -0
  211. data/vendor/Pods/Headers/YapDatabase/YapNull.h +17 -0
  212. data/vendor/Pods/Headers/YapDatabase/YapSet.h +41 -0
  213. data/vendor/Pods/Headers/YapDatabase/YapTouch.h +15 -0
  214. data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +17 -0
  215. data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +5 -0
  216. data/vendor/Pods/Headers/____Pods-NSData+MD5Digest-prefix.h +5 -0
  217. data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +5 -0
  218. data/vendor/Pods/Headers/____Pods-YapDatabase-prefix.h +5 -0
  219. data/vendor/Pods/Headers/____Pods-environment.h +38 -0
  220. data/vendor/Pods/Manifest.lock +24 -0
  221. data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
  222. data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.m +39 -0
  223. data/vendor/Pods/NSData+MD5Digest/README.md +11 -0
  224. data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +5 -0
  225. data/vendor/Pods/Pods-AFNetworking-dummy.m +5 -0
  226. data/vendor/Pods/Pods-AFNetworking-prefix.pch +17 -0
  227. data/vendor/Pods/Pods-AFNetworking.xcconfig +1 -0
  228. data/vendor/Pods/Pods-Acknowledgements.markdown +96 -0
  229. data/vendor/Pods/Pods-Acknowledgements.plist +142 -0
  230. data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +5 -0
  231. data/vendor/Pods/Pods-CocoaLumberjack-dummy.m +5 -0
  232. data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +5 -0
  233. data/vendor/Pods/Pods-CocoaLumberjack.xcconfig +0 -0
  234. data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +5 -0
  235. data/vendor/Pods/Pods-NSData+MD5Digest-dummy.m +5 -0
  236. data/vendor/Pods/Pods-NSData+MD5Digest-prefix.pch +5 -0
  237. data/vendor/Pods/Pods-NSData+MD5Digest.xcconfig +0 -0
  238. data/vendor/Pods/Pods-Reachability-Private.xcconfig +5 -0
  239. data/vendor/Pods/Pods-Reachability-dummy.m +5 -0
  240. data/vendor/Pods/Pods-Reachability-prefix.pch +5 -0
  241. data/vendor/Pods/Pods-Reachability.xcconfig +1 -0
  242. data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +5 -0
  243. data/vendor/Pods/Pods-YapDatabase-dummy.m +5 -0
  244. data/vendor/Pods/Pods-YapDatabase-prefix.pch +5 -0
  245. data/vendor/Pods/Pods-YapDatabase.xcconfig +1 -0
  246. data/vendor/Pods/Pods-dummy.m +5 -0
  247. data/vendor/Pods/Pods-environment.h +38 -0
  248. data/vendor/Pods/Pods-resources.sh +68 -0
  249. data/vendor/Pods/Pods.bridgesupport +5096 -0
  250. data/vendor/Pods/Pods.xcconfig +5 -0
  251. data/vendor/Pods/Pods.xcodeproj/project.pbxproj +5536 -0
  252. data/vendor/Pods/Reachability/LICENCE.txt +24 -0
  253. data/vendor/Pods/Reachability/README.md +65 -0
  254. data/vendor/Pods/Reachability/Reachability.h +109 -0
  255. data/vendor/Pods/Reachability/Reachability.m +527 -0
  256. data/vendor/Pods/YapDatabase/LICENSE.txt +18 -0
  257. data/vendor/Pods/YapDatabase/README.md +30 -0
  258. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +19 -0
  259. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +108 -0
  260. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +175 -0
  261. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.h +12 -0
  262. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.m +41 -0
  263. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +39 -0
  264. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +966 -0
  265. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +69 -0
  266. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.h +89 -0
  267. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.m +146 -0
  268. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.h +32 -0
  269. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +298 -0
  270. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
  271. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.m +95 -0
  272. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.h +68 -0
  273. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +1352 -0
  274. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +440 -0
  275. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.h +15 -0
  276. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +58 -0
  277. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.h +11 -0
  278. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +46 -0
  279. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.h +11 -0
  280. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +180 -0
  281. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +73 -0
  282. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +100 -0
  283. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +149 -0
  284. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.h +33 -0
  285. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +330 -0
  286. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.h +33 -0
  287. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +184 -0
  288. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.h +58 -0
  289. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +1166 -0
  290. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewChangePrivate.h +94 -0
  291. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewMappingsPrivate.h +72 -0
  292. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.h +36 -0
  293. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.mm +296 -0
  294. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.h +27 -0
  295. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.m +28 -0
  296. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +153 -0
  297. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewRangeOptionsPrivate.h +17 -0
  298. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +272 -0
  299. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +2494 -0
  300. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +825 -0
  301. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +1567 -0
  302. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.h +330 -0
  303. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.m +141 -0
  304. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +186 -0
  305. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +191 -0
  306. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +115 -0
  307. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +897 -0
  308. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +56 -0
  309. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.m +27 -0
  310. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +447 -0
  311. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +4505 -0
  312. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +90 -0
  313. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +453 -0
  314. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.h +29 -0
  315. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.m +48 -0
  316. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +37 -0
  317. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +83 -0
  318. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.h +158 -0
  319. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.m +73 -0
  320. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.h +17 -0
  321. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.m +56 -0
  322. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +424 -0
  323. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.h +13 -0
  324. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.m +26 -0
  325. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseString.h +121 -0
  326. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.h +74 -0
  327. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.m +603 -0
  328. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.h +17 -0
  329. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +31 -0
  330. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.h +15 -0
  331. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.m +31 -0
  332. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +20 -0
  333. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +194 -0
  334. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.h +42 -0
  335. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.m +96 -0
  336. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.h +41 -0
  337. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.m +82 -0
  338. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +547 -0
  339. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +2022 -0
  340. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +447 -0
  341. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +3874 -0
  342. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +541 -0
  343. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +5282 -0
  344. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +16 -0
  345. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +13 -0
  346. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +20 -0
  347. data/yapper.gemspec +24 -0
  348. metadata +458 -0
@@ -0,0 +1,825 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import "YapDatabaseViewRangeOptions.h"
3
+
4
+ @class YapDatabaseReadTransaction;
5
+
6
+ /**
7
+ * Welcome to YapDatabase!
8
+ *
9
+ * https://github.com/yaptv/YapDatabase
10
+ *
11
+ * The project wiki has a wealth of documentation if you have any questions.
12
+ * https://github.com/yaptv/YapDatabase/wiki
13
+ *
14
+ * YapDatabaseView is an extension designed to work with YapDatabase.
15
+ * It gives you a persistent sorted "view" of a configurable subset of your data.
16
+ *
17
+ * For the full documentation on Views, please see the related wiki article:
18
+ * https://github.com/yaptv/YapDatabase/wiki/Views
19
+ *
20
+ * YapDatabaseViewMappings helps you map from groups to sections.
21
+ * Let's take a look at a concrete example:
22
+ *
23
+ * Say you have a database full of items for sale in a grocery store.
24
+ * You have a view which sorts the items alphabetically, grouped by department.
25
+ * There are many different departments (produce, bakery, dairy, wine, etc).
26
+ * But you want to display a table view that contains only a few departments: (wine, liquor, beer).
27
+ *
28
+ * This class allows you to specify that you want:
29
+ * - section 0 = wine
30
+ * - section 1 = liquor
31
+ * - section 2 = beer
32
+ *
33
+ * From this starting point, the class helps you map from section to group, and vice versa.
34
+ * Plus it can properly take into account empty sections. For example, if there are no items
35
+ * for sale in the liquor department then it can automatically move beer to section 1 (optional).
36
+ *
37
+ * But the primary purpose of this class has to do with assisting in animating changes to your view.
38
+ * In order to provide the proper animation instructions to your tableView or collectionView,
39
+ * the database layer needs to know a little about how you're setting things up.
40
+ *
41
+ * Using the example above, we might have code that looks something like this:
42
+ *
43
+ * - (void)viewDidLoad
44
+ * {
45
+ * // Freeze our connection for use on the main-thread.
46
+ * // This gives us a stable data-source that won't change until we tell it to.
47
+ *
48
+ * [databaseConnection beginLongLivedReadTransaction];
49
+ *
50
+ * // The view may have a whole bunch of groups.
51
+ * // In our example, the view contains a group for every department in the grocery store.
52
+ * // We only want to display the alcohol related sections in our tableView.
53
+ *
54
+ * NSArray *groups = @[@"wine", @"liquor", @"beer"];
55
+ * mappings = [[YapDatabaseViewMappings alloc] initWithGroups:groups view:@"order"];
56
+ *
57
+ * // There are several ways in which we can further configure the mappings.
58
+ * // You would configure it however you want.
59
+ *
60
+ * // ...
61
+ *
62
+ * // Now initialize the mappings.
63
+ * // This will allow the mappings object to get the counts per group.
64
+ *
65
+ * [databaseConnection readWithBlock:(YapDatabaseReadTransaction *transaction){
66
+ * // One-time initialization
67
+ * [mappings updateWithTransaction:transaction];
68
+ * }];
69
+ *
70
+ * // And register for notifications when the database changes.
71
+ * // Our method will be invoked on the main-thread,
72
+ * // and will allow us to move our stable data-source from our existing state to an updated state.
73
+ *
74
+ * [[NSNotificationCenter defaultCenter] addObserver:self
75
+ * selector:@selector(yapDatabaseModified:)
76
+ * name:YapDatabaseModifiedNotification
77
+ * object:databaseConnection.database];
78
+ * }
79
+ *
80
+ * - (void)yapDatabaseModified:(NSNotification *)notification
81
+ * {
82
+ * // End & Re-Begin the long-lived transaction atomically.
83
+ * // Also grab all the notifications for all the commits that I jump.
84
+ *
85
+ * NSArray *notifications = [databaseConnection beginLongLivedReadTransaction];
86
+ *
87
+ * // Process the notification(s),
88
+ * // and get the changeset as it applies to me, based on my view and my mappings setup.
89
+ *
90
+ * NSArray *sectionChanges = nil;
91
+ * NSArray *rowChanges = nil;
92
+ *
93
+ * [[databaseConnection ext:@"order"] getSectionChanges:&sectionChanges
94
+ * rowChanges:&rowChanges
95
+ * forNotifications:notifications
96
+ * withMappings:mappings];
97
+ *
98
+ * // No need to update mappings.
99
+ * // The above method did it automatically.
100
+ *
101
+ * if ([sectionChanges count] == 0 & [rowChanges count] == 0)
102
+ * {
103
+ * // Nothing has changed that affects our tableView
104
+ * return;
105
+ * }
106
+ *
107
+ * // Now it's time to process the changes.
108
+ * //
109
+ * // Note: Because we explicitly told the mappings to allowEmptySections,
110
+ * // there won't be any section changes. If we had instead set allowEmptySections to NO,
111
+ * // then there might be section deletions & insertions as sections become empty & non-empty.
112
+ *
113
+ * [self.tableView beginUpdates];
114
+ *
115
+ * for (YapDatabaseViewSectionChange *sectionChange in sectionChanges)
116
+ * {
117
+ * // ... (see https://github.com/yaptv/YapDatabase/wiki/Views )
118
+ * }
119
+ *
120
+ * for (YapDatabaseViewRowChange *rowChange in rowChanges)
121
+ * {
122
+ * // ... (see https://github.com/yaptv/YapDatabase/wiki/Views )
123
+ * }
124
+ *
125
+ * [self.tableView endUpdates];
126
+ * }
127
+ *
128
+ * - (NSInteger)numberOfSectionsInTableView:(UITableView *)sender
129
+ * {
130
+ * // We can use the cached information in the mappings object.
131
+ * //
132
+ * // This comes in handy if my sections are dynamic,
133
+ * // and automatically come and go as individual sections become empty & non-empty.
134
+ *
135
+ * return [mappings numberOfSections];
136
+ * }
137
+ *
138
+ * - (NSInteger)tableView:(UITableView *)sender numberOfRowsInSection:(NSInteger)section
139
+ * {
140
+ * // We can use the cached information in the mappings object.
141
+ *
142
+ * return [mappings numberOfItemsInSection:section];
143
+ * }
144
+ *
145
+ * - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
146
+ * {
147
+ * // If my sections are dynamic (they automatically come and go as individual sections become empty & non-empty),
148
+ * // then I can easily use the mappings object to find the appropriate group.
149
+ *
150
+ * NSString *group = [mappings groupForSection:indexPath.section];
151
+ *
152
+ * __block id object = nil;
153
+ * [databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction){
154
+ *
155
+ * object = [[transaction ext:@"view"] objectAtIndex:indexPath.row inGroup:group];
156
+ * }];
157
+ *
158
+ * // configure and return cell...
159
+ * }
160
+ *
161
+ * @see YapDatabaseConnection getSectionChanges:rowChanges:forNotifications:withMappings:
162
+ **/
163
+
164
+ /**
165
+ * The YapDatabaseViewRangePosition struct represents the range window within the full group.
166
+ * @see rangePositionForGroup:
167
+ **/
168
+ struct YapDatabaseViewRangePosition {
169
+ NSUInteger offsetFromBeginning;
170
+ NSUInteger offsetFromEnd;
171
+ NSUInteger length;
172
+
173
+ };
174
+ typedef struct YapDatabaseViewRangePosition YapDatabaseViewRangePosition;
175
+
176
+
177
+ @interface YapDatabaseViewMappings : NSObject <NSCopying>
178
+
179
+ /**
180
+ * Initializes a new mappings object.
181
+ *
182
+ * @param allGroups
183
+ * The ordered array of group names.
184
+ * From the example above, this would be @[ @"wine", @"liquor", @"beer" ]
185
+ *
186
+ * @param registeredViewName
187
+ * This is the name of the view, as you registered it with the database system.
188
+ **/
189
+ + (instancetype)mappingsWithGroups:(NSArray *)allGroups view:(NSString *)registeredViewName;
190
+
191
+ /**
192
+ * Initializes a new mappings object.
193
+ *
194
+ * @param allGroups
195
+ * The ordered array of group names.
196
+ * From the example above, this would be @[ @"wine", @"liquor", @"beer" ]
197
+ *
198
+ * @param registeredViewName
199
+ * This is the name of the view, as you registered it with the database system.
200
+ *
201
+ *
202
+ **/
203
+ - (id)initWithGroups:(NSArray *)allGroups
204
+ view:(NSString *)registeredViewName;
205
+
206
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
207
+ #pragma mark Accessors
208
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
209
+
210
+ /**
211
+ * The allGroups property returns the groups that were passed in the init method.
212
+ * That is, all groups, whether currently visible or non-visible.
213
+ *
214
+ * @see visibleGroups
215
+ **/
216
+ @property (nonatomic, copy, readonly) NSArray *allGroups;
217
+
218
+ /**
219
+ * The registeredViewName that was passed in the init method.
220
+ **/
221
+ @property (nonatomic, copy, readonly) NSString *view;
222
+
223
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
224
+ #pragma mark Configuration
225
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
226
+
227
+ /**
228
+ * A group/section can either be "static" or "dynamic".
229
+ *
230
+ * A dynamic section automatically disappears if it becomes empty.
231
+ * A static section is always visible, regardless of its item count.
232
+ *
233
+ * By default all groups/sections are static.
234
+ * You can enable dynamic sections on a per-group basis (just for certain sections) or for all groups (all sections).
235
+ *
236
+ * If you enable dynamic sections, be sure to use the helper methods available in this class.
237
+ * This will drastically simplify things for you.
238
+ * For example:
239
+ *
240
+ * Let's say you have 3 groups: @[ @"wine", @"liquor", @"beer" ]
241
+ * You've enabled dynamic sections for all groups.
242
+ * Section 0 refers to what group?
243
+ *
244
+ * The answer depends entirely on the item count per section.
245
+ * If "wine" is empty, but "liquor" isn't, then section zero is "liquor".
246
+ * If "wine" and "liquor" are empty, but "beer" isn't, then section zero is "beer".
247
+ *
248
+ * But you can simply do this to get the answer:
249
+ *
250
+ * NSString *group = [mappings groupForSection:indexPath.section];
251
+ *
252
+ * @see numberOfSections
253
+ * @see groupForSection:
254
+ * @see visibleGroups
255
+ *
256
+ * The mappings object is used with:
257
+ *
258
+ * - YapDatabaseViewConnection getSectionChanges:rowChanges:forNotifications:withMappings:
259
+ *
260
+ * If all your sections are static, then you won't ever get any section changes.
261
+ * But if you have one or more dynamic sections, then be sure to process the section changes.
262
+ * As the dynamic sections disappear & re-appear, the proper section changes will be emitted.
263
+ *
264
+ * By DEFAULT, all groups/sections are STATIC.
265
+ * You can configure this per group, or all-at-once.
266
+ **/
267
+
268
+ - (void)setIsDynamicSectionForAllGroups:(BOOL)isDynamic;
269
+ - (BOOL)isDynamicSectionForAllGroups;
270
+
271
+ - (void)setIsDynamicSection:(BOOL)isDynamic forGroup:(NSString *)group;
272
+ - (BOOL)isDynamicSectionForGroup:(NSString *)group;
273
+
274
+ /**
275
+ * You can use the YapDatabaseViewRangeOptions class to configure a "range" that you would
276
+ * like to restrict your tableView / collectionView to.
277
+ *
278
+ * Two types of ranges are supported:
279
+ *
280
+ * 1. Fixed ranges.
281
+ * This is similar to using a LIMIT & OFFSET in a typical sql query.
282
+ *
283
+ * 2. Flexible ranges.
284
+ * These allow you to specify an initial range, and allow it to grow and shrink.
285
+ *
286
+ * The YapDatabaseViewRangeOptions header file has a lot of documentation on
287
+ * setting up and configuring range options.
288
+ *
289
+ * One of the best parts of using rangeOptions is that you get animations for free.
290
+ * For example:
291
+ *
292
+ * Say you have view that sorts items by sales rank.
293
+ * You want to display a tableView that displays the top 20 best-sellers. Simple enough so far.
294
+ * But you want the tableView to automatically update throughout the day as sales are getting processed.
295
+ * And you want the tableView to automatically animate any changes. (No wimping out with reloadData!)
296
+ * You can get this with only a few lines of code using range options.
297
+ *
298
+ * Note that if you're using range options, then the indexPaths in your UI might not match up directly
299
+ * with the indexes in the view's group. No worries. You can use the various mapping methods in this class
300
+ * to automatically handle all that for you.
301
+ *
302
+ * @see getGroup:viewIndex:forIndexPath:
303
+ * @see viewIndexForRow:inSection:
304
+ * @see viewIndexForRow:inGroup:
305
+ *
306
+ * The rangeOptions you pass in are copied, and YapDatabaseViewMappings keeps a private immutable version of them.
307
+ * So if you make changes to the rangeOptions, you need to invoke this method again to set the changes.
308
+ **/
309
+
310
+ - (void)setRangeOptions:(YapDatabaseViewRangeOptions *)rangeOpts forGroup:(NSString *)group;
311
+ - (YapDatabaseViewRangeOptions *)rangeOptionsForGroup:(NSString *)group;
312
+
313
+ - (void)removeRangeOptionsForGroup:(NSString *)group;
314
+
315
+ /**
316
+ * There are some times when the drawing of one cell depends somehow on a neighboring cell.
317
+ * For example:
318
+ *
319
+ * Apple's SMS messaging app draws a timestamp if more than a certain amount of time has elapsed
320
+ * between a message and the previous message. The timestamp is actually drawn at the top of a cell.
321
+ * So cell-B would draw a timestamp at the top of its cell if cell-A represented a message
322
+ * that was sent/received say 3 hours ago.
323
+ *
324
+ * We refer to this as a "cell drawing dependency". For the example above, the timestamp drawing is dependent
325
+ * upon the cell at offset -1. That is, the drawing of cell at index 5 is dependent upon the cell at index (5-1).
326
+ *
327
+ * This method allows you to specify if there are cell drawing dependecies.
328
+ * For the example above you could simply do the following:
329
+ *
330
+ * [mappings setCellDrawingDependencyForNeighboringCellWithOffset:-1 forGroup:@""]
331
+ *
332
+ * This will inject extra YapDatabaseViewChangeUpdate's for cells that may have been affected by
333
+ * other Insert/Delete/Update/Move operations (and thus need to be redrawn).
334
+ *
335
+ * Continuing the example above, if the item at index 7 is deleted, then changeset processing will automatically emit
336
+ * and update change for the item that was previously at index 8. This is because, as specified by the "cell drawing
337
+ * offset" configuration, the drawing of index 8 was dependent upon the item before it (offset=-1). The item
338
+ * before it has changed, so it gets an update emitted for it automatically.
339
+ *
340
+ * Using this configuration makes it exteremely simple to handle various "cell drawing dependencies".
341
+ * You can just ask for changesets as you would if there weren't any dependencies,
342
+ * perform the boiler-plate updates, and everything just works.
343
+ *
344
+ * Note that if a YapDatabaseViewChangeUpdate is emitted due to a cell drawing dependeny,
345
+ * AND there were no actual updates for the corresponding item,
346
+ * and you'd like to detect these changes for whatever reason (optimizing, etc),
347
+ * then you can do so by checking to see if the rowChange.changes == YapDatabaseViewChangedDependency.
348
+ *
349
+ * If you have multiple cell drawing dependencies (e.g. +1 & -1),
350
+ * then you can pass in an NSSet of NSNumbers.
351
+ **/
352
+
353
+ - (void)setCellDrawingDependencyForNeighboringCellWithOffset:(NSInteger)offset forGroup:(NSString *)group;
354
+
355
+ - (void)setCellDrawingDependencyOffsets:(NSSet *)offsets forGroup:(NSString *)group;
356
+ - (NSSet *)cellDrawingDependencyOffsetsForGroup:(NSString *)group;
357
+
358
+ /**
359
+ * You can tell mappings to reverse a group/section if you'd like to display it in your tableView/collectionView
360
+ * in the opposite direction in which the items actually exist within the database.
361
+ *
362
+ * For example:
363
+ *
364
+ * You have a database view which sorts items by sales rank. The best-selling item is at index 0.
365
+ * Sometimes you use the view to display the top 20 best-selling items.
366
+ * But other times you use the view to display the worst-selling items (perhaps to dump these items in order
367
+ * to make room for new inventory). You want to display the worst-selling item at index 0.
368
+ * And the second worst-selling item at index 1. Etc.
369
+ * This happens to be the opposite sorting order from how the items are in stored in the database.
370
+ * So you simply use the reverse option in mappings to handle the math for you.
371
+ *
372
+ * It's important to understand the relationship between reversing a group and the other mapping options
373
+ * (such as ranges and cell-drawing-dependencies):
374
+ *
375
+ * Once you reverse a group (setIsReversed:YES forGroup:group) you can visualize the view as reversed in your head,
376
+ * and set all other mappings options as if it was actually reversed.
377
+ *
378
+ * >>>>> ORDER MATTERS <<<<<
379
+ *
380
+ * To be more precise:
381
+ *
382
+ * - After reversing a group, you can pass in rangeOptions as if the group were actually reversed in the database.
383
+ * This makes it easier to configure, as your mental model can match how you configure it.
384
+ *
385
+ * rangeOptions = [YapDatabaseViewRangeOptions fixedRangeWithLength:20 offset:0 from:YapDatabaseViewEnd];
386
+ * [mappings setRangeOptions:rangeOptions forGroup:@"books"];
387
+ * [mappings setIsReversed:YES forGroup:@"books"];
388
+ *
389
+ * is EQUIVALENT to:
390
+ *
391
+ * [mappings setIsReversed:YES forGroup:@"books"];
392
+ * rangeOptions = [YapDatabaseViewRangeOptions fixedRangeWithLength:20 offset:0 from:YapDatabaseViewBeginning];
393
+ * [mappings setRangeOptions:rangeOptions forGroup:@"books"];
394
+ *
395
+ * - In terms of cell-drawing-dependencies, its a similar effect.
396
+ *
397
+ * [mappings setCellDrawingDependencyForNeighboringCellWithOffset:+1 forGroup:@"books"]; // <-- Positive one
398
+ * [mappings setIsReversed:YES forGroup:@"books"];
399
+ *
400
+ * is EQUIVALENT to:
401
+ *
402
+ * [mappings setCellDrawingDependencyForNeighboringCellWithOffset:-1 forGroup:@"books"]; // <-- Negative one
403
+ * [mappings setIsReversed:YES forGroup:@"books"];
404
+ *
405
+ *
406
+ * In general, if you wish to visualize other configuration options in terms of how they're going to be displayed
407
+ * in your user interface, you should reverse the group BEFORE you make other configuration changes.
408
+ * Alternatively you might visualize it differently. Perhaps you're imaging the database view, applying
409
+ * range options first, and then reversing the final product for dispaly in a tableView.
410
+ * So in this case you should reverse the group AFTER you make other configuration changes.
411
+ *
412
+ * It's simply a matter of how you visualize it.
413
+ * Either order is fine, but one likely makes more sense in your head.
414
+ **/
415
+
416
+ - (void)setIsReversed:(BOOL)isReversed forGroup:(NSString *)group;
417
+ - (BOOL)isReversedForGroup:(NSString *)group;
418
+
419
+ /**
420
+ * This configuration allows you to take multiple groups in a database view,
421
+ * and display them in a single section in your tableView / collectionView.
422
+ *
423
+ * It's called a "consolidated group".
424
+ *
425
+ * Further, you can configure a threshold where the mappings will automatically switch between
426
+ * using a "consolidated group" and normal mode.
427
+ *
428
+ * This is useful for those situations where the total number of items in your tableView
429
+ * could be very small or very big. When the count is small, you don't want to use sections.
430
+ * But when the count reaches a certain size, you do want to use sections.
431
+ * For these situations, you can configure the threshold to meet your requirements,
432
+ * and mappings will automatically handle everything for you.
433
+ * Including animating the changes when switching back and forth between consolidated mode and normal mode.
434
+ *
435
+ * The threshold represents the point at which the transition occurs. That is:
436
+ * - if the total number of items is less than the threshold, then consolidated mode will be used.
437
+ * - if the total number of items is equal or greater than the threshold, then normal mode will be used.
438
+ *
439
+ * If the threshold is 0, then auto consolidation is disabled.
440
+ *
441
+ * For example, imagine you're displaying a list of contacts.
442
+ * You might setup a view like this:
443
+ *
444
+ * view = @{
445
+ * @"A" : @[ @"Allison Jones" ],
446
+ * @"B" : @[ @"Billy Bob", @"Brandon Allen" ],
447
+ * @"R" : @[ @"Ricky Bobby" ]
448
+ * }
449
+ *
450
+ * The total number of contacts is only 4. So it might look better to display them without sections.
451
+ * However, you're going to want to switch to sections at some point. Perhaps when the total count reaches 10?
452
+ *
453
+ * It would be nice if there was something to handle this for you.
454
+ * And even better if that something would help you properly animate the tableView
455
+ * when switching between no-sections & sections (and vice versa).
456
+ * This is exactly what the autoConsolidateGroupsThreshold does for you!
457
+ *
458
+ * The default threshold value is 0 (disabled).
459
+ **/
460
+
461
+ - (void)setAutoConsolidateGroupsThreshold:(NSUInteger)threshold withName:(NSString *)consolidatedGroupName;
462
+ - (NSUInteger)autoConsolidateGroupsThreshold;
463
+ - (NSString *)consolidatedGroupName;
464
+
465
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
466
+ #pragma mark Initialization & Updates
467
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
468
+
469
+ /**
470
+ * You have to call this method to initialize the mappings.
471
+ * This method uses the given transaction to fetch and cache the counts for each group.
472
+ *
473
+ * This class is designed to be used with the method getSectionChanges:rowChanges:forNotifications:withMappings:.
474
+ * That method needs the 'before' & 'after' snapshot of the mappings in order to calculate the proper changeset.
475
+ * In order to get this, it automatically invokes this method.
476
+ *
477
+ * Thus you only have to manually invoke this method once.
478
+ * Aftewards, it should be invoked for you.
479
+ *
480
+ * Please see the example code above.
481
+ **/
482
+ - (void)updateWithTransaction:(YapDatabaseReadTransaction *)transaction;
483
+
484
+ /**
485
+ * Returns the snapshot of the last time the mappings were initialized/updated.
486
+ *
487
+ * This method is primarily for internal use.
488
+ * When the changesets are being calculated from the notifications & mappings,
489
+ * this property is consulted to ensure the mappings match the notifications.
490
+ *
491
+ * Everytime the updateWithTransaction method is invoked,
492
+ * this property will be set to transaction.abstractConnection.snapshot.
493
+ *
494
+ * If never initialized/updated, the snapshot will be UINT64_MAX.
495
+ *
496
+ * @see YapDatabaseConnection snapshot
497
+ **/
498
+ @property (nonatomic, readonly) uint64_t snapshotOfLastUpdate;
499
+
500
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
501
+ #pragma mark Getters
502
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
503
+
504
+ /**
505
+ * Returns the actual number of visible sections.
506
+ *
507
+ * This number may be less than the original count of groups passed in the init method.
508
+ * That is, if dynamic sections are enabled for one or more groups, and some of these groups have zero items,
509
+ * then those groups will be removed from the visible list of groups. And thus the section count may be less.
510
+ **/
511
+ - (NSUInteger)numberOfSections;
512
+
513
+ /**
514
+ * Returns the number of items in the given section.
515
+ * @see groupForSection
516
+ **/
517
+ - (NSUInteger)numberOfItemsInSection:(NSUInteger)section;
518
+
519
+ /**
520
+ * Returns the number of items in the given group.
521
+ *
522
+ * This is the cached value from the last time one of the following methods was invoked:
523
+ * - updateWithTransaction:
524
+ * - changesForNotifications:withMappings:
525
+ **/
526
+ - (NSUInteger)numberOfItemsInGroup:(NSString *)group;
527
+
528
+ /**
529
+ * The visibleGroups property returns the current sections setup.
530
+ * That is, it only contains the visible groups that are being represented as sections in the view.
531
+ *
532
+ * If all sections are static, then visibleGroups will always be the same as allGroups.
533
+ * However, if one or more sections are dynamic, then the visible groups may be a subset of allGroups.
534
+ *
535
+ * Dynamic groups/sections automatically "disappear" if/when they become empty.
536
+ **/
537
+ - (NSArray *)visibleGroups;
538
+
539
+ /**
540
+ * Returns YES if there are zero items in all sections/groups.
541
+ **/
542
+ - (BOOL)isEmpty;
543
+
544
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
545
+ #pragma mark Mapping: UI -> View
546
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
547
+
548
+ /**
549
+ * Maps from a section (in the UI) to a group (in the View).
550
+ *
551
+ * Returns the group for the given section.
552
+ * This method properly takes into account dynamic groups.
553
+ *
554
+ * If the section is out-of-bounds, returns nil.
555
+ **/
556
+ - (NSString *)groupForSection:(NSUInteger)section;
557
+
558
+ /**
559
+ * Maps from an indexPath (in the UI) to a group & index (within the View).
560
+ *
561
+ * When your UI doesn't exactly match up with the View in the database, this method does all the math for you.
562
+ *
563
+ * For example, if using rangeOptions, the rows in your tableView/collectionView may not
564
+ * directly match the index in the corresponding view & group (in the database).
565
+ *
566
+ * For example, say a view in the database has a group named "elders" and contains 100 items.
567
+ * A fixed range is used to display only the last 20 items in the "elders" group (the 20 oldest elders).
568
+ * Thus row zero in the tableView is actually index 80 in the "elders" group.
569
+ *
570
+ * So you pass in an indexPath or row & section from the UI perspective,
571
+ * and it spits out the corresponding index within the database view's group.
572
+ *
573
+ * Code sample:
574
+ *
575
+ * - (UITableViewCell *)tableView:(UITableView *)sender cellForRowAtIndexPath:(NSIndexPath *)indexPath
576
+ * {
577
+ * NSString *group = nil;
578
+ * NSUInteger groupIndex = 0;
579
+ *
580
+ * [mappings getGroup:&group index:&groupIndex forIndexPath:indexPath];
581
+ *
582
+ * __block Elder *elder = nil;
583
+ * [databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
584
+ *
585
+ * elder = [[transaction extension:@"elders"] objectAtIndex:groupIndex inGroup:group];
586
+ * }];
587
+ *
588
+ * // configure and return cell...
589
+ * }
590
+ **/
591
+ - (BOOL)getGroup:(NSString **)groupPtr index:(NSUInteger *)indexPtr forIndexPath:(NSIndexPath *)indexPath;
592
+
593
+ /**
594
+ * Maps from an indexPath (in the UI) to a group & index (within the View).
595
+ *
596
+ * When your UI doesn't exactly match up with the View in the database, this method does all the math for you.
597
+ *
598
+ * For example, if using rangeOptions, the rows in your tableView/collectionView may not
599
+ * directly match the index in the corresponding view & group (in the database).
600
+ *
601
+ * For example, say a view in the database has a group named "elders" and contains 100 items.
602
+ * A fixed range is used to display only the last 20 items in the "elders" group (the 20 oldest elders).
603
+ * Thus row zero in the tableView is actually index 80 in the "elders" group.
604
+ *
605
+ * So you pass in an indexPath or row & section from the UI perspective,
606
+ * and it spits out the corresponding index within the database view's group.
607
+ *
608
+ * Code sample:
609
+ *
610
+ * - (UITableViewCell *)tableView:(UITableView *)sender cellForRowAtIndexPath:(NSIndexPath *)indexPath
611
+ * {
612
+ * NSString *group = nil;
613
+ * NSUInteger groupIndex = 0;
614
+ *
615
+ * [mappings getGroup:&group index:&groupIndex forIndexPath:indexPath];
616
+ *
617
+ * __block Elder *elder = nil;
618
+ * [databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
619
+ *
620
+ * elder = [[transaction extension:@"elders"] objectAtIndex:groupIndex inGroup:group];
621
+ * }];
622
+ *
623
+ * // configure and return cell...
624
+ * }
625
+ **/
626
+ - (BOOL)getGroup:(NSString **)groupPtr
627
+ index:(NSUInteger *)indexPtr
628
+ forRow:(NSUInteger)row
629
+ inSection:(NSUInteger)section;
630
+
631
+ /**
632
+ * Maps from a row & section (in the UI) to an index (within the View).
633
+ *
634
+ * This method is shorthand for getGroup:index:forIndexPath: when you already know the group.
635
+ * @see getGroup:index:forIndexPath:
636
+ *
637
+ * Returns NSNotFound if the given row & section are invalid.
638
+ **/
639
+ - (NSUInteger)indexForRow:(NSUInteger)row inSection:(NSUInteger)section;
640
+
641
+ /**
642
+ * Maps from a row & section (in the UI) to an index (within the View).
643
+ *
644
+ * This method is shorthand for getGroup:index:forIndexPath: when you already know the group.
645
+ * @see getGroup:index:forIndexPath:
646
+ *
647
+ * Returns NSNotFound if the given row & group are invalid.
648
+ **/
649
+ - (NSUInteger)indexForRow:(NSUInteger)row inGroup:(NSString *)group;
650
+
651
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
652
+ #pragma mark Mapping: View -> UI
653
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
654
+
655
+ /**
656
+ * Maps from a group (in the View) to the corresponding section (in the UI).
657
+ *
658
+ * Returns the visible section number for the visible group.
659
+ * Returns NSNotFound if the group is NOT visible (or invalid).
660
+ **/
661
+ - (NSUInteger)sectionForGroup:(NSString *)group;
662
+
663
+ /**
664
+ * Maps from an index & group (in the View) to the corresponding row & section (in the UI).
665
+ *
666
+ * Returns YES if the proper row & section were found.
667
+ * Returns NO if the given index is NOT visible (or out-of-bounds).
668
+ * Returns NO if the given group is NOT visible (or invalid).
669
+ **/
670
+ - (BOOL)getRow:(NSUInteger *)rowPtr
671
+ section:(NSUInteger *)sectionPtr
672
+ forIndex:(NSUInteger)index
673
+ inGroup:(NSString *)group;
674
+
675
+ /**
676
+ * Maps from an index & group (in the View) to the corresponding indexPath (in the UI).
677
+ *
678
+ * Returns the indexPath with the proper section and row.
679
+ * Returns nil if the given index & group is NOT visible (or out-of-bounds).
680
+ **/
681
+ - (NSIndexPath *)indexPathForIndex:(NSUInteger)index inGroup:(NSString *)group;
682
+
683
+ /**
684
+ * Maps from an index & group (in the View) to the corresponding row (in the UI).
685
+ *
686
+ * This method is shorthand for getRow:section:forIndex:inGroup: when you already know the section.
687
+ * @see getRow:section:forIndex:inGroup:
688
+ *
689
+ * Returns NSNotFound if the given index & group is NOT visible (or out-of-bounds).
690
+ **/
691
+ - (NSUInteger)rowForIndex:(NSUInteger)index inGroup:(NSString *)group;
692
+
693
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
694
+ #pragma mark Getters + Consolidation
695
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
696
+
697
+ /**
698
+ * Whether or not the groups have been automatically consolidated due to the configured autoConsolidateGroupsThreshold.
699
+ **/
700
+ - (BOOL)isUsingConsolidatedGroup;
701
+
702
+ /**
703
+ * Returns the total number of items by summing up the totals across all groups.
704
+ **/
705
+ - (NSUInteger)numberOfItemsInAllGroups;
706
+
707
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
708
+ #pragma mark Getters + Utilities
709
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
710
+
711
+ /**
712
+ * The YapDatabaseViewRangePosition struct represents the range window within the full group.
713
+ * For example:
714
+ *
715
+ * You have a section in your tableView which represents a group that contains 100 items.
716
+ * However, you've setup rangeOptions to only display the first 20 items:
717
+ *
718
+ * YapDatabaseViewRangeOptions *rangeOptions =
719
+ * [YapDatabaseViewRangeOptions fixedRangeWithLength:20 offset:0 from:YapDatabaseViewBeginning];
720
+ * [mappings setRangeOptions:rangeOptions forGroup:@"sales"];
721
+ *
722
+ * The corresponding rangePosition would be: (YapDatabaseViewRangePosition){
723
+ * .offsetFromBeginning = 0,
724
+ * .offsetFromEnd = 80,
725
+ * .length = 20
726
+ * }
727
+ **/
728
+ - (YapDatabaseViewRangePosition)rangePositionForGroup:(NSString *)group;
729
+
730
+ /**
731
+ * This is a helper method to assist in maintaining the selection while updating the tableView/collectionView.
732
+ * In general the idea is this:
733
+ * - yapDatabaseModified is invoked on the main thread
734
+ * - at the beginning of the method, you grab some information about the current selection
735
+ * - you update the database connection, and then start the animation for the changes to the table
736
+ * - you reselect whatever was previously selected
737
+ * - if that's not possible (row was deleted) then you select the closest row to the previous selection
738
+ *
739
+ * The last step isn't always what you want to do. Maybe you don't want to select anything at that point.
740
+ * But if you do, then this method can simplify the task for you.
741
+ *
742
+ * For example:
743
+ *
744
+ * - (void)yapDatabaseModified:(NSNotification *)notification {
745
+ *
746
+ * // Grab info about current selection
747
+ *
748
+ * NSString *selectedGroup = nil;
749
+ * NSUInteger selectedRow = 0;
750
+ * __block NSString *selectedWidgetId = nil;
751
+ *
752
+ * NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
753
+ * if (selectedIndexPath) {
754
+ * selectedGroup = [mappings groupForSection:selectedIndexPath.section];
755
+ * selectedRow = selectedIndexPath.row;
756
+ *
757
+ * [databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
758
+ * selectedWidgetId = [[transaction ext:@"widgets"] keyAtIndex:selectedRow inGroup:selectedGroup];
759
+ * }];
760
+ * }
761
+ *
762
+ * // Update the database connection (move it to the latest commit)
763
+ *
764
+ * NSArray *notifications = [databaseConnection beginLongLivedReadTransaction];
765
+ *
766
+ * // Process the notification(s),
767
+ * // and get the changeset as it applies to me, based on my view and my mappings setup.
768
+ *
769
+ * NSArray *sectionChanges = nil;
770
+ * NSArray *rowChanges = nil;
771
+ *
772
+ * [[databaseConnection ext:@"order"] getSectionChanges:&sectionChanges
773
+ * rowChanges:&rowChanges
774
+ * forNotifications:notifications
775
+ * withMappings:mappings];
776
+ *
777
+ * if ([sectionChanges count] == 0 & [rowChanges count] == 0)
778
+ * {
779
+ * // Nothing has changed that affects our tableView
780
+ * return;
781
+ * }
782
+ *
783
+ * // Update the table (animating the changes)
784
+ *
785
+ * [self.tableView beginUpdates];
786
+ *
787
+ * for (YapDatabaseViewSectionChange *sectionChange in sectionChanges)
788
+ * {
789
+ * // ... (see https://github.com/yaptv/YapDatabase/wiki/Views )
790
+ * }
791
+ *
792
+ * for (YapDatabaseViewRowChange *rowChange in rowChanges)
793
+ * {
794
+ * // ... (see https://github.com/yaptv/YapDatabase/wiki/Views )
795
+ * }
796
+ *
797
+ * [self.tableView endUpdates];
798
+ *
799
+ * // Try to reselect whatever was selected before
800
+ *
801
+ * __block NSIndexPath *indexPath = nil;
802
+ *
803
+ * if (selectedIndexPath) {
804
+ * [databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
805
+ * indexPath = [[transaction ext:@"widgets"] indexPathForKey:selectedWidgetId
806
+ * withMappings:mappings];
807
+ * }];
808
+ * }
809
+ *
810
+ * // Otherwise select the nearest row to whatever was selected before
811
+ *
812
+ * if (!indexPath && selectedGroup) {
813
+ * indexPath = [mappings nearestIndexPathForRow:selectedRow inGroup:selectedGroup];
814
+ * }
815
+ *
816
+ * if (indexPath) {
817
+ * [self.tableView selectRowAtIndexPath:indexPath
818
+ * animated:NO
819
+ * scrollPosition:UITableViewScrollPositionMiddle];
820
+ * }
821
+ * }
822
+ **/
823
+ - (NSIndexPath *)nearestIndexPathForRow:(NSUInteger)row inGroup:(NSString *)group;
824
+
825
+ @end