motion-yapper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +6 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +63 -0
- data/README.md +16 -0
- data/Rakefile +20 -0
- data/app/app_delegate.rb +5 -0
- data/lib/yapper.rb +30 -0
- data/lib/yapper/attachment.rb +48 -0
- data/lib/yapper/bson.rb +20 -0
- data/lib/yapper/config.rb +18 -0
- data/lib/yapper/db.rb +151 -0
- data/lib/yapper/document.rb +54 -0
- data/lib/yapper/document/attachment.rb +26 -0
- data/lib/yapper/document/callbacks.rb +86 -0
- data/lib/yapper/document/persistance.rb +171 -0
- data/lib/yapper/document/relation.rb +84 -0
- data/lib/yapper/document/selection.rb +100 -0
- data/lib/yapper/extensions.rb +80 -0
- data/lib/yapper/log.rb +5 -0
- data/lib/yapper/sync.rb +134 -0
- data/lib/yapper/sync/data.rb +12 -0
- data/lib/yapper/sync/event.rb +194 -0
- data/lib/yapper/sync/queue.rb +164 -0
- data/lib/yapper/timestamps.rb +16 -0
- data/lib/yapper/version.rb +3 -0
- data/lib/yapper/yapper.rb +2 -0
- data/spec/helpers/time_helper.rb +3 -0
- data/spec/integration/all_spec.rb +40 -0
- data/spec/integration/callback_spec.rb +87 -0
- data/spec/integration/db_spec.rb +40 -0
- data/spec/integration/find_spec.rb +51 -0
- data/spec/integration/persistance_spec.rb +118 -0
- data/spec/integration/relation_spec.rb +174 -0
- data/spec/integration/sync_spec.rb +42 -0
- data/spec/integration/timestamps_spec.rb +34 -0
- data/spec/integration/types_spec.rb +23 -0
- data/spec/integration/when_spec.rb +29 -0
- data/spec/integration/where_spec.rb +132 -0
- data/vendor/Podfile.lock +24 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +1396 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +327 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +321 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +150 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +157 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +143 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +848 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +167 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +191 -0
- data/vendor/Pods/AFNetworking/LICENSE +19 -0
- data/vendor/Pods/AFNetworking/README.md +208 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/BuildHeaders/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +109 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/CocoaLumberjack/LICENSE.txt +18 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +99 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +727 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1353 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +601 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +1083 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1479 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +7 -0
- data/vendor/Pods/CocoaLumberjack/README.markdown +37 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/Headers/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/Headers/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/Headers/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Headers/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/Headers/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/Headers/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +17 -0
- data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-NSData+MD5Digest-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-YapDatabase-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-environment.h +38 -0
- data/vendor/Pods/Manifest.lock +24 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.m +39 -0
- data/vendor/Pods/NSData+MD5Digest/README.md +11 -0
- data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-AFNetworking-dummy.m +5 -0
- data/vendor/Pods/Pods-AFNetworking-prefix.pch +17 -0
- data/vendor/Pods/Pods-AFNetworking.xcconfig +1 -0
- data/vendor/Pods/Pods-Acknowledgements.markdown +96 -0
- data/vendor/Pods/Pods-Acknowledgements.plist +142 -0
- data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-dummy.m +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack.xcconfig +0 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-dummy.m +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-prefix.pch +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest.xcconfig +0 -0
- data/vendor/Pods/Pods-Reachability-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-Reachability-dummy.m +5 -0
- data/vendor/Pods/Pods-Reachability-prefix.pch +5 -0
- data/vendor/Pods/Pods-Reachability.xcconfig +1 -0
- data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-YapDatabase-dummy.m +5 -0
- data/vendor/Pods/Pods-YapDatabase-prefix.pch +5 -0
- data/vendor/Pods/Pods-YapDatabase.xcconfig +1 -0
- data/vendor/Pods/Pods-dummy.m +5 -0
- data/vendor/Pods/Pods-environment.h +38 -0
- data/vendor/Pods/Pods-resources.sh +68 -0
- data/vendor/Pods/Pods.bridgesupport +5096 -0
- data/vendor/Pods/Pods.xcconfig +5 -0
- data/vendor/Pods/Pods.xcodeproj/project.pbxproj +5536 -0
- data/vendor/Pods/Reachability/LICENCE.txt +24 -0
- data/vendor/Pods/Reachability/README.md +65 -0
- data/vendor/Pods/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Reachability/Reachability.m +527 -0
- data/vendor/Pods/YapDatabase/LICENSE.txt +18 -0
- data/vendor/Pods/YapDatabase/README.md +30 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +175 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.m +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +966 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.m +146 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +298 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.m +95 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +1352 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +46 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +180 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +149 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +184 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +1166 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.mm +296 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.m +28 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +2494 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +1567 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.m +141 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +186 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +191 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +897 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.m +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +4505 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +90 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +453 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.m +48 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +83 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.m +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.m +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.m +26 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseString.h +121 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.h +74 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.m +603 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +20 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +194 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.m +96 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.h +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.m +82 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +2022 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +3874 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +5282 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +16 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +13 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +20 -0
- data/yapper.gemspec +24 -0
- metadata +458 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2011 Gowalla (http://gowalla.com/)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
@@ -0,0 +1,208 @@
|
|
1
|
+
<p align="center" >
|
2
|
+
<img src="https://raw.github.com/AFNetworking/AFNetworking/assets/afnetworking-logo.png" alt="AFNetworking" title="AFNetworking">
|
3
|
+
</p>
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/AFNetworking/AFNetworking.png?branch=master)](https://travis-ci.org/AFNetworking/AFNetworking)
|
6
|
+
|
7
|
+
AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of [NSURLConnection](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html), [NSOperation](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperation_class/Reference/Reference.html), and other familiar Foundation technologies. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. For example, here's how easy it is to get JSON from a URL:
|
8
|
+
|
9
|
+
```objective-c
|
10
|
+
NSURL *url = [NSURL URLWithString:@"https://alpha-api.app.net/stream/0/posts/stream/global"];
|
11
|
+
NSURLRequest *request = [NSURLRequest requestWithURL:url];
|
12
|
+
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
|
13
|
+
NSLog(@"App.net Global Stream: %@", JSON);
|
14
|
+
} failure:nil];
|
15
|
+
[operation start];
|
16
|
+
```
|
17
|
+
|
18
|
+
Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac.
|
19
|
+
|
20
|
+
Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did!
|
21
|
+
|
22
|
+
## How To Get Started
|
23
|
+
|
24
|
+
- [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/zipball/master) and try out the included Mac and iPhone example apps
|
25
|
+
- Read the ["Getting Started" guide](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking), [FAQ](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ), or [other articles in the wiki](https://github.com/AFNetworking/AFNetworking/wiki)
|
26
|
+
- Check out the [complete documentation](http://cocoadocs.org/docsets/AFNetworking/) for a comprehensive look at the APIs available in AFNetworking
|
27
|
+
- Watch the [NSScreencast episode about AFNetworking](http://nsscreencast.com/episodes/6-afnetworking) for a quick introduction to how to use it in your application
|
28
|
+
- Questions? [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking) is the best place to find answers
|
29
|
+
|
30
|
+
## Overview
|
31
|
+
|
32
|
+
AFNetworking is architected to be as small and modular as possible, in order to make it simple to use and extend.
|
33
|
+
|
34
|
+
<table>
|
35
|
+
<tr><th colspan="2" style="text-align:center;">Core</th></tr>
|
36
|
+
<tr>
|
37
|
+
<td><a href="http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFURLConnectionOperation.html">AFURLConnectionOperation</a></td>
|
38
|
+
<td>An <tt>NSOperation</tt> that implements the <tt>NSURLConnection</tt> delegate methods.</td>
|
39
|
+
</tr>
|
40
|
+
|
41
|
+
<tr><th colspan="2" style="text-align:center;">HTTP Requests</th></tr>
|
42
|
+
|
43
|
+
<tr>
|
44
|
+
<td><a href="http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFHTTPRequestOperation.html">AFHTTPRequestOperation</a></td>
|
45
|
+
<td>A subclass of <tt>AFURLConnectionOperation</tt> for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request.</td>
|
46
|
+
</tr>
|
47
|
+
<tr>
|
48
|
+
<td><a href="http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFJSONRequestOperation.html">AFJSONRequestOperation</a></td>
|
49
|
+
<td>A subclass of <tt>AFHTTPRequestOperation</tt> for downloading and working with JSON response data.</td>
|
50
|
+
</tr>
|
51
|
+
<tr>
|
52
|
+
<td><a href="http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFXMLRequestOperation.html">AFXMLRequestOperation</a></td>
|
53
|
+
<td>A subclass of <tt>AFHTTPRequestOperation</tt> for downloading and working with XML response data.</td>
|
54
|
+
</tr>
|
55
|
+
<tr>
|
56
|
+
<td><a href="http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFPropertyListRequestOperation.html">AFPropertyListRequestOperation</a></td>
|
57
|
+
<td>A subclass of <tt>AFHTTPRequestOperation</tt> for downloading and deserializing objects with <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/PropertyLists/index.html">property list</a> response data.</td>
|
58
|
+
</tr>
|
59
|
+
|
60
|
+
<tr><th colspan="2" style="text-align:center;">HTTP Client</th></tr>
|
61
|
+
<tr>
|
62
|
+
<td><a href="http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFHTTPClient.html">AFHTTPClient</a></td>
|
63
|
+
<td>
|
64
|
+
Captures the common patterns of communicating with an web application over HTTP, including:
|
65
|
+
|
66
|
+
<ul>
|
67
|
+
<li>Making requests from relative paths of a base URL</li>
|
68
|
+
<li>Setting HTTP headers to be added automatically to requests</li>
|
69
|
+
<li>Authenticating requests with HTTP Basic credentials or an OAuth token</li>
|
70
|
+
<li>Managing an <tt>NSOperationQueue</tt> for requests made by the client</li>
|
71
|
+
<li>Generating query strings or HTTP bodies from an <tt>NSDictionary</tt></li>
|
72
|
+
<li>Constructing multipart form requests</li>
|
73
|
+
<li>Automatically parsing HTTP response data into its corresponding object representation</li>
|
74
|
+
<li>Monitoring and responding to changes in network reachability</li>
|
75
|
+
</ul>
|
76
|
+
</td>
|
77
|
+
</tr>
|
78
|
+
|
79
|
+
<tr><th colspan="2" style="text-align:center;">Images</th></tr>
|
80
|
+
<tr>
|
81
|
+
<td><a href="http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFImageRequestOperation.html">AFImageRequestOperation</a></td>
|
82
|
+
<td>A subclass of <tt>AFHTTPRequestOperation</tt> for downloading and processing images.</td>
|
83
|
+
</tr>
|
84
|
+
<tr>
|
85
|
+
<td><a href="http://cocoadocs.org/docsets/AFNetworking/1.3.1/Categories/UIImageView+AFNetworking.html">UIImageView+AFNetworking</a></td>
|
86
|
+
<td>Adds methods to <tt>UIImageView</tt> for loading remote images asynchronously from a URL.</td>
|
87
|
+
</tr>
|
88
|
+
</table>
|
89
|
+
|
90
|
+
## Example Usage
|
91
|
+
|
92
|
+
### XML Request
|
93
|
+
|
94
|
+
```objective-c
|
95
|
+
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://api.flickr.com/services/rest/?method=flickr.groups.browse&api_key=b6300e17ad3c506e706cb0072175d047&cat_id=34427469792%40N01&format=rest"]];
|
96
|
+
AFXMLRequestOperation *operation = [AFXMLRequestOperation XMLParserRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser) {
|
97
|
+
XMLParser.delegate = self;
|
98
|
+
[XMLParser parse];
|
99
|
+
} failure:nil];
|
100
|
+
[operation start];
|
101
|
+
```
|
102
|
+
|
103
|
+
### Image Request
|
104
|
+
|
105
|
+
```objective-c
|
106
|
+
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)];
|
107
|
+
[imageView setImageWithURL:[NSURL URLWithString:@"http://i.imgur.com/r4uwx.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder-avatar"]];
|
108
|
+
```
|
109
|
+
|
110
|
+
### API Client Request
|
111
|
+
|
112
|
+
```objective-c
|
113
|
+
// AFAppDotNetAPIClient is a subclass of AFHTTPClient, which defines the base URL and default HTTP headers for NSURLRequests it creates
|
114
|
+
[[AFAppDotNetAPIClient sharedClient] getPath:@"stream/0/posts/stream/global" parameters:nil success:^(AFHTTPRequestOperation *operation, id JSON) {
|
115
|
+
NSLog(@"App.net Global Stream: %@", JSON);
|
116
|
+
} failure:nil];
|
117
|
+
```
|
118
|
+
|
119
|
+
### File Upload with Progress Callback
|
120
|
+
|
121
|
+
```objective-c
|
122
|
+
NSURL *url = [NSURL URLWithString:@"http://api-base-url.com"];
|
123
|
+
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
|
124
|
+
NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"avatar.jpg"], 0.5);
|
125
|
+
NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:@"/upload" parameters:nil constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
|
126
|
+
[formData appendPartWithFileData:imageData name:@"avatar" fileName:@"avatar.jpg" mimeType:@"image/jpeg"];
|
127
|
+
}];
|
128
|
+
|
129
|
+
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
|
130
|
+
[operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
|
131
|
+
NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite);
|
132
|
+
}];
|
133
|
+
[httpClient enqueueHTTPRequestOperation:operation];
|
134
|
+
```
|
135
|
+
|
136
|
+
### Streaming Request
|
137
|
+
|
138
|
+
```objective-c
|
139
|
+
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:8080/encode"]];
|
140
|
+
|
141
|
+
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
|
142
|
+
operation.inputStream = [NSInputStream inputStreamWithFileAtPath:[[NSBundle mainBundle] pathForResource:@"large-image" ofType:@"tiff"]];
|
143
|
+
operation.outputStream = [NSOutputStream outputStreamToMemory];
|
144
|
+
[operation start];
|
145
|
+
```
|
146
|
+
|
147
|
+
## Requirements
|
148
|
+
|
149
|
+
AFNetworking 1.0 and higher requires either [iOS 5.0](http://developer.apple.com/library/ios/#releasenotes/General/WhatsNewIniPhoneOS/Articles/iPhoneOS4.html) and above, or [Mac OS 10.7](http://developer.apple.com/library/mac/#releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_6.html#//apple_ref/doc/uid/TP40008898-SW7) ([64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)) and above.
|
150
|
+
|
151
|
+
For compatibility with iOS 4.3, use the latest 0.10.x release.
|
152
|
+
|
153
|
+
### ARC
|
154
|
+
|
155
|
+
AFNetworking uses ARC as of its 1.0 release.
|
156
|
+
|
157
|
+
If you are using AFNetworking 1.0 in your non-arc project, you will need to set a `-fobjc-arc` compiler flag on all of the AFNetworking source files. Conversely, if you are adding a pre-1.0 version of AFNetworking, you will need to set a `-fno-objc-arc` compiler flag.
|
158
|
+
|
159
|
+
To set a compiler flag in Xcode, go to your active target and select the "Build Phases" tab. Now select all AFNetworking source files, press Enter, insert `-fobjc-arc` or `-fno-objc-arc` and then "Done" to enable or disable ARC for AFNetworking.
|
160
|
+
|
161
|
+
## Unit Tests
|
162
|
+
|
163
|
+
AFNetworking includes a suite of unit tests within the Tests subdirectory. In order to run the unit tests, you must install the testing dependencies via CocoaPods. To do so:
|
164
|
+
|
165
|
+
$ gem install cocoapods # If necessary
|
166
|
+
$ cd Tests
|
167
|
+
$ pod install
|
168
|
+
|
169
|
+
Once CocoaPods has finished the installation, you can execute the test suite via the 'iOS Tests' and 'OS X Tests' schemes within Xcode.
|
170
|
+
|
171
|
+
### Test Logging
|
172
|
+
|
173
|
+
By default, the unit tests do not emit any output during execution. For debugging purposes, it can be useful to enable logging of the requests and responses. Logging support is provided by the [AFHTTPRequestOperationLogger](https://github.com/AFNetworking/AFHTTPRequestOperationLogger) extension, which is installed via CocoaPods into the test targets. To enable logging, edit the test Scheme and add an environment variable named `AFTestsLoggingEnabled` with a value of `YES`.
|
174
|
+
|
175
|
+
### Using xctool
|
176
|
+
|
177
|
+
If you wish to execute the tests from the command line or within a continuous integration environment, you will need to install [xctool](https://github.com/facebook/xctool). The recommended installation method is [Homebrew](http://mxcl.github.io/homebrew/).
|
178
|
+
|
179
|
+
To install the commandline testing support via Homebrew:
|
180
|
+
|
181
|
+
$ brew update
|
182
|
+
$ brew install xctool --HEAD
|
183
|
+
|
184
|
+
Once xctool is installed, you can execute the suite via `rake test`.
|
185
|
+
|
186
|
+
## Credits
|
187
|
+
|
188
|
+
AFNetworking was created by [Scott Raymond](https://github.com/sco/) and [Mattt Thompson](https://github.com/mattt/) in the development of [Gowalla for iPhone](http://en.wikipedia.org/wiki/Gowalla).
|
189
|
+
|
190
|
+
AFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/).
|
191
|
+
|
192
|
+
And most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/contributors).
|
193
|
+
|
194
|
+
## Contact
|
195
|
+
|
196
|
+
Follow AFNetworking on Twitter ([@AFNetworking](https://twitter.com/AFNetworking))
|
197
|
+
|
198
|
+
### Creators
|
199
|
+
|
200
|
+
[Mattt Thompson](http://github.com/mattt)
|
201
|
+
[@mattt](https://twitter.com/mattt)
|
202
|
+
|
203
|
+
[Scott Raymond](http://github.com/sco)
|
204
|
+
[@sco](https://twitter.com/sco)
|
205
|
+
|
206
|
+
## License
|
207
|
+
|
208
|
+
AFNetworking is available under the MIT license. See the LICENSE file for more info.
|
@@ -0,0 +1,641 @@
|
|
1
|
+
// AFHTTPClient.h
|
2
|
+
//
|
3
|
+
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
|
4
|
+
//
|
5
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
// of this software and associated documentation files (the "Software"), to deal
|
7
|
+
// in the Software without restriction, including without limitation the rights
|
8
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
// copies of the Software, and to permit persons to whom the Software is
|
10
|
+
// furnished to do so, subject to the following conditions:
|
11
|
+
//
|
12
|
+
// The above copyright notice and this permission notice shall be included in
|
13
|
+
// all copies or substantial portions of the Software.
|
14
|
+
//
|
15
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
// THE SOFTWARE.
|
22
|
+
|
23
|
+
#import <Foundation/Foundation.h>
|
24
|
+
#import "AFURLConnectionOperation.h"
|
25
|
+
|
26
|
+
#import <Availability.h>
|
27
|
+
|
28
|
+
/**
|
29
|
+
`AFHTTPClient` captures the common patterns of communicating with an web application over HTTP. It encapsulates information like base URL, authorization credentials, and HTTP headers, and uses them to construct and manage the execution of HTTP request operations.
|
30
|
+
|
31
|
+
## Automatic Content Parsing
|
32
|
+
|
33
|
+
Instances of `AFHTTPClient` may specify which types of requests it expects and should handle by registering HTTP operation classes for automatic parsing. Registered classes will determine whether they can handle a particular request, and then construct a request operation accordingly in `enqueueHTTPRequestOperationWithRequest:success:failure`.
|
34
|
+
|
35
|
+
## Subclassing Notes
|
36
|
+
|
37
|
+
In most cases, one should create an `AFHTTPClient` subclass for each website or web application that your application communicates with. It is often useful, also, to define a class method that returns a singleton shared HTTP client in each subclass, that persists authentication credentials and other configuration across the entire application.
|
38
|
+
|
39
|
+
## Methods to Override
|
40
|
+
|
41
|
+
To change the behavior of all url request construction for an `AFHTTPClient` subclass, override `requestWithMethod:path:parameters`.
|
42
|
+
|
43
|
+
To change the behavior of all request operation construction for an `AFHTTPClient` subclass, override `HTTPRequestOperationWithRequest:success:failure`.
|
44
|
+
|
45
|
+
## Default Headers
|
46
|
+
|
47
|
+
By default, `AFHTTPClient` sets the following HTTP headers:
|
48
|
+
|
49
|
+
- `Accept-Language: (comma-delimited preferred languages), en-us;q=0.8`
|
50
|
+
- `User-Agent: (generated user agent)`
|
51
|
+
|
52
|
+
You can override these HTTP headers or define new ones using `setDefaultHeader:value:`.
|
53
|
+
|
54
|
+
## URL Construction Using Relative Paths
|
55
|
+
|
56
|
+
Both `-requestWithMethod:path:parameters:` and `-multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:` construct URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`. Below are a few examples of how `baseURL` and relative paths interact:
|
57
|
+
|
58
|
+
NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];
|
59
|
+
[NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo
|
60
|
+
[NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz
|
61
|
+
[NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo
|
62
|
+
[NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo
|
63
|
+
[NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/
|
64
|
+
[NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
|
65
|
+
|
66
|
+
Also important to note is that a trailing slash will be added to any `baseURL` without one, which would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash.
|
67
|
+
|
68
|
+
## NSCoding / NSCopying Conformance
|
69
|
+
|
70
|
+
`AFHTTPClient` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. There are a few minor caveats to keep in mind, however:
|
71
|
+
|
72
|
+
- Archives and copies of HTTP clients will be initialized with an empty operation queue.
|
73
|
+
- NSCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set.
|
74
|
+
*/
|
75
|
+
|
76
|
+
#ifdef _SYSTEMCONFIGURATION_H
|
77
|
+
typedef enum {
|
78
|
+
AFNetworkReachabilityStatusUnknown = -1,
|
79
|
+
AFNetworkReachabilityStatusNotReachable = 0,
|
80
|
+
AFNetworkReachabilityStatusReachableViaWWAN = 1,
|
81
|
+
AFNetworkReachabilityStatusReachableViaWiFi = 2,
|
82
|
+
} AFNetworkReachabilityStatus;
|
83
|
+
#else
|
84
|
+
#pragma message("SystemConfiguration framework not found in project, or not included in precompiled header. Network reachability functionality will not be available.")
|
85
|
+
#endif
|
86
|
+
|
87
|
+
#ifndef __UTTYPE__
|
88
|
+
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
89
|
+
#pragma message("MobileCoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available.")
|
90
|
+
#else
|
91
|
+
#pragma message("CoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available.")
|
92
|
+
#endif
|
93
|
+
#endif
|
94
|
+
|
95
|
+
typedef enum {
|
96
|
+
AFFormURLParameterEncoding,
|
97
|
+
AFJSONParameterEncoding,
|
98
|
+
AFPropertyListParameterEncoding,
|
99
|
+
} AFHTTPClientParameterEncoding;
|
100
|
+
|
101
|
+
@class AFHTTPRequestOperation;
|
102
|
+
@protocol AFMultipartFormData;
|
103
|
+
|
104
|
+
@interface AFHTTPClient : NSObject <NSCoding, NSCopying>
|
105
|
+
|
106
|
+
///---------------------------------------
|
107
|
+
/// @name Accessing HTTP Client Properties
|
108
|
+
///---------------------------------------
|
109
|
+
|
110
|
+
/**
|
111
|
+
The url used as the base for paths specified in methods such as `getPath:parameters:success:failure`
|
112
|
+
*/
|
113
|
+
@property (readonly, nonatomic, strong) NSURL *baseURL;
|
114
|
+
|
115
|
+
/**
|
116
|
+
The string encoding used in constructing url requests. This is `NSUTF8StringEncoding` by default.
|
117
|
+
*/
|
118
|
+
@property (nonatomic, assign) NSStringEncoding stringEncoding;
|
119
|
+
|
120
|
+
/**
|
121
|
+
The `AFHTTPClientParameterEncoding` value corresponding to how parameters are encoded into a request body for request methods other than `GET`, `HEAD` or `DELETE`. This is `AFFormURLParameterEncoding` by default.
|
122
|
+
|
123
|
+
@warning Some nested parameter structures, such as a keyed array of hashes containing inconsistent keys (i.e. `@{@"": @[@{@"a" : @(1)}, @{@"b" : @(2)}]}`), cannot be unambiguously represented in query strings. It is strongly recommended that an unambiguous encoding, such as `AFJSONParameterEncoding`, is used when posting complicated or nondeterministic parameter structures.
|
124
|
+
*/
|
125
|
+
@property (nonatomic, assign) AFHTTPClientParameterEncoding parameterEncoding;
|
126
|
+
|
127
|
+
/**
|
128
|
+
The operation queue which manages operations enqueued by the HTTP client.
|
129
|
+
*/
|
130
|
+
@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue;
|
131
|
+
|
132
|
+
/**
|
133
|
+
The reachability status from the device to the current `baseURL` of the `AFHTTPClient`.
|
134
|
+
|
135
|
+
@warning This property requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
|
136
|
+
*/
|
137
|
+
#ifdef _SYSTEMCONFIGURATION_H
|
138
|
+
@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
|
139
|
+
#endif
|
140
|
+
|
141
|
+
/**
|
142
|
+
Default SSL pinning mode for each `AFHTTPRequestOperation` created by `HTTPRequestOperationWithRequest:success:failure:`.
|
143
|
+
*/
|
144
|
+
@property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode defaultSSLPinningMode;
|
145
|
+
|
146
|
+
/**
|
147
|
+
Whether each `AFHTTPRequestOperation` created by `HTTPRequestOperationWithRequest:success:failure:` should accept an invalid SSL certificate.
|
148
|
+
|
149
|
+
If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to `YES` for backwards compatibility. Otherwise, this property defaults to `NO`.
|
150
|
+
*/
|
151
|
+
@property (nonatomic, assign) BOOL allowsInvalidSSLCertificate;
|
152
|
+
|
153
|
+
///---------------------------------------------
|
154
|
+
/// @name Creating and Initializing HTTP Clients
|
155
|
+
///---------------------------------------------
|
156
|
+
|
157
|
+
/**
|
158
|
+
Creates and initializes an `AFHTTPClient` object with the specified base URL.
|
159
|
+
|
160
|
+
@param url The base URL for the HTTP client. This argument must not be `nil`.
|
161
|
+
|
162
|
+
@return The newly-initialized HTTP client
|
163
|
+
*/
|
164
|
+
+ (instancetype)clientWithBaseURL:(NSURL *)url;
|
165
|
+
|
166
|
+
/**
|
167
|
+
Initializes an `AFHTTPClient` object with the specified base URL.
|
168
|
+
|
169
|
+
This is the designated initializer.
|
170
|
+
|
171
|
+
@param url The base URL for the HTTP client. This argument must not be `nil`.
|
172
|
+
|
173
|
+
@return The newly-initialized HTTP client
|
174
|
+
*/
|
175
|
+
- (id)initWithBaseURL:(NSURL *)url;
|
176
|
+
|
177
|
+
///-----------------------------------
|
178
|
+
/// @name Managing Reachability Status
|
179
|
+
///-----------------------------------
|
180
|
+
|
181
|
+
/**
|
182
|
+
Sets a callback to be executed when the network availability of the `baseURL` host changes.
|
183
|
+
|
184
|
+
@param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
|
185
|
+
|
186
|
+
@warning This method requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
|
187
|
+
*/
|
188
|
+
#ifdef _SYSTEMCONFIGURATION_H
|
189
|
+
- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block;
|
190
|
+
#endif
|
191
|
+
|
192
|
+
///-------------------------------
|
193
|
+
/// @name Managing HTTP Operations
|
194
|
+
///-------------------------------
|
195
|
+
|
196
|
+
/**
|
197
|
+
Attempts to register a subclass of `AFHTTPRequestOperation`, adding it to a chain to automatically generate request operations from a URL request.
|
198
|
+
|
199
|
+
When `enqueueHTTPRequestOperationWithRequest:success:failure` is invoked, each registered class is consulted in turn to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to create an operation using `initWithURLRequest:` and do `setCompletionBlockWithSuccess:failure:`. There is no guarantee that all registered classes will be consulted. Classes are consulted in the reverse order of their registration. Attempting to register an already-registered class will move it to the top of the list.
|
200
|
+
|
201
|
+
@param operationClass The subclass of `AFHTTPRequestOperation` to register
|
202
|
+
|
203
|
+
@return `YES` if the registration is successful, `NO` otherwise. The only failure condition is if `operationClass` is not a subclass of `AFHTTPRequestOperation`.
|
204
|
+
*/
|
205
|
+
- (BOOL)registerHTTPOperationClass:(Class)operationClass;
|
206
|
+
|
207
|
+
/**
|
208
|
+
Unregisters the specified subclass of `AFHTTPRequestOperation` from the chain of classes consulted when `-requestWithMethod:path:parameters` is called.
|
209
|
+
|
210
|
+
@param operationClass The subclass of `AFHTTPRequestOperation` to register
|
211
|
+
*/
|
212
|
+
- (void)unregisterHTTPOperationClass:(Class)operationClass;
|
213
|
+
|
214
|
+
///----------------------------------
|
215
|
+
/// @name Managing HTTP Header Values
|
216
|
+
///----------------------------------
|
217
|
+
|
218
|
+
/**
|
219
|
+
Returns the value for the HTTP headers set in request objects created by the HTTP client.
|
220
|
+
|
221
|
+
@param header The HTTP header to return the default value for
|
222
|
+
|
223
|
+
@return The default value for the HTTP header, or `nil` if unspecified
|
224
|
+
*/
|
225
|
+
- (NSString *)defaultValueForHeader:(NSString *)header;
|
226
|
+
|
227
|
+
/**
|
228
|
+
Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header.
|
229
|
+
|
230
|
+
@param header The HTTP header to set a default value for
|
231
|
+
@param value The value set as default for the specified header, or `nil
|
232
|
+
*/
|
233
|
+
- (void)setDefaultHeader:(NSString *)header
|
234
|
+
value:(NSString *)value;
|
235
|
+
|
236
|
+
/**
|
237
|
+
Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
|
238
|
+
|
239
|
+
@param username The HTTP basic auth username
|
240
|
+
@param password The HTTP basic auth password
|
241
|
+
*/
|
242
|
+
- (void)setAuthorizationHeaderWithUsername:(NSString *)username
|
243
|
+
password:(NSString *)password;
|
244
|
+
|
245
|
+
/**
|
246
|
+
Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a token-based authentication value, such as an OAuth access token. This overwrites any existing value for this header.
|
247
|
+
|
248
|
+
@param token The authentication token
|
249
|
+
*/
|
250
|
+
- (void)setAuthorizationHeaderWithToken:(NSString *)token;
|
251
|
+
|
252
|
+
|
253
|
+
/**
|
254
|
+
Clears any existing value for the "Authorization" HTTP header.
|
255
|
+
*/
|
256
|
+
- (void)clearAuthorizationHeader;
|
257
|
+
|
258
|
+
///-------------------------------
|
259
|
+
/// @name Managing URL Credentials
|
260
|
+
///-------------------------------
|
261
|
+
|
262
|
+
/**
|
263
|
+
Set the default URL credential to be set for request operations.
|
264
|
+
|
265
|
+
@param credential The URL credential
|
266
|
+
*/
|
267
|
+
- (void)setDefaultCredential:(NSURLCredential *)credential;
|
268
|
+
|
269
|
+
///-------------------------------
|
270
|
+
/// @name Creating Request Objects
|
271
|
+
///-------------------------------
|
272
|
+
|
273
|
+
/**
|
274
|
+
Creates an `NSMutableURLRequest` object with the specified HTTP method and path.
|
275
|
+
|
276
|
+
If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body.
|
277
|
+
|
278
|
+
@param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`.
|
279
|
+
@param path The path to be appended to the HTTP client's base URL and used as the request URL. If `nil`, no path will be appended to the base URL.
|
280
|
+
@param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body.
|
281
|
+
|
282
|
+
@return An `NSMutableURLRequest` object
|
283
|
+
*/
|
284
|
+
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method
|
285
|
+
path:(NSString *)path
|
286
|
+
parameters:(NSDictionary *)parameters;
|
287
|
+
|
288
|
+
/**
|
289
|
+
Creates an `NSMutableURLRequest` object with the specified HTTP method and path, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2
|
290
|
+
|
291
|
+
Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream.
|
292
|
+
|
293
|
+
@param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`.
|
294
|
+
@param path The path to be appended to the HTTP client's base URL and used as the request URL.
|
295
|
+
@param parameters The parameters to be encoded and set in the request HTTP body.
|
296
|
+
@param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. This can be used to upload files, encode HTTP body as JSON or XML, or specify multiple values for the same parameter, as one might for array values.
|
297
|
+
|
298
|
+
@return An `NSMutableURLRequest` object
|
299
|
+
*/
|
300
|
+
- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
|
301
|
+
path:(NSString *)path
|
302
|
+
parameters:(NSDictionary *)parameters
|
303
|
+
constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block;
|
304
|
+
|
305
|
+
///-------------------------------
|
306
|
+
/// @name Creating HTTP Operations
|
307
|
+
///-------------------------------
|
308
|
+
|
309
|
+
/**
|
310
|
+
Creates an `AFHTTPRequestOperation`.
|
311
|
+
|
312
|
+
In order to determine what kind of operation is created, each registered subclass conforming to the `AFHTTPClient` protocol is consulted (in reverse order of when they were specified) to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to generate an operation using `HTTPRequestOperationWithRequest:success:failure:`.
|
313
|
+
|
314
|
+
@param urlRequest The request object to be loaded asynchronously during execution of the operation.
|
315
|
+
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
|
316
|
+
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
|
317
|
+
*/
|
318
|
+
- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest
|
319
|
+
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
320
|
+
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
|
321
|
+
|
322
|
+
///----------------------------------------
|
323
|
+
/// @name Managing Enqueued HTTP Operations
|
324
|
+
///----------------------------------------
|
325
|
+
|
326
|
+
/**
|
327
|
+
Enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue.
|
328
|
+
|
329
|
+
@param operation The HTTP request operation to be enqueued.
|
330
|
+
*/
|
331
|
+
- (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation;
|
332
|
+
|
333
|
+
/**
|
334
|
+
Cancels all operations in the HTTP client's operation queue whose URLs match the specified HTTP method and path.
|
335
|
+
|
336
|
+
This method only cancels `AFHTTPRequestOperations` whose request URL matches the HTTP client base URL with the path appended. For complete control over the lifecycle of enqueued operations, you can access the `operationQueue` property directly, which allows you to, for instance, cancel operations filtered by a predicate, or simply use `-cancelAllRequests`. Note that the operation queue may include non-HTTP operations, so be sure to check the type before attempting to directly introspect an operation's `request` property.
|
337
|
+
|
338
|
+
@param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`. If `nil`, all request operations with URLs matching the path will be cancelled.
|
339
|
+
@param path The path appended to the HTTP client base URL to match against the cancelled requests. If `nil`, no path will be appended to the base URL.
|
340
|
+
*/
|
341
|
+
- (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path;
|
342
|
+
|
343
|
+
///---------------------------------------
|
344
|
+
/// @name Batching HTTP Request Operations
|
345
|
+
///---------------------------------------
|
346
|
+
|
347
|
+
/**
|
348
|
+
Creates and enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue for each specified request object into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes.
|
349
|
+
|
350
|
+
Operations are created by passing the specified `NSURLRequest` objects in `requests`, using `-HTTPRequestOperationWithRequest:success:failure:`, with `nil` for both the `success` and `failure` parameters.
|
351
|
+
|
352
|
+
@param urlRequests The `NSURLRequest` objects used to create and enqueue operations.
|
353
|
+
@param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations.
|
354
|
+
@param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations.
|
355
|
+
*/
|
356
|
+
- (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)urlRequests
|
357
|
+
progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
|
358
|
+
completionBlock:(void (^)(NSArray *operations))completionBlock;
|
359
|
+
|
360
|
+
/**
|
361
|
+
Enqueues the specified request operations into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes.
|
362
|
+
|
363
|
+
@param operations The request operations used to be batched and enqueued.
|
364
|
+
@param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations.
|
365
|
+
@param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations.
|
366
|
+
*/
|
367
|
+
- (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations
|
368
|
+
progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
|
369
|
+
completionBlock:(void (^)(NSArray *operations))completionBlock;
|
370
|
+
|
371
|
+
///---------------------------
|
372
|
+
/// @name Making HTTP Requests
|
373
|
+
///---------------------------
|
374
|
+
|
375
|
+
/**
|
376
|
+
Creates an `AFHTTPRequestOperation` with a `GET` request, and enqueues it to the HTTP client's operation queue.
|
377
|
+
|
378
|
+
@param path The path to be appended to the HTTP client's base URL and used as the request URL.
|
379
|
+
@param parameters The parameters to be encoded and appended as the query string for the request URL.
|
380
|
+
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
|
381
|
+
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments: the created request operation and the `NSError` object describing the network or parsing error that occurred.
|
382
|
+
|
383
|
+
@see -HTTPRequestOperationWithRequest:success:failure:
|
384
|
+
*/
|
385
|
+
- (void)getPath:(NSString *)path
|
386
|
+
parameters:(NSDictionary *)parameters
|
387
|
+
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
388
|
+
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
|
389
|
+
|
390
|
+
/**
|
391
|
+
Creates an `AFHTTPRequestOperation` with a `POST` request, and enqueues it to the HTTP client's operation queue.
|
392
|
+
|
393
|
+
@param path The path to be appended to the HTTP client's base URL and used as the request URL.
|
394
|
+
@param parameters The parameters to be encoded and set in the request HTTP body.
|
395
|
+
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
|
396
|
+
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments: the created request operation and the `NSError` object describing the network or parsing error that occurred.
|
397
|
+
|
398
|
+
@see -HTTPRequestOperationWithRequest:success:failure:
|
399
|
+
*/
|
400
|
+
- (void)postPath:(NSString *)path
|
401
|
+
parameters:(NSDictionary *)parameters
|
402
|
+
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
403
|
+
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
|
404
|
+
|
405
|
+
/**
|
406
|
+
Creates an `AFHTTPRequestOperation` with a `PUT` request, and enqueues it to the HTTP client's operation queue.
|
407
|
+
|
408
|
+
@param path The path to be appended to the HTTP client's base URL and used as the request URL.
|
409
|
+
@param parameters The parameters to be encoded and set in the request HTTP body.
|
410
|
+
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
|
411
|
+
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments: the created request operation and the `NSError` object describing the network or parsing error that occurred.
|
412
|
+
|
413
|
+
@see -HTTPRequestOperationWithRequest:success:failure:
|
414
|
+
*/
|
415
|
+
- (void)putPath:(NSString *)path
|
416
|
+
parameters:(NSDictionary *)parameters
|
417
|
+
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
418
|
+
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
|
419
|
+
|
420
|
+
/**
|
421
|
+
Creates an `AFHTTPRequestOperation` with a `DELETE` request, and enqueues it to the HTTP client's operation queue.
|
422
|
+
|
423
|
+
@param path The path to be appended to the HTTP client's base URL and used as the request URL.
|
424
|
+
@param parameters The parameters to be encoded and appended as the query string for the request URL.
|
425
|
+
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
|
426
|
+
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments: the created request operation and the `NSError` object describing the network or parsing error that occurred.
|
427
|
+
|
428
|
+
@see -HTTPRequestOperationWithRequest:success:failure:
|
429
|
+
*/
|
430
|
+
- (void)deletePath:(NSString *)path
|
431
|
+
parameters:(NSDictionary *)parameters
|
432
|
+
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
433
|
+
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
|
434
|
+
|
435
|
+
/**
|
436
|
+
Creates an `AFHTTPRequestOperation` with a `PATCH` request, and enqueues it to the HTTP client's operation queue.
|
437
|
+
|
438
|
+
@param path The path to be appended to the HTTP client's base URL and used as the request URL.
|
439
|
+
@param parameters The parameters to be encoded and set in the request HTTP body.
|
440
|
+
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
|
441
|
+
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments: the created request operation and the `NSError` object describing the network or parsing error that occurred.
|
442
|
+
|
443
|
+
@see -HTTPRequestOperationWithRequest:success:failure:
|
444
|
+
*/
|
445
|
+
- (void)patchPath:(NSString *)path
|
446
|
+
parameters:(NSDictionary *)parameters
|
447
|
+
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
448
|
+
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
|
449
|
+
@end
|
450
|
+
|
451
|
+
///----------------
|
452
|
+
/// @name Constants
|
453
|
+
///----------------
|
454
|
+
|
455
|
+
/**
|
456
|
+
## Network Reachability
|
457
|
+
|
458
|
+
The following constants are provided by `AFHTTPClient` as possible network reachability statuses.
|
459
|
+
|
460
|
+
enum {
|
461
|
+
AFNetworkReachabilityStatusUnknown,
|
462
|
+
AFNetworkReachabilityStatusNotReachable,
|
463
|
+
AFNetworkReachabilityStatusReachableViaWWAN,
|
464
|
+
AFNetworkReachabilityStatusReachableViaWiFi,
|
465
|
+
}
|
466
|
+
|
467
|
+
`AFNetworkReachabilityStatusUnknown`
|
468
|
+
The `baseURL` host reachability is not known.
|
469
|
+
|
470
|
+
`AFNetworkReachabilityStatusNotReachable`
|
471
|
+
The `baseURL` host cannot be reached.
|
472
|
+
|
473
|
+
`AFNetworkReachabilityStatusReachableViaWWAN`
|
474
|
+
The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
|
475
|
+
|
476
|
+
`AFNetworkReachabilityStatusReachableViaWiFi`
|
477
|
+
The `baseURL` host can be reached via a Wi-Fi connection.
|
478
|
+
|
479
|
+
### Keys for Notification UserInfo Dictionary
|
480
|
+
|
481
|
+
Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
|
482
|
+
|
483
|
+
`AFNetworkingReachabilityNotificationStatusItem`
|
484
|
+
A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
|
485
|
+
The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
|
486
|
+
|
487
|
+
## Parameter Encoding
|
488
|
+
|
489
|
+
The following constants are provided by `AFHTTPClient` as possible methods for serializing parameters into query string or message body values.
|
490
|
+
|
491
|
+
enum {
|
492
|
+
AFFormURLParameterEncoding,
|
493
|
+
AFJSONParameterEncoding,
|
494
|
+
AFPropertyListParameterEncoding,
|
495
|
+
}
|
496
|
+
|
497
|
+
`AFFormURLParameterEncoding`
|
498
|
+
Parameters are encoded into field/key pairs in the URL query string for `GET` `HEAD` and `DELETE` requests, and in the message body otherwise. Dictionary keys are sorted with the `caseInsensitiveCompare:` selector of their description, in order to mitigate the possibility of ambiguous query strings being generated non-deterministically. See the warning for the `parameterEncoding` property for additional information.
|
499
|
+
|
500
|
+
`AFJSONParameterEncoding`
|
501
|
+
Parameters are encoded into JSON in the message body.
|
502
|
+
|
503
|
+
`AFPropertyListParameterEncoding`
|
504
|
+
Parameters are encoded into a property list in the message body.
|
505
|
+
*/
|
506
|
+
|
507
|
+
///----------------
|
508
|
+
/// @name Functions
|
509
|
+
///----------------
|
510
|
+
|
511
|
+
/**
|
512
|
+
Returns a query string constructed by a set of parameters, using the specified encoding.
|
513
|
+
|
514
|
+
Query strings are constructed by collecting each key-value pair, percent escaping a string representation of the key-value pair, and then joining the pairs with "&".
|
515
|
+
|
516
|
+
If a query string pair has a an `NSArray` for its value, each member of the array will be represented in the format `field[]=value1&field[]value2`. Otherwise, the pair will be formatted as "field=value". String representations of both keys and values are derived using the `-description` method. The constructed query string does not include the ? character used to delimit the query component.
|
517
|
+
|
518
|
+
@param parameters The parameters used to construct the query string
|
519
|
+
@param encoding The encoding to use in constructing the query string. If you are uncertain of the correct encoding, you should use UTF-8 (`NSUTF8StringEncoding`), which is the encoding designated by RFC 3986 as the correct encoding for use in URLs.
|
520
|
+
|
521
|
+
@return A percent-escaped query string
|
522
|
+
*/
|
523
|
+
extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding encoding);
|
524
|
+
|
525
|
+
///--------------------
|
526
|
+
/// @name Notifications
|
527
|
+
///--------------------
|
528
|
+
|
529
|
+
/**
|
530
|
+
Posted when network reachability changes.
|
531
|
+
This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
|
532
|
+
|
533
|
+
@warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
|
534
|
+
*/
|
535
|
+
#ifdef _SYSTEMCONFIGURATION_H
|
536
|
+
extern NSString * const AFNetworkingReachabilityDidChangeNotification;
|
537
|
+
extern NSString * const AFNetworkingReachabilityNotificationStatusItem;
|
538
|
+
#endif
|
539
|
+
|
540
|
+
#pragma mark -
|
541
|
+
|
542
|
+
extern NSUInteger const kAFUploadStream3GSuggestedPacketSize;
|
543
|
+
extern NSTimeInterval const kAFUploadStream3GSuggestedDelay;
|
544
|
+
|
545
|
+
/**
|
546
|
+
The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPClient -multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:`.
|
547
|
+
*/
|
548
|
+
@protocol AFMultipartFormData
|
549
|
+
|
550
|
+
/**
|
551
|
+
Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary.
|
552
|
+
|
553
|
+
The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively.
|
554
|
+
|
555
|
+
@param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
|
556
|
+
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
557
|
+
@param error If an error occurs, upon return contains an `NSError` object that describes the problem.
|
558
|
+
|
559
|
+
@return `YES` if the file data was successfully appended, otherwise `NO`.
|
560
|
+
*/
|
561
|
+
- (BOOL)appendPartWithFileURL:(NSURL *)fileURL
|
562
|
+
name:(NSString *)name
|
563
|
+
error:(NSError * __autoreleasing *)error;
|
564
|
+
|
565
|
+
/**
|
566
|
+
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
|
567
|
+
|
568
|
+
@param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
|
569
|
+
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
570
|
+
@param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`.
|
571
|
+
@param mimeType The declared MIME type of the file data. This parameter must not be `nil`.
|
572
|
+
@param error If an error occurs, upon return contains an `NSError` object that describes the problem.
|
573
|
+
|
574
|
+
@return `YES` if the file data was successfully appended otherwise `NO`.
|
575
|
+
*/
|
576
|
+
- (BOOL)appendPartWithFileURL:(NSURL *)fileURL
|
577
|
+
name:(NSString *)name
|
578
|
+
fileName:(NSString *)fileName
|
579
|
+
mimeType:(NSString *)mimeType
|
580
|
+
error:(NSError * __autoreleasing *)error;
|
581
|
+
|
582
|
+
/**
|
583
|
+
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary.
|
584
|
+
|
585
|
+
@param inputStream The input stream to be appended to the form data
|
586
|
+
@param name The name to be associated with the specified input stream. This parameter must not be `nil`.
|
587
|
+
@param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`.
|
588
|
+
@param length The length of the specified input stream in bytes.
|
589
|
+
@param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
|
590
|
+
*/
|
591
|
+
- (void)appendPartWithInputStream:(NSInputStream *)inputStream
|
592
|
+
name:(NSString *)name
|
593
|
+
fileName:(NSString *)fileName
|
594
|
+
length:(unsigned long long)length
|
595
|
+
mimeType:(NSString *)mimeType;
|
596
|
+
|
597
|
+
/**
|
598
|
+
Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
|
599
|
+
|
600
|
+
@param data The data to be encoded and appended to the form data.
|
601
|
+
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
602
|
+
@param fileName The filename to be associated with the specified data. This parameter must not be `nil`.
|
603
|
+
@param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
|
604
|
+
*/
|
605
|
+
- (void)appendPartWithFileData:(NSData *)data
|
606
|
+
name:(NSString *)name
|
607
|
+
fileName:(NSString *)fileName
|
608
|
+
mimeType:(NSString *)mimeType;
|
609
|
+
|
610
|
+
/**
|
611
|
+
Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary.
|
612
|
+
|
613
|
+
@param data The data to be encoded and appended to the form data.
|
614
|
+
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
615
|
+
*/
|
616
|
+
|
617
|
+
- (void)appendPartWithFormData:(NSData *)data
|
618
|
+
name:(NSString *)name;
|
619
|
+
|
620
|
+
|
621
|
+
/**
|
622
|
+
Appends HTTP headers, followed by the encoded data and the multipart form boundary.
|
623
|
+
|
624
|
+
@param headers The HTTP headers to be appended to the form data.
|
625
|
+
@param body The data to be encoded and appended to the form data.
|
626
|
+
*/
|
627
|
+
- (void)appendPartWithHeaders:(NSDictionary *)headers
|
628
|
+
body:(NSData *)body;
|
629
|
+
|
630
|
+
/**
|
631
|
+
Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
|
632
|
+
|
633
|
+
When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, as of iOS 6, there is no definite way to distinguish between a 3G, EDGE, or LTE connection. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth.
|
634
|
+
|
635
|
+
@param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 32kb.
|
636
|
+
@param delay Duration of delay each time a packet is read. By default, no delay is set.
|
637
|
+
*/
|
638
|
+
- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
|
639
|
+
delay:(NSTimeInterval)delay;
|
640
|
+
|
641
|
+
@end
|