├── .cocoadocs.yml
├── .gitignore
├── .travis.yml
├── AFNetworking.podspec
├── AFNetworking.xcodeproj
├── project.pbxproj
└── xcshareddata
│ └── xcschemes
│ ├── AFNetworking iOS.xcscheme
│ ├── AFNetworking macOS.xcscheme
│ ├── AFNetworking tvOS.xcscheme
│ └── AFNetworking watchOS.xcscheme
├── AFNetworking.xcworkspace
└── contents.xcworkspacedata
├── AFNetworking
├── AFNetworking.h
├── Reachability
│ ├── AFNetworkReachabilityManager.h
│ └── AFNetworkReachabilityManager.m
├── SecurityPolicy
│ ├── AFSecurityPolicy.h
│ └── AFSecurityPolicy.m
├── Serialization
│ ├── AFURLRequestSerialization.h
│ ├── AFURLRequestSerialization.m
│ ├── AFURLResponseSerialization.h
│ └── AFURLResponseSerialization.m
└── Session
│ ├── AFHTTPSessionManager.h
│ ├── AFHTTPSessionManager.m
│ ├── AFURLSessionManager.h
│ └── AFURLSessionManager.m
├── CHANGELOG.md
├── CONTRIBUTING.md
├── Example
├── AFNetworking Example.entitlements
├── AFNetworking Example.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ │ └── xcschemes
│ │ ├── iOS Example.xcscheme
│ │ ├── iOS Today Extension Example.xcscheme
│ │ ├── macOS Example.xcscheme
│ │ ├── tvOS Example.xcscheme
│ │ └── watchOS Example.xcscheme
├── AFNetworking tvOS Example.xcodeproj
│ └── project.pbxproj
├── AFNetworking watchOS
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Base.lproj
│ │ └── Interface.storyboard
│ └── Info.plist
├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── Icon-40.png
│ │ ├── Icon-40@2x.png
│ │ ├── Icon-40@3x.png
│ │ ├── Icon-60@2x.png
│ │ ├── Icon-60@3x.png
│ │ ├── Icon-76.png
│ │ ├── Icon-76@2x.png
│ │ ├── Icon-Small.png
│ │ ├── Icon-Small@2x.png
│ │ └── Icon-Small@3x.png
│ ├── Contents.json
│ └── profile-image-placeholder.imageset
│ │ ├── Contents.json
│ │ ├── profile-image-placeholder.png
│ │ └── profile-image-placeholder@2x.png
├── Certificates
│ ├── adn.cer
│ ├── digicert_ca_3.cer
│ └── root_ca.cer
├── Classes
│ ├── Models
│ │ ├── Post.h
│ │ ├── Post.m
│ │ ├── User.h
│ │ └── User.m
│ └── Networking Extensions
│ │ ├── AFAppDotNetAPIClient.h
│ │ └── AFAppDotNetAPIClient.m
├── Prefix.pch
├── Today Extension Example
│ ├── Base.lproj
│ │ └── MainInterface.storyboard
│ ├── Info.plist
│ ├── TodayViewController.h
│ └── TodayViewController.m
├── en.lproj
│ └── MainMenu.xib
├── iOS Example
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Controllers
│ │ ├── GlobalTimelineViewController.h
│ │ └── GlobalTimelineViewController.m
│ ├── Info.plist
│ ├── Launchscreen.storyboard
│ └── Views
│ │ ├── PostTableViewCell.h
│ │ └── PostTableViewCell.m
├── macOS Example
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Info.plist
│ ├── MainMenu.xib
│ └── main.m
├── main.m
├── tvOS Example
│ ├── AFNetworking tvOS Example-Bridging-Header.h
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ │ ├── App Icon & Top Shelf Image.brandassets
│ │ │ ├── App Icon - Large.imagestack
│ │ │ │ ├── Back.imagestacklayer
│ │ │ │ │ ├── Content.imageset
│ │ │ │ │ │ └── Contents.json
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Front.imagestacklayer
│ │ │ │ │ ├── Content.imageset
│ │ │ │ │ │ └── Contents.json
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Middle.imagestacklayer
│ │ │ │ │ ├── Content.imageset
│ │ │ │ │ └── Contents.json
│ │ │ │ │ └── Contents.json
│ │ │ ├── App Icon - Small.imagestack
│ │ │ │ ├── Back.imagestacklayer
│ │ │ │ │ ├── Content.imageset
│ │ │ │ │ │ └── Contents.json
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Front.imagestacklayer
│ │ │ │ │ ├── Content.imageset
│ │ │ │ │ │ └── Contents.json
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Middle.imagestacklayer
│ │ │ │ │ ├── Content.imageset
│ │ │ │ │ └── Contents.json
│ │ │ │ │ └── Contents.json
│ │ │ ├── Contents.json
│ │ │ └── Top Shelf Image.imageset
│ │ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── LaunchImage.launchimage
│ │ │ └── Contents.json
│ ├── Base.lproj
│ │ └── Main.storyboard
│ ├── Gravatar.swift
│ ├── Info.plist
│ └── ViewController.swift
├── watchOS Example Extension
│ ├── Assets.xcassets
│ │ └── README__ignoredByTemplate__
│ ├── ExtensionDelegate.h
│ ├── ExtensionDelegate.m
│ ├── Info.plist
│ ├── InterfaceController.h
│ └── InterfaceController.m
└── watchOS Example
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ └── Interface.storyboard
│ └── Info.plist
├── Framework
├── AFNetworking.h
├── Info.plist
└── module.modulemap
├── LICENSE
├── README.md
├── Tests
├── Info.plist
├── Resources
│ ├── ADN.net
│ │ └── ADNNetServerTrustChain
│ │ │ ├── adn_0.cer
│ │ │ ├── adn_1.cer
│ │ │ └── adn_2.cer
│ ├── Google.com
│ │ ├── Equifax_Secure_Certificate_Authority_Root.cer
│ │ ├── GeoTrust_Global_CA-cross.cer
│ │ ├── GeoTrust_Global_CA_Root.cer
│ │ ├── GoogleComServerTrustChainPath1
│ │ │ ├── googlecom_0.cer
│ │ │ └── googlecom_1.cer
│ │ ├── GoogleComServerTrustChainPath2
│ │ │ ├── googlecom_0.cer
│ │ │ ├── googlecom_1.cer
│ │ │ └── googlecom_2.cer
│ │ ├── GoogleInternetAuthorityG2.cer
│ │ └── google.com.cer
│ ├── HTTPBin.org
│ │ ├── DST Root CA X3.cer
│ │ ├── HTTPBinOrgServerTrustChain
│ │ │ ├── httpbin_0.cer
│ │ │ ├── httpbin_1.cer
│ │ │ └── httpbin_2.cer
│ │ ├── Let's Encrypt Authority X3.cer
│ │ └── httpbinorg_04112018.cer
│ ├── SelfSigned
│ │ ├── AltName.cer
│ │ ├── NoDomains.cer
│ │ └── foobar.com.cer
│ └── logo.png
├── Tests-Prefix.pch
└── Tests
│ ├── AFAutoPurgingImageCacheTests.m
│ ├── AFCompoundResponseSerializerTests.m
│ ├── AFHTTPRequestSerializationTests.m
│ ├── AFHTTPResponseSerializationTests.m
│ ├── AFHTTPSessionManagerTests.m
│ ├── AFImageDownloaderTests.m
│ ├── AFImageResponseSerializerTests.m
│ ├── AFJSONSerializationTests.m
│ ├── AFNetworkActivityManagerTests.m
│ ├── AFNetworkReachabilityManagerTests.m
│ ├── AFPropertyListRequestSerializerTests.m
│ ├── AFPropertyListResponseSerializerTests.m
│ ├── AFSecurityPolicyTests.m
│ ├── AFTestCase.h
│ ├── AFTestCase.m
│ ├── AFUIActivityIndicatorViewTests.m
│ ├── AFUIButtonTests.m
│ ├── AFUIImageViewTests.m
│ ├── AFUIRefreshControlTests.m
│ ├── AFUIWebViewTests.m
│ ├── AFURLSessionManagerTests.m
│ ├── AFXMLDocumentResponseSerializerTests.m
│ └── AFXMLParserResponseSerializerTests.m
├── UIKit+AFNetworking
├── AFAutoPurgingImageCache.h
├── AFAutoPurgingImageCache.m
├── AFImageDownloader.h
├── AFImageDownloader.m
├── AFNetworkActivityIndicatorManager.h
├── AFNetworkActivityIndicatorManager.m
├── UIActivityIndicatorView+AFNetworking.h
├── UIActivityIndicatorView+AFNetworking.m
├── UIButton+AFNetworking.h
├── UIButton+AFNetworking.m
├── UIImage+AFNetworking.h
├── UIImageView+AFNetworking.h
├── UIImageView+AFNetworking.m
├── UIKit+AFNetworking.h
├── UIProgressView+AFNetworking.h
├── UIProgressView+AFNetworking.m
├── UIRefreshControl+AFNetworking.h
├── UIRefreshControl+AFNetworking.m
├── UIWebView+AFNetworking.h
└── UIWebView+AFNetworking.m
└── fastlane
├── .env
├── .env.default
├── .env.deploy
├── .env.ios10_xcode8
├── .env.ios11_xcode93
├── .env.ios8_xcode7
├── .env.ios9_xcode7
├── .env.osx
├── .env.tvos11_xcode9
└── Fastfile
/.cocoadocs.yml:
--------------------------------------------------------------------------------
1 | highlight-color: "#F89915"
2 | highlight-dark-color: "#E23B1B"
3 | darker-color: "#D8A688"
4 | darker-dark-color: "#E93D1C"
5 | background-color: "#E9DFDB"
6 | alt-link-color: "#E23B1B"
7 | warning-color: "#E23B1B"
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | .DS_Store
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | *.xcworkspace
13 | !default.xcworkspace
14 | xcuserdata
15 | profile
16 | *.moved-aside
17 | DerivedData
18 | .idea/
19 | Tests/Pods
20 | Tests/Podfile.lock
21 | Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/
22 | AFNetworking.framework.zip
23 |
24 | # Fastlane
25 | /fastlane/report.xml
26 | /fastlane/.env*private*
27 | fastlane/test-output/*
28 |
29 | Carthage/Build
30 |
31 | fastlane/README.md
32 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: objective-c
2 | osx_image: xcode7.1
3 | sudo: false
4 | env:
5 | global:
6 | - LC_CTYPE=en_US.UTF-8
7 | - LANG=en_US.UTF-8
8 | - LANGUAGE=en_US.UTF-8
9 | - FASTLANE_LANE=ci_commit
10 | matrix:
11 | include:
12 | - osx_image: xcode9.2
13 | env: FASTLANE_LANE=code_coverage FASTLANE_ENV=default
14 | - osx_image: xcode9.2
15 | env: FASTLANE_ENV=ios11_xcode9
16 | - osx_image: xcode9.2
17 | env: FASTLANE_ENV=tvos11_xcode9
18 | - osx_image: xcode9.2
19 | env: FASTLANE_ENV=osx
20 | - osx_image: xcode8.3
21 | env: FASTLANE_ENV=ios10_xcode8
22 | - osx_image: xcode7.3
23 | env: FASTLANE_ENV=ios9_xcode7
24 | - osx_image: xcode7.3
25 | env: FASTLANE_ENV=ios8_xcode7
26 | before_install:
27 | # Force bundler 1.12.5 because version 1.13 has issues, see https://github.com/fastlane/fastlane/issues/6065#issuecomment-246044617
28 | - gem uninstall bundler -v '>1.12.5' --force --executables || echo "bundler >1.12.5 is not installed"
29 | - gem install bundler -v 1.12.5 --no-rdoc --no-ri --no-document --quiet
30 | - gem install fastlane --no-rdoc --no-ri --no-document --quiet
31 | - gem install cocoapods --no-rdoc --no-ri --no-document --quiet
32 | script:
33 | - set -o pipefail
34 | - fastlane $FASTLANE_LANE configuration:Debug --env $FASTLANE_ENV
35 | - fastlane $FASTLANE_LANE configuration:Release --env $FASTLANE_ENV
36 | after_success:
37 | - if [ "$FASTLANE_LANE" == "code_coverage" ]; then
38 | bash <(curl -s https://codecov.io/bash);
39 | fi
40 | after_failure:
41 | - cat -n ~/Library/Logs/scan/*
42 | - cat -n $TMPDIR/com.apple.dt.XCTest-status/Session*.log
43 | - cat -n ~/Library/Logs/DiagnosticReports/xctest*.crash
44 | # deploy:
45 | # provider: script
46 | # script: fastlane complete_framework_release --env deploy
47 | # on:
48 | # tags: true
49 |
--------------------------------------------------------------------------------
/AFNetworking.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = 'AFNetworking'
3 | s.version = '3.2.0'
4 | s.license = 'MIT'
5 | s.summary = 'A delightful iOS and OS X networking framework.'
6 | s.homepage = 'https://github.com/AFNetworking/AFNetworking'
7 | s.social_media_url = 'https://twitter.com/AFNetworking'
8 | s.authors = { 'Mattt Thompson' => 'm@mattt.me' }
9 | s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => s.version, :submodules => true }
10 | s.requires_arc = true
11 |
12 | s.public_header_files = 'AFNetworking/AFNetworking.h'
13 | s.source_files = 'AFNetworking/AFNetworking.h'
14 |
15 | pch_AF = <<-EOS
16 | #ifndef TARGET_OS_IOS
17 | #define TARGET_OS_IOS TARGET_OS_IPHONE
18 | #endif
19 |
20 | #ifndef TARGET_OS_WATCH
21 | #define TARGET_OS_WATCH 0
22 | #endif
23 |
24 | #ifndef TARGET_OS_TV
25 | #define TARGET_OS_TV 0
26 | #endif
27 | EOS
28 | s.prefix_header_contents = pch_AF
29 |
30 | s.ios.deployment_target = '7.0'
31 | s.osx.deployment_target = '10.9'
32 | s.watchos.deployment_target = '2.0'
33 | s.tvos.deployment_target = '9.0'
34 |
35 | s.subspec 'Serialization' do |ss|
36 | ss.source_files = 'AFNetworking/AFURL{Request,Response}Serialization.{h,m}'
37 | ss.public_header_files = 'AFNetworking/AFURL{Request,Response}Serialization.h'
38 | ss.watchos.frameworks = 'MobileCoreServices', 'CoreGraphics'
39 | ss.ios.frameworks = 'MobileCoreServices', 'CoreGraphics'
40 | ss.osx.frameworks = 'CoreServices'
41 | end
42 |
43 | s.subspec 'Security' do |ss|
44 | ss.source_files = 'AFNetworking/AFSecurityPolicy.{h,m}'
45 | ss.public_header_files = 'AFNetworking/AFSecurityPolicy.h'
46 | ss.frameworks = 'Security'
47 | end
48 |
49 | s.subspec 'Reachability' do |ss|
50 | ss.ios.deployment_target = '7.0'
51 | ss.osx.deployment_target = '10.9'
52 | ss.tvos.deployment_target = '9.0'
53 |
54 | ss.source_files = 'AFNetworking/AFNetworkReachabilityManager.{h,m}'
55 | ss.public_header_files = 'AFNetworking/AFNetworkReachabilityManager.h'
56 |
57 | ss.frameworks = 'SystemConfiguration'
58 | end
59 |
60 | s.subspec 'NSURLSession' do |ss|
61 | ss.dependency 'AFNetworking/Serialization'
62 | ss.ios.dependency 'AFNetworking/Reachability'
63 | ss.osx.dependency 'AFNetworking/Reachability'
64 | ss.tvos.dependency 'AFNetworking/Reachability'
65 | ss.dependency 'AFNetworking/Security'
66 |
67 | ss.source_files = 'AFNetworking/AF{URL,HTTP}SessionManager.{h,m}'
68 | ss.public_header_files = 'AFNetworking/AF{URL,HTTP}SessionManager.h'
69 | end
70 |
71 | s.subspec 'UIKit' do |ss|
72 | ss.ios.deployment_target = '7.0'
73 | ss.tvos.deployment_target = '9.0'
74 | ss.dependency 'AFNetworking/NSURLSession'
75 |
76 | ss.public_header_files = 'UIKit+AFNetworking/*.h'
77 | ss.source_files = 'UIKit+AFNetworking'
78 | end
79 | end
80 |
--------------------------------------------------------------------------------
/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworking macOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
35 |
41 |
42 |
43 |
45 |
46 |
47 |
48 |
49 |
50 |
56 |
57 |
58 |
59 |
63 |
64 |
65 |
66 |
67 |
68 |
79 |
80 |
86 |
87 |
88 |
89 |
90 |
91 |
97 |
98 |
104 |
105 |
106 |
107 |
109 |
110 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworking watchOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
35 |
36 |
47 |
48 |
54 |
55 |
56 |
57 |
58 |
59 |
65 |
66 |
72 |
73 |
74 |
75 |
77 |
78 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/AFNetworking.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/AFNetworking/AFNetworking.h:
--------------------------------------------------------------------------------
1 | // AFNetworking.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.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
24 | #import
25 | #import
26 |
27 | #ifndef _AFNETWORKING_
28 | #define _AFNETWORKING_
29 |
30 | #import "AFURLRequestSerialization.h"
31 | #import "AFURLResponseSerialization.h"
32 | #import "AFSecurityPolicy.h"
33 |
34 | #if !TARGET_OS_WATCH
35 | #import "AFNetworkReachabilityManager.h"
36 | #endif
37 |
38 | #import "AFURLSessionManager.h"
39 | #import "AFHTTPSessionManager.h"
40 |
41 | #endif /* _AFNETWORKING_ */
42 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | This document contains information and guidelines about contributing to this project.
4 | Please read it before you start participating.
5 |
6 | **Topics**
7 |
8 | * [Asking Questions](#asking-questions)
9 | * [Reporting Security Issues](#reporting-security-issues)
10 | * [Reporting Issues](#reporting-other-issues)
11 | * [Submitting Pull Requests](#submitting-pull-requests)
12 | * [Developers Certificate of Origin](#developers-certificate-of-origin)
13 | * [Code of Conduct](#code-of-conduct)
14 |
15 | ## Asking Questions
16 |
17 | We don't use GitHub as a support forum.
18 | For any usage questions that are not specific to the project itself,
19 | please ask on [Stack Overflow](https://stackoverflow.com) instead.
20 | By doing so, you'll be more likely to quickly solve your problem,
21 | and you'll allow anyone else with the same question to find the answer.
22 | This also allows maintainers to focus on improving the project for others.
23 |
24 | ## Reporting Security Issues
25 |
26 | The Alamofire Software Foundation takes security seriously.
27 | If you discover a security issue, please bring it to our attention right away!
28 |
29 | Please **DO NOT** file a public issue,
30 | instead send your report privately to .
31 | This will help ensure that any vulnerabilities that _are_ found
32 | can be [disclosed responsibly](http://en.wikipedia.org/wiki/Responsible_disclosure)
33 | to any affected parties.
34 |
35 | ## Reporting Other Issues
36 |
37 | A great way to contribute to the project
38 | is to send a detailed issue when you encounter an problem.
39 | We always appreciate a well-written, thorough bug report.
40 |
41 | Check that the project issues database
42 | doesn't already include that problem or suggestion before submitting an issue.
43 | If you find a match, add a quick "+1" or "I have this problem too."
44 | Doing this helps prioritize the most common problems and requests.
45 |
46 | When reporting issues, please include the following:
47 |
48 | * The version of Xcode you're using
49 | * The version of iOS or OS X you're targeting
50 | * The full output of any stack trace or compiler error
51 | * A code snippet that reproduces the described behavior, if applicable
52 | * Any other details that would be useful in understanding the problem
53 |
54 | This information will help us review and fix your issue faster.
55 |
56 | ## Submitting Pull Requests
57 |
58 | Pull requests are welcome, and greatly encouraged. When submitting a pull request, please create proper test cases demonstrating the issue to be fixed or the new feature.
59 |
60 | ## Developer's Certificate of Origin 1.1
61 |
62 | By making a contribution to this project, I certify that:
63 |
64 | - (a) The contribution was created in whole or in part by me and I
65 | have the right to submit it under the open source license
66 | indicated in the file; or
67 |
68 | - (b) The contribution is based upon previous work that, to the best
69 | of my knowledge, is covered under an appropriate open source
70 | license and I have the right under that license to submit that
71 | work with modifications, whether created in whole or in part
72 | by me, under the same open source license (unless I am
73 | permitted to submit under a different license), as indicated
74 | in the file; or
75 |
76 | - (c) The contribution was provided directly to me by some other
77 | person who certified (a), (b) or (c) and I have not modified
78 | it.
79 |
80 | - (d) I understand and agree that this project and the contribution
81 | are public and that a record of the contribution (including all
82 | personal information I submit with it, including my sign-off) is
83 | maintained indefinitely and may be redistributed consistent with
84 | this project or the open source license(s) involved.
85 |
86 | ## Code of Conduct
87 |
88 | The Code of Conduct governs how we behave in public or in private
89 | whenever the project will be judged by our actions.
90 | We expect it to be honored by everyone who contributes to this project.
91 |
92 | See [CONDUCT.md](https://github.com/Alamofire/Foundation/blob/master/CONDUCT.md) for details.
93 |
94 | ---
95 |
96 | *Some of the ideas and wording for the statements above were based on work by the [Docker](https://github.com/docker/docker/blob/master/CONTRIBUTING.md) and [Linux](http://elinux.org/Developer_Certificate_Of_Origin) communities. We commend them for their efforts to facilitate collaboration in their projects.*
97 |
--------------------------------------------------------------------------------
/Example/AFNetworking Example.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.network.client
8 |
9 | com.apple.security.network.server
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Example/AFNetworking Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
45 |
46 |
48 |
54 |
55 |
56 |
57 |
58 |
64 |
65 |
66 |
67 |
68 |
69 |
80 |
82 |
88 |
89 |
90 |
91 |
92 |
93 |
99 |
101 |
107 |
108 |
109 |
110 |
112 |
113 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/Example/AFNetworking Example.xcodeproj/xcshareddata/xcschemes/macOS Example.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
45 |
46 |
48 |
54 |
55 |
56 |
57 |
58 |
64 |
65 |
66 |
67 |
68 |
69 |
80 |
82 |
88 |
89 |
90 |
91 |
92 |
93 |
99 |
101 |
107 |
108 |
109 |
110 |
112 |
113 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/Example/AFNetworking Example.xcodeproj/xcshareddata/xcschemes/tvOS Example.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
45 |
46 |
48 |
54 |
55 |
56 |
57 |
58 |
64 |
65 |
66 |
67 |
68 |
69 |
80 |
82 |
88 |
89 |
90 |
91 |
92 |
93 |
99 |
101 |
107 |
108 |
109 |
110 |
112 |
113 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/Example/AFNetworking watchOS/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "24x24",
5 | "idiom" : "watch",
6 | "scale" : "2x",
7 | "role" : "notificationCenter",
8 | "subtype" : "38mm"
9 | },
10 | {
11 | "size" : "27.5x27.5",
12 | "idiom" : "watch",
13 | "scale" : "2x",
14 | "role" : "notificationCenter",
15 | "subtype" : "42mm"
16 | },
17 | {
18 | "size" : "29x29",
19 | "idiom" : "watch",
20 | "role" : "companionSettings",
21 | "scale" : "2x"
22 | },
23 | {
24 | "size" : "29x29",
25 | "idiom" : "watch",
26 | "role" : "companionSettings",
27 | "scale" : "3x"
28 | },
29 | {
30 | "size" : "40x40",
31 | "idiom" : "watch",
32 | "scale" : "2x",
33 | "role" : "appLauncher",
34 | "subtype" : "38mm"
35 | },
36 | {
37 | "size" : "44x44",
38 | "idiom" : "watch",
39 | "scale" : "2x",
40 | "role" : "longLook",
41 | "subtype" : "42mm"
42 | },
43 | {
44 | "size" : "86x86",
45 | "idiom" : "watch",
46 | "scale" : "2x",
47 | "role" : "quickLook",
48 | "subtype" : "38mm"
49 | },
50 | {
51 | "size" : "98x98",
52 | "idiom" : "watch",
53 | "scale" : "2x",
54 | "role" : "quickLook",
55 | "subtype" : "42mm"
56 | }
57 | ],
58 | "info" : {
59 | "version" : 1,
60 | "author" : "xcode"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Example/AFNetworking watchOS/Base.lproj/Interface.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Example/AFNetworking watchOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | AFNetworking iOS Example
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | UISupportedInterfaceOrientations
26 |
27 | UIInterfaceOrientationPortrait
28 | UIInterfaceOrientationPortraitUpsideDown
29 |
30 | WKCompanionAppBundleIdentifier
31 | com.alamofire.AFNetworking-iOS-Example
32 | WKWatchKitApp
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Example/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x",
7 | "filename" : "Icon-Small@2x.png"
8 | },
9 | {
10 | "idiom" : "iphone",
11 | "size" : "29x29",
12 | "scale" : "3x",
13 | "filename" : "Icon-Small@3x.png"
14 | },
15 | {
16 | "idiom" : "iphone",
17 | "size" : "40x40",
18 | "scale" : "2x",
19 | "filename" : "Icon-40@2x.png"
20 | },
21 | {
22 | "idiom" : "iphone",
23 | "size" : "40x40",
24 | "scale" : "3x",
25 | "filename" : "Icon-40@3x.png"
26 | },
27 | {
28 | "idiom" : "iphone",
29 | "size" : "60x60",
30 | "scale" : "2x",
31 | "filename" : "Icon-60@2x.png"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "3x",
37 | "filename" : "Icon-60@3x.png"
38 | },
39 | {
40 | "idiom" : "ipad",
41 | "size" : "29x29",
42 | "scale" : "1x",
43 | "filename" : "Icon-Small.png"
44 | },
45 | {
46 | "idiom" : "ipad",
47 | "size" : "29x29",
48 | "scale" : "2x",
49 | "filename" : "Icon-Small@2x.png"
50 | },
51 | {
52 | "idiom" : "ipad",
53 | "size" : "40x40",
54 | "scale" : "1x",
55 | "filename" : "Icon-40.png"
56 | },
57 | {
58 | "idiom" : "ipad",
59 | "size" : "40x40",
60 | "scale" : "2x",
61 | "filename" : "Icon-40@2x.png"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "76x76",
66 | "scale" : "1x",
67 | "filename" : "Icon-76.png"
68 | },
69 | {
70 | "idiom" : "ipad",
71 | "size" : "76x76",
72 | "scale" : "2x",
73 | "filename" : "Icon-76@2x.png"
74 | }
75 | ],
76 | "info" : {
77 | "version" : 1,
78 | "author" : "makeappicon"
79 | }
80 | }
--------------------------------------------------------------------------------
/Example/Assets.xcassets/AppIcon.appiconset/Icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Assets.xcassets/AppIcon.appiconset/Icon-40.png
--------------------------------------------------------------------------------
/Example/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png
--------------------------------------------------------------------------------
/Example/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png
--------------------------------------------------------------------------------
/Example/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png
--------------------------------------------------------------------------------
/Example/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png
--------------------------------------------------------------------------------
/Example/Assets.xcassets/AppIcon.appiconset/Icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Assets.xcassets/AppIcon.appiconset/Icon-76.png
--------------------------------------------------------------------------------
/Example/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png
--------------------------------------------------------------------------------
/Example/Assets.xcassets/AppIcon.appiconset/Icon-Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Assets.xcassets/AppIcon.appiconset/Icon-Small.png
--------------------------------------------------------------------------------
/Example/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png
--------------------------------------------------------------------------------
/Example/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png
--------------------------------------------------------------------------------
/Example/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Example/Assets.xcassets/profile-image-placeholder.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "profile-image-placeholder.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "profile-image-placeholder@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/Example/Assets.xcassets/profile-image-placeholder.imageset/profile-image-placeholder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Assets.xcassets/profile-image-placeholder.imageset/profile-image-placeholder.png
--------------------------------------------------------------------------------
/Example/Assets.xcassets/profile-image-placeholder.imageset/profile-image-placeholder@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Assets.xcassets/profile-image-placeholder.imageset/profile-image-placeholder@2x.png
--------------------------------------------------------------------------------
/Example/Certificates/adn.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Certificates/adn.cer
--------------------------------------------------------------------------------
/Example/Certificates/digicert_ca_3.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Certificates/digicert_ca_3.cer
--------------------------------------------------------------------------------
/Example/Certificates/root_ca.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Example/Certificates/root_ca.cer
--------------------------------------------------------------------------------
/Example/Classes/Models/Post.h:
--------------------------------------------------------------------------------
1 | // Post.h
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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
24 |
25 | @class User;
26 |
27 | @interface Post : NSObject
28 |
29 | @property (nonatomic, assign) NSUInteger postID;
30 | @property (nonatomic, strong) NSString *text;
31 |
32 | @property (nonatomic, strong) User *user;
33 |
34 | - (instancetype)initWithAttributes:(NSDictionary *)attributes;
35 |
36 | + (NSURLSessionDataTask *)globalTimelinePostsWithBlock:(void (^)(NSArray *posts, NSError *error))block;
37 |
38 | @end
39 |
40 | @interface Post (NSCoding)
41 | @end
42 |
--------------------------------------------------------------------------------
/Example/Classes/Models/Post.m:
--------------------------------------------------------------------------------
1 | // Post.m
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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 "Post.h"
24 | #import "User.h"
25 |
26 | #import "AFAppDotNetAPIClient.h"
27 |
28 | @implementation Post
29 |
30 | - (instancetype)initWithAttributes:(NSDictionary *)attributes {
31 | self = [super init];
32 | if (!self) {
33 | return nil;
34 | }
35 |
36 | self.postID = (NSUInteger)[[attributes valueForKeyPath:@"id"] integerValue];
37 | self.text = [attributes valueForKeyPath:@"text"];
38 |
39 | self.user = [[User alloc] initWithAttributes:[attributes valueForKeyPath:@"user"]];
40 |
41 | return self;
42 | }
43 |
44 | #pragma mark -
45 |
46 | + (NSURLSessionDataTask *)globalTimelinePostsWithBlock:(void (^)(NSArray *posts, NSError *error))block {
47 | return [[AFAppDotNetAPIClient sharedClient] GET:@"stream/0/posts/stream/global" parameters:nil progress:nil success:^(NSURLSessionDataTask * __unused task, id JSON) {
48 | NSArray *postsFromResponse = [JSON valueForKeyPath:@"data"];
49 | NSMutableArray *mutablePosts = [NSMutableArray arrayWithCapacity:[postsFromResponse count]];
50 | for (NSDictionary *attributes in postsFromResponse) {
51 | Post *post = [[Post alloc] initWithAttributes:attributes];
52 | [mutablePosts addObject:post];
53 | }
54 |
55 | if (block) {
56 | block([NSArray arrayWithArray:mutablePosts], nil);
57 | }
58 | } failure:^(NSURLSessionDataTask *__unused task, NSError *error) {
59 | if (block) {
60 | block([NSArray array], error);
61 | }
62 | }];
63 | }
64 |
65 | @end
66 |
67 | @implementation Post (NSCoding)
68 |
69 | - (void)encodeWithCoder:(NSCoder *)aCoder {
70 | [aCoder encodeInteger:(NSInteger)self.postID forKey:@"AF.postID"];
71 | [aCoder encodeObject:self.text forKey:@"AF.text"];
72 | [aCoder encodeObject:self.user forKey:@"AF.user"];
73 | }
74 |
75 | - (instancetype)initWithCoder:(NSCoder *)aDecoder {
76 | self = [super init];
77 | if (!self) {
78 | return nil;
79 | }
80 |
81 | self.postID = (NSUInteger)[aDecoder decodeIntegerForKey:@"AF.postID"];
82 | self.text = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"AF.text"];
83 | self.user = [aDecoder decodeObjectOfClass:[User class] forKey:@"AF.user"];
84 |
85 | return self;
86 | }
87 |
88 | + (BOOL)supportsSecureCoding {
89 | return YES;
90 | }
91 |
92 | @end
93 |
--------------------------------------------------------------------------------
/Example/Classes/Models/User.h:
--------------------------------------------------------------------------------
1 | // User.h
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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
24 |
25 | extern NSString * const kUserProfileImageDidLoadNotification;
26 |
27 | @interface User : NSObject
28 |
29 | @property (readonly, nonatomic, assign) NSUInteger userID;
30 | @property (readonly, nonatomic, copy) NSString *username;
31 | @property (readonly, nonatomic, unsafe_unretained) NSURL *avatarImageURL;
32 |
33 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
34 | @property (nonatomic, strong) NSImage *profileImage;
35 | #endif
36 |
37 | - (instancetype)initWithAttributes:(NSDictionary *)attributes;
38 |
39 | @end
40 |
41 | @interface User (NSCoding)
42 | @end
43 |
--------------------------------------------------------------------------------
/Example/Classes/Models/User.m:
--------------------------------------------------------------------------------
1 | // User.m
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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 "User.h"
24 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
25 | //#import "AFHTTPRequestOperation.h"
26 | #endif
27 |
28 | NSString * const kUserProfileImageDidLoadNotification = @"com.alamofire.user.profile-image.loaded";
29 |
30 | @interface User ()
31 | @property (readwrite, nonatomic, assign) NSUInteger userID;
32 | @property (readwrite, nonatomic, copy) NSString *username;
33 | @property (readwrite, nonatomic, copy) NSString *avatarImageURLString;
34 |
35 | //#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
36 | //@property (readwrite, nonatomic, strong) AFHTTPRequestOperation *avatarImageRequestOperation;
37 | //#endif
38 | @end
39 |
40 | @implementation User
41 |
42 | - (instancetype)initWithAttributes:(NSDictionary *)attributes {
43 | self = [super init];
44 | if (!self) {
45 | return nil;
46 | }
47 |
48 | self.userID = (NSUInteger)[[attributes valueForKeyPath:@"id"] integerValue];
49 | self.username = [attributes valueForKeyPath:@"username"];
50 | self.avatarImageURLString = [attributes valueForKeyPath:@"avatar_image.url"];
51 |
52 | return self;
53 | }
54 |
55 | - (NSURL *)avatarImageURL {
56 | return [NSURL URLWithString:self.avatarImageURLString];
57 | }
58 |
59 | #pragma mark -
60 |
61 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
62 |
63 | //+ (NSOperationQueue *)sharedProfileImageRequestOperationQueue {
64 | // static NSOperationQueue *_sharedProfileImageRequestOperationQueue = nil;
65 | // static dispatch_once_t onceToken;
66 | // dispatch_once(&onceToken, ^{
67 | // _sharedProfileImageRequestOperationQueue = [[NSOperationQueue alloc] init];
68 | // [_sharedProfileImageRequestOperationQueue setMaxConcurrentOperationCount:8];
69 | // });
70 | //
71 | // return _sharedProfileImageRequestOperationQueue;
72 | //}
73 |
74 | - (NSImage *)profileImage {
75 | return nil;
76 | // if (!_profileImage && !_avatarImageRequestOperation) {
77 | // NSMutableURLRequest *mutableRequest = [NSMutableURLRequest requestWithURL:self.avatarImageURL];
78 | // [mutableRequest setValue:@"image/*" forHTTPHeaderField:@"Accept"];
79 | // AFHTTPRequestOperation *imageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:mutableRequest];
80 | // imageRequestOperation.responseSerializer = [AFImageResponseSerializer serializer];
81 | // [imageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, NSImage *responseImage) {
82 | // self.profileImage = responseImage;
83 | //
84 | // _avatarImageRequestOperation = nil;
85 | //
86 | // [[NSNotificationCenter defaultCenter] postNotificationName:kUserProfileImageDidLoadNotification object:self userInfo:nil];
87 | // } failure:nil];
88 | //
89 | // [imageRequestOperation setCacheResponseBlock:^NSCachedURLResponse *(NSURLConnection *connection, NSCachedURLResponse *cachedResponse) {
90 | // return [[NSCachedURLResponse alloc] initWithResponse:cachedResponse.response data:cachedResponse.data userInfo:cachedResponse.userInfo storagePolicy:NSURLCacheStorageAllowed];
91 | // }];
92 | //
93 | // _avatarImageRequestOperation = imageRequestOperation;
94 | //
95 | // [[[self class] sharedProfileImageRequestOperationQueue] addOperation:_avatarImageRequestOperation];
96 | // }
97 | //
98 | // return _profileImage;
99 | }
100 |
101 | #endif
102 |
103 | @end
104 |
105 | @implementation User (NSCoding)
106 |
107 | - (void)encodeWithCoder:(NSCoder *)aCoder {
108 | [aCoder encodeInteger:(NSInteger)self.userID forKey:@"AF.userID"];
109 | [aCoder encodeObject:self.username forKey:@"AF.username"];
110 | [aCoder encodeObject:self.avatarImageURLString forKey:@"AF.avatarImageURLString"];
111 | }
112 |
113 | - (instancetype)initWithCoder:(NSCoder *)aDecoder {
114 | self = [super init];
115 | if (!self) {
116 | return nil;
117 | }
118 |
119 | self.userID = (NSUInteger)[aDecoder decodeIntegerForKey:@"AF.userID"];
120 | self.username = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"AF.username"];
121 | self.avatarImageURLString = [aDecoder decodeObjectOfClass:[User class] forKey:@"AF.avatarImageURLString"];
122 |
123 | return self;
124 | }
125 |
126 | + (BOOL)supportsSecureCoding {
127 | return YES;
128 | }
129 |
130 | @end
131 |
--------------------------------------------------------------------------------
/Example/Classes/Networking Extensions/AFAppDotNetAPIClient.h:
--------------------------------------------------------------------------------
1 | // AFAppDotNetAPIClient.h
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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
24 | @import AFNetworking;
25 |
26 | @interface AFAppDotNetAPIClient : AFHTTPSessionManager
27 |
28 | + (instancetype)sharedClient;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/Example/Classes/Networking Extensions/AFAppDotNetAPIClient.m:
--------------------------------------------------------------------------------
1 | // AFAppDotNetAPIClient.h
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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 "AFAppDotNetAPIClient.h"
24 |
25 | static NSString * const AFAppDotNetAPIBaseURLString = @"https://api.app.net/";
26 |
27 | @implementation AFAppDotNetAPIClient
28 |
29 | + (instancetype)sharedClient {
30 | static AFAppDotNetAPIClient *_sharedClient = nil;
31 | static dispatch_once_t onceToken;
32 | dispatch_once(&onceToken, ^{
33 | _sharedClient = [[AFAppDotNetAPIClient alloc] initWithBaseURL:[NSURL URLWithString:AFAppDotNetAPIBaseURLString]];
34 | _sharedClient.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
35 | });
36 |
37 | return _sharedClient;
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/Example/Prefix.pch:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #if __IPHONE_OS_VERSION_MIN_REQUIRED
4 | #ifndef __IPHONE_6_0
5 | #warning "This project uses features only available in iPhone SDK 6.0 and later."
6 | #endif
7 |
8 | #ifdef __OBJC__
9 | #import
10 | #import
11 | #import
12 | #import
13 | #endif
14 | #else
15 | #ifdef __OBJC__
16 | #import
17 | #import
18 | #import
19 | #import
20 | #endif
21 | #endif
22 |
--------------------------------------------------------------------------------
/Example/Today Extension Example/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | Today Extension Example
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | XPC!
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | NSExtension
26 |
27 | NSExtensionMainStoryboard
28 | MainInterface
29 | NSExtensionPointIdentifier
30 | com.apple.widget-extension
31 |
32 | NSAppTransportSecurity
33 |
34 | NSExceptionDomains
35 |
36 | cloudfront.net
37 |
38 | NSIncludesSubdomains
39 |
40 | NSThirdPartyExceptionMinimumTLSVersion
41 | TLSv1.0
42 | NSThirdPartyExceptionRequiresForwardSecrecy
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/Example/Today Extension Example/TodayViewController.h:
--------------------------------------------------------------------------------
1 | // TodayViewController.h
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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
24 |
25 | @interface TodayViewController : UIViewController
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/Example/Today Extension Example/TodayViewController.m:
--------------------------------------------------------------------------------
1 | // TodayViewController.m
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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
24 | #import "TodayViewController.h"
25 | #import "Post.h"
26 | #import "User.h"
27 | @import AFNetworking;
28 |
29 | @interface TodayViewController ()
30 | @property (strong, nonatomic) IBOutlet UIImageView *imageView;
31 | @property (strong, nonatomic) IBOutlet UILabel *titleLabel;
32 | @property (strong, nonatomic) IBOutlet UILabel *bodyLabel;
33 | @property (nonatomic, strong) Post *post;
34 | @end
35 |
36 | @implementation TodayViewController
37 |
38 | - (void)viewDidLoad {
39 | [super viewDidLoad];
40 |
41 | NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil];
42 | [NSURLCache setSharedURLCache:URLCache];
43 | self.post = [self loadSavedPost];
44 | }
45 |
46 | - (void)viewWillAppear:(BOOL)animated {
47 | [super viewWillAppear:animated];
48 | }
49 |
50 | - (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
51 | [Post globalTimelinePostsWithBlock:^(NSArray *posts, NSError *error) {
52 | if (!error) {
53 |
54 | self.post = posts.firstObject;
55 | [self savePost:self.post];
56 |
57 | if (completionHandler) {
58 | completionHandler(self.post != nil ? NCUpdateResultNewData : NCUpdateResultNoData);
59 | }
60 |
61 | } else {
62 | if (completionHandler) {
63 | completionHandler(NCUpdateResultFailed);
64 | }
65 | }
66 | }];
67 | }
68 |
69 | - (void)setPost:(Post *)post {
70 | _post = post;
71 |
72 | self.titleLabel.hidden = post == nil;
73 | self.bodyLabel.hidden = post == nil;
74 | self.imageView.hidden = post == nil;
75 |
76 | if (post == nil) {
77 | return;
78 | }
79 |
80 | self.titleLabel.text = _post.user.username;
81 | self.bodyLabel.text = _post.text;
82 | [self.imageView setImageWithURL:_post.user.avatarImageURL placeholderImage:[UIImage imageNamed:@"profile-image-placeholder"]];
83 | }
84 |
85 | - (void)savePost:(Post *)post {
86 |
87 | if (post == nil) {
88 | [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"AF.post"];
89 | [[NSUserDefaults standardUserDefaults] synchronize];
90 | return;
91 | }
92 |
93 | NSData *postData = [NSKeyedArchiver archivedDataWithRootObject:post];
94 | [[NSUserDefaults standardUserDefaults] setObject:postData forKey:@"AF.post"];
95 | [[NSUserDefaults standardUserDefaults] synchronize];
96 | }
97 |
98 | - (Post *)loadSavedPost {
99 | NSData *postData = [[NSUserDefaults standardUserDefaults] objectForKey:@"AF.post"];
100 | if (postData == nil || ![postData isKindOfClass:[NSData class]]) {
101 | return nil;
102 | }
103 |
104 | return [NSKeyedUnarchiver unarchiveObjectWithData:postData];
105 | }
106 |
107 | @end
108 |
--------------------------------------------------------------------------------
/Example/iOS Example/AppDelegate.h:
--------------------------------------------------------------------------------
1 | // AppDelegate.h
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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
24 |
25 | @interface AppDelegate : NSObject
26 |
27 | @property (nonatomic, strong) UIWindow *window;
28 | @property (nonatomic, strong) UINavigationController *navigationController;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/Example/iOS Example/AppDelegate.m:
--------------------------------------------------------------------------------
1 | // AppDelegate.m
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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 "AppDelegate.h"
24 | @import AFNetworking;
25 |
26 | #import "GlobalTimelineViewController.h"
27 |
28 | @implementation AppDelegate
29 |
30 | - (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWithOptions:(__unused NSDictionary *)launchOptions
31 | {
32 | NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil];
33 | [NSURLCache setSharedURLCache:URLCache];
34 |
35 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
36 |
37 | UITableViewController *viewController = [[GlobalTimelineViewController alloc] initWithStyle:UITableViewStylePlain];
38 | self.navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
39 | self.navigationController.navigationBar.tintColor = [UIColor darkGrayColor];
40 |
41 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
42 | self.window.backgroundColor = [UIColor whiteColor];
43 | self.window.rootViewController = self.navigationController;
44 | [self.window makeKeyAndVisible];
45 |
46 | return YES;
47 | }
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/Example/iOS Example/Controllers/GlobalTimelineViewController.h:
--------------------------------------------------------------------------------
1 | // GlobalTimelineViewController.h
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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
24 |
25 | @interface GlobalTimelineViewController : UITableViewController
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/Example/iOS Example/Controllers/GlobalTimelineViewController.m:
--------------------------------------------------------------------------------
1 | // GlobalTimelineViewController.m
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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 "GlobalTimelineViewController.h"
24 |
25 | #import "Post.h"
26 |
27 | #import "PostTableViewCell.h"
28 |
29 | @import AFNetworking;
30 |
31 | @interface GlobalTimelineViewController ()
32 | @property (readwrite, nonatomic, strong) NSArray *posts;
33 | @end
34 |
35 | @implementation GlobalTimelineViewController
36 |
37 | - (void)reload:(__unused id)sender {
38 | self.navigationItem.rightBarButtonItem.enabled = NO;
39 |
40 | NSURLSessionTask *task = [Post globalTimelinePostsWithBlock:^(NSArray *posts, NSError *error) {
41 | if (!error) {
42 | self.posts = posts;
43 | [self.tableView reloadData];
44 | }
45 | }];
46 |
47 | [self.refreshControl setRefreshingWithStateOfTask:task];
48 | }
49 |
50 | #pragma mark - UIViewController
51 |
52 | - (void)viewDidLoad {
53 | [super viewDidLoad];
54 |
55 | self.title = NSLocalizedString(@"AFNetworking", nil);
56 |
57 | self.refreshControl = [[UIRefreshControl alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableView.frame.size.width, 100.0f)];
58 | [self.refreshControl addTarget:self action:@selector(reload:) forControlEvents:UIControlEventValueChanged];
59 | [self.tableView.tableHeaderView addSubview:self.refreshControl];
60 |
61 | self.tableView.rowHeight = 70.0f;
62 |
63 | [self reload:nil];
64 | }
65 |
66 | #pragma mark - UITableViewDataSource
67 |
68 | - (NSInteger)tableView:(__unused UITableView *)tableView
69 | numberOfRowsInSection:(__unused NSInteger)section
70 | {
71 | return (NSInteger)[self.posts count];
72 | }
73 |
74 | - (UITableViewCell *)tableView:(UITableView *)tableView
75 | cellForRowAtIndexPath:(NSIndexPath *)indexPath
76 | {
77 | static NSString *CellIdentifier = @"Cell";
78 |
79 | PostTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
80 | if (!cell) {
81 | cell = [[PostTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
82 | }
83 |
84 | cell.post = self.posts[(NSUInteger)indexPath.row];
85 |
86 | return cell;
87 | }
88 |
89 | #pragma mark - UITableViewDelegate
90 |
91 | - (CGFloat)tableView:(__unused UITableView *)tableView
92 | heightForRowAtIndexPath:(NSIndexPath *)indexPath
93 | {
94 | return [PostTableViewCell heightForCellWithPost:self.posts[(NSUInteger)indexPath.row]];
95 | }
96 |
97 | - (void)tableView:(UITableView *)tableView
98 | didSelectRowAtIndexPath:(NSIndexPath *)indexPath
99 | {
100 | [tableView deselectRowAtIndexPath:indexPath animated:YES];
101 | }
102 |
103 | @end
104 |
--------------------------------------------------------------------------------
/Example/iOS Example/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | AFNetworking
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIconFile
12 |
13 | CFBundleIconFiles
14 |
15 | Icon.png
16 | Icon@2x.png
17 |
18 | CFBundleIcons
19 |
20 | CFBundleIcons~ipad
21 |
22 | CFBundleIdentifier
23 | $(PRODUCT_BUNDLE_IDENTIFIER)
24 | CFBundleInfoDictionaryVersion
25 | 6.0
26 | CFBundleName
27 | ${PRODUCT_NAME}
28 | CFBundlePackageType
29 | APPL
30 | CFBundleShortVersionString
31 | 1.0
32 | CFBundleSignature
33 | ????
34 | CFBundleVersion
35 | 1.0.0
36 | LSRequiresIPhoneOS
37 |
38 | NSAppTransportSecurity
39 |
40 | NSExceptionDomains
41 |
42 | cloudfront.net
43 |
44 | NSIncludesSubdomains
45 |
46 | NSThirdPartyExceptionMinimumTLSVersion
47 | TLSv1.0
48 | NSThirdPartyExceptionRequiresForwardSecrecy
49 |
50 |
51 |
52 |
53 | UIBackgroundModes
54 |
55 | fetch
56 |
57 | UILaunchStoryboardName
58 | Launchscreen
59 | UIPrerenderedIcon
60 |
61 | UIStatusBarHidden
62 |
63 | UISupportedInterfaceOrientations
64 |
65 | UIInterfaceOrientationPortrait
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/Example/iOS Example/Launchscreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/Example/iOS Example/Views/PostTableViewCell.h:
--------------------------------------------------------------------------------
1 | // TweetTableViewCell.h
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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
24 |
25 | @class Post;
26 |
27 | @interface PostTableViewCell : UITableViewCell
28 |
29 | @property (nonatomic, strong) Post *post;
30 |
31 | + (CGFloat)heightForCellWithPost:(Post *)post;
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/Example/iOS Example/Views/PostTableViewCell.m:
--------------------------------------------------------------------------------
1 | // TweetTableViewCell.m
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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 "PostTableViewCell.h"
24 |
25 | #import "Post.h"
26 | #import "User.h"
27 |
28 | @import AFNetworking;
29 |
30 | @implementation PostTableViewCell
31 |
32 | - (instancetype)initWithStyle:(UITableViewCellStyle)style
33 | reuseIdentifier:(NSString *)reuseIdentifier
34 | {
35 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
36 | if (!self) {
37 | return nil;
38 | }
39 |
40 | self.textLabel.adjustsFontSizeToFitWidth = YES;
41 | self.textLabel.textColor = [UIColor darkGrayColor];
42 | self.detailTextLabel.font = [UIFont systemFontOfSize:12.0f];
43 | self.detailTextLabel.numberOfLines = 0;
44 | self.selectionStyle = UITableViewCellSelectionStyleGray;
45 |
46 | return self;
47 | }
48 |
49 | - (void)setPost:(Post *)post {
50 | _post = post;
51 |
52 | self.textLabel.text = _post.user.username;
53 | self.detailTextLabel.text = _post.text;
54 | [self.imageView setImageWithURL:_post.user.avatarImageURL placeholderImage:[UIImage imageNamed:@"profile-image-placeholder"]];
55 |
56 | [self setNeedsLayout];
57 | }
58 |
59 | + (CGFloat)heightForCellWithPost:(Post *)post {
60 | return (CGFloat)fmaxf(70.0f, (float)[self detailTextHeight:post.text] + 45.0f);
61 | }
62 |
63 | + (CGFloat)detailTextHeight:(NSString *)text {
64 | CGRect rectToFit = [text boundingRectWithSize:CGSizeMake(240.0f, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12.0f]} context:nil];
65 | return rectToFit.size.height;
66 | }
67 |
68 | #pragma mark - UIView
69 |
70 | - (void)layoutSubviews {
71 | [super layoutSubviews];
72 |
73 | self.imageView.frame = CGRectMake(10.0f, 10.0f, 50.0f, 50.0f);
74 | self.textLabel.frame = CGRectMake(70.0f, 6.0f, 240.0f, 20.0f);
75 |
76 | CGRect detailTextLabelFrame = CGRectOffset(self.textLabel.frame, 0.0f, 25.0f);
77 | CGFloat calculatedHeight = [[self class] detailTextHeight:self.post.text];
78 | detailTextLabelFrame.size.height = calculatedHeight;
79 | self.detailTextLabel.frame = detailTextLabelFrame;
80 | }
81 |
82 | @end
83 |
--------------------------------------------------------------------------------
/Example/macOS Example/AppDelegate.h:
--------------------------------------------------------------------------------
1 | // AppDelegate.h
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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
24 |
25 | @interface AppDelegate : NSObject
26 |
27 | @property (strong) IBOutlet NSWindow *window;
28 | @property (strong) IBOutlet NSTableView *tableView;
29 | @property (strong) IBOutlet NSArrayController *postsArrayController;
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/Example/macOS Example/AppDelegate.m:
--------------------------------------------------------------------------------
1 | // AppDelegate.m
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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 "AppDelegate.h"
24 | @import AFNetworking;
25 |
26 | #import "Post.h"
27 | #import "User.h"
28 |
29 | @implementation AppDelegate
30 |
31 | - (void)applicationDidFinishLaunching:(NSNotification *)notification {
32 | NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil];
33 | [NSURLCache setSharedURLCache:URLCache];
34 |
35 | [self.window makeKeyAndOrderFront:self];
36 |
37 | [Post globalTimelinePostsWithBlock:^(NSArray *posts, NSError *error) {
38 | if (error) {
39 | NSAlert *alert = [[NSAlert alloc] init];
40 | alert.messageText = NSLocalizedString(@"Error", nil);
41 | alert.informativeText = error.localizedDescription;
42 | [alert addButtonWithTitle:NSLocalizedString(@"OK", nil)];
43 | [alert runModal];
44 | }
45 |
46 | self.postsArrayController.content = posts;
47 | }];
48 |
49 | [[NSNotificationCenter defaultCenter] addObserverForName:kUserProfileImageDidLoadNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
50 | [self.tableView reloadData];
51 | }];
52 | }
53 |
54 | - (BOOL)applicationShouldHandleReopen:(NSApplication *)application
55 | hasVisibleWindows:(BOOL)flag
56 | {
57 | [self.window makeKeyAndOrderFront:self];
58 |
59 | return YES;
60 | }
61 |
62 | @end
63 |
--------------------------------------------------------------------------------
/Example/macOS Example/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/Example/macOS Example/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSMinimumSystemVersion
26 | $(MACOSX_DEPLOYMENT_TARGET)
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Example/macOS Example/main.m:
--------------------------------------------------------------------------------
1 | // main.m
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | int main(int argc, const char * argv[]) {
25 | return NSApplicationMain(argc, argv);
26 | }
27 |
--------------------------------------------------------------------------------
/Example/main.m:
--------------------------------------------------------------------------------
1 | // main.m
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 | #if TARGET_OS_IOS || TARGET_OS_TV
24 | #import
25 |
26 | int main(int argc, char *argv[]) {
27 | @autoreleasepool {
28 | int retVal = UIApplicationMain(argc, argv, @"UIApplication", @"AppDelegate");
29 | return retVal;
30 | }
31 | }
32 | #else
33 | #import
34 |
35 | int main(int argc, char *argv[]) {
36 | return NSApplicationMain(argc, (const char **)argv);
37 | }
38 | #endif
39 |
--------------------------------------------------------------------------------
/Example/tvOS Example/AFNetworking tvOS Example-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Use this file to import your target's public headers that you would like to expose to Swift.
3 | //
4 |
5 | #import
6 | @import AFNetworking;
--------------------------------------------------------------------------------
/Example/tvOS Example/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | // AppDelegate.swift
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | import UIKit
23 |
24 | @UIApplicationMain
25 | class AppDelegate: UIResponder, UIApplicationDelegate {
26 |
27 | var window: UIWindow?
28 |
29 |
30 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
31 | // Override point for customization after application launch.
32 | return true
33 | }
34 |
35 | func applicationWillResignActive(_ application: UIApplication) {
36 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
37 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
38 | }
39 |
40 | func applicationDidEnterBackground(_ application: UIApplication) {
41 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
42 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
43 | }
44 |
45 | func applicationWillEnterForeground(_ application: UIApplication) {
46 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
47 | }
48 |
49 | func applicationDidBecomeActive(_ application: UIApplication) {
50 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
51 | }
52 |
53 | func applicationWillTerminate(_ application: UIApplication) {
54 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
55 | }
56 |
57 |
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "layers" : [
3 | {
4 | "filename" : "Front.imagestacklayer"
5 | },
6 | {
7 | "filename" : "Middle.imagestacklayer"
8 | },
9 | {
10 | "filename" : "Back.imagestacklayer"
11 | }
12 | ],
13 | "info" : {
14 | "version" : 1,
15 | "author" : "xcode"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "layers" : [
3 | {
4 | "filename" : "Front.imagestacklayer"
5 | },
6 | {
7 | "filename" : "Middle.imagestacklayer"
8 | },
9 | {
10 | "filename" : "Back.imagestacklayer"
11 | }
12 | ],
13 | "info" : {
14 | "version" : 1,
15 | "author" : "xcode"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "assets" : [
3 | {
4 | "size" : "1280x768",
5 | "idiom" : "tv",
6 | "filename" : "App Icon - Large.imagestack",
7 | "role" : "primary-app-icon"
8 | },
9 | {
10 | "size" : "400x240",
11 | "idiom" : "tv",
12 | "filename" : "App Icon - Small.imagestack",
13 | "role" : "primary-app-icon"
14 | },
15 | {
16 | "size" : "1920x720",
17 | "idiom" : "tv",
18 | "filename" : "Top Shelf Image.imageset",
19 | "role" : "top-shelf-image"
20 | }
21 | ],
22 | "info" : {
23 | "version" : 1,
24 | "author" : "xcode"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "tv",
5 | "scale" : "1x"
6 | }
7 | ],
8 | "info" : {
9 | "version" : 1,
10 | "author" : "xcode"
11 | }
12 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Assets.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "landscape",
5 | "idiom" : "tv",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "9.0",
8 | "scale" : "1x"
9 | }
10 | ],
11 | "info" : {
12 | "version" : 1,
13 | "author" : "xcode"
14 | }
15 | }
--------------------------------------------------------------------------------
/Example/tvOS Example/Gravatar.swift:
--------------------------------------------------------------------------------
1 | // Gravatar.swift
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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
24 | import UIKit
25 |
26 | private extension String {
27 | var md5_hash: String {
28 | let trimmedString = lowercased().trimmingCharacters(in: CharacterSet.whitespaces)
29 | let utf8String = trimmedString.cString(using: String.Encoding.utf8)!
30 | let stringLength = CC_LONG(trimmedString.lengthOfBytes(using: String.Encoding.utf8))
31 | let digestLength = Int(CC_MD5_DIGEST_LENGTH)
32 | let result = UnsafeMutablePointer.allocate(capacity: digestLength)
33 |
34 | CC_MD5(utf8String, stringLength, result)
35 |
36 | var hash = ""
37 |
38 | for i in 0.. Foundation.URL {
102 | let URL = Gravatar.baseURL.appendingPathComponent(email.md5_hash)
103 | var components = URLComponents(url: URL, resolvingAgainstBaseURL: false)!
104 |
105 | var queryItems = [defaultImage.queryItem, rating.queryItem]
106 | queryItems.append(URLQueryItem(name: "f", value: forceDefault ? "y" : "n"))
107 | queryItems.append(URLQueryItem(name: "s", value: String(format: "%.0f",size * scale)))
108 |
109 | components.queryItems = queryItems
110 |
111 | return components.url!
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/Example/tvOS Example/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | arm64
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Example/tvOS Example/ViewController.swift:
--------------------------------------------------------------------------------
1 | // ViewController.swift
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | import UIKit
23 |
24 | class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
25 |
26 | @IBOutlet var collectionView: UICollectionView!
27 | var gravatars: [Gravatar] = []
28 |
29 | override func viewDidLoad() {
30 | super.viewDidLoad()
31 |
32 | for _ in 1...100 {
33 | let gravatar = Gravatar(
34 | emailAddress: UUID().uuidString,
35 | defaultImage: Gravatar.DefaultImage.Identicon,
36 | forceDefault: true
37 | )
38 |
39 | gravatars.append(gravatar)
40 | }
41 | }
42 |
43 | override func didReceiveMemoryWarning() {
44 | super.didReceiveMemoryWarning()
45 | // Dispose of any resources that can be recreated.
46 | }
47 |
48 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
49 | return gravatars.count
50 | }
51 |
52 | func numberOfSections(in collectionView: UICollectionView) -> Int {
53 | return 1
54 | }
55 |
56 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
57 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CollectionViewCell", for: indexPath) as! CollectionViewCell
58 | cell.update(forGravatar: gravatars[(indexPath as NSIndexPath).item])
59 | return cell
60 | }
61 |
62 | func collectionView(_ collectionView: UICollectionView, canFocusItemAt indexPath: IndexPath) -> Bool {
63 | return true
64 | }
65 |
66 | }
67 |
68 | class CollectionViewCell : UICollectionViewCell {
69 | @IBOutlet var avatarView: UIImageView!
70 |
71 | override func prepareForReuse() {
72 | self.avatarView.image = nil
73 | }
74 |
75 | func update(forGravatar gravatar:Gravatar) {
76 | self.avatarView.setImageWith(gravatar.URL(size: self.bounds.size.width) as URL)
77 | }
78 | }
79 |
80 |
--------------------------------------------------------------------------------
/Example/watchOS Example Extension/Assets.xcassets/README__ignoredByTemplate__:
--------------------------------------------------------------------------------
1 | Did you know that git does not support storing empty directories?
2 |
--------------------------------------------------------------------------------
/Example/watchOS Example Extension/ExtensionDelegate.h:
--------------------------------------------------------------------------------
1 | // ExtensionDelegate.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | @interface ExtensionDelegate : NSObject
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/Example/watchOS Example Extension/ExtensionDelegate.m:
--------------------------------------------------------------------------------
1 | // ExtensionDelegate.m
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "ExtensionDelegate.h"
23 |
24 | @implementation ExtensionDelegate
25 |
26 | - (void)applicationDidFinishLaunching {
27 | // Perform any final initialization of your application.
28 | }
29 |
30 | - (void)applicationDidBecomeActive {
31 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
32 | }
33 |
34 | - (void)applicationWillResignActive {
35 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
36 | // Use this method to pause ongoing tasks, disable timers, etc.
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/Example/watchOS Example Extension/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | watchOS Example Extension
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | XPC!
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | NSExtension
26 |
27 | NSExtensionAttributes
28 |
29 | WKAppBundleIdentifier
30 | com.alamofire.iOS-Example.watchkitapp
31 |
32 | NSExtensionPointIdentifier
33 | com.apple.watchkit
34 |
35 | RemoteInterfacePrincipalClass
36 | InterfaceController
37 | WKExtensionDelegateClassName
38 | ExtensionDelegate
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Example/watchOS Example Extension/InterfaceController.h:
--------------------------------------------------------------------------------
1 | // InterfaceController.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 | #import
24 |
25 | @interface InterfaceController : WKInterfaceController
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/Example/watchOS Example Extension/InterfaceController.m:
--------------------------------------------------------------------------------
1 | // InterfaceController.m
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "InterfaceController.h"
23 |
24 |
25 | @interface InterfaceController()
26 |
27 | @end
28 |
29 |
30 | @implementation InterfaceController
31 |
32 | - (void)awakeWithContext:(id)context {
33 | [super awakeWithContext:context];
34 |
35 | // Configure interface objects here.
36 | }
37 |
38 | - (void)willActivate {
39 | // This method is called when watch view controller is about to be visible to user
40 | [super willActivate];
41 | }
42 |
43 | - (void)didDeactivate {
44 | // This method is called when watch view controller is no longer visible
45 | [super didDeactivate];
46 | }
47 |
48 | @end
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/Example/watchOS Example/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "24x24",
5 | "idiom" : "watch",
6 | "scale" : "2x",
7 | "role" : "notificationCenter",
8 | "subtype" : "38mm"
9 | },
10 | {
11 | "size" : "27.5x27.5",
12 | "idiom" : "watch",
13 | "scale" : "2x",
14 | "role" : "notificationCenter",
15 | "subtype" : "42mm"
16 | },
17 | {
18 | "size" : "29x29",
19 | "idiom" : "watch",
20 | "role" : "companionSettings",
21 | "scale" : "2x"
22 | },
23 | {
24 | "size" : "29x29",
25 | "idiom" : "watch",
26 | "role" : "companionSettings",
27 | "scale" : "3x"
28 | },
29 | {
30 | "size" : "40x40",
31 | "idiom" : "watch",
32 | "scale" : "2x",
33 | "role" : "appLauncher",
34 | "subtype" : "38mm"
35 | },
36 | {
37 | "size" : "44x44",
38 | "idiom" : "watch",
39 | "scale" : "2x",
40 | "role" : "longLook",
41 | "subtype" : "42mm"
42 | },
43 | {
44 | "size" : "86x86",
45 | "idiom" : "watch",
46 | "scale" : "2x",
47 | "role" : "quickLook",
48 | "subtype" : "38mm"
49 | },
50 | {
51 | "size" : "98x98",
52 | "idiom" : "watch",
53 | "scale" : "2x",
54 | "role" : "quickLook",
55 | "subtype" : "42mm"
56 | }
57 | ],
58 | "info" : {
59 | "version" : 1,
60 | "author" : "xcode"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Example/watchOS Example/Base.lproj/Interface.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Example/watchOS Example/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | iOS Example
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | UISupportedInterfaceOrientations
26 |
27 | UIInterfaceOrientationPortrait
28 | UIInterfaceOrientationPortraitUpsideDown
29 |
30 | WKCompanionAppBundleIdentifier
31 | com.alamofire.iOS-Example
32 | WKWatchKitApp
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Framework/AFNetworking.h:
--------------------------------------------------------------------------------
1 | // AFNetworking.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | //! Project version number for AFNetworking.
25 | FOUNDATION_EXPORT double AFNetworkingVersionNumber;
26 |
27 | //! Project version string for AFNetworking.
28 | FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[];
29 |
30 | // In this header, you should import all the public headers of your framework using statements like #import
31 |
32 | #import
33 | #import
34 |
35 | #ifndef _AFNETWORKING_
36 | #define _AFNETWORKING_
37 |
38 | #import
39 | #import
40 | #import
41 |
42 | #if !TARGET_OS_WATCH
43 | #import
44 | #endif
45 |
46 | #import
47 | #import
48 |
49 | #if TARGET_OS_IOS || TARGET_OS_TV
50 | #import
51 | #import
52 | #import
53 | #import
54 | #import
55 | #import
56 | #import
57 | #endif
58 |
59 | #if TARGET_OS_IOS
60 | #import
61 | #import
62 | #import
63 | #endif
64 |
65 |
66 | #endif /* _AFNETWORKING_ */
67 |
--------------------------------------------------------------------------------
/Framework/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 3.1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 3.2.0
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Framework/module.modulemap:
--------------------------------------------------------------------------------
1 | framework module AFNetworking {
2 | umbrella header "AFNetworking.h"
3 | export *
4 | module * { export * }
5 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011-2016 Alamofire Software Foundation (http://alamofire.org/)
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.
20 |
--------------------------------------------------------------------------------
/Tests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | com.alamofire.afnetworking.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Tests/Resources/ADN.net/ADNNetServerTrustChain/adn_0.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/ADN.net/ADNNetServerTrustChain/adn_0.cer
--------------------------------------------------------------------------------
/Tests/Resources/ADN.net/ADNNetServerTrustChain/adn_1.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/ADN.net/ADNNetServerTrustChain/adn_1.cer
--------------------------------------------------------------------------------
/Tests/Resources/ADN.net/ADNNetServerTrustChain/adn_2.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/ADN.net/ADNNetServerTrustChain/adn_2.cer
--------------------------------------------------------------------------------
/Tests/Resources/Google.com/Equifax_Secure_Certificate_Authority_Root.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/Google.com/Equifax_Secure_Certificate_Authority_Root.cer
--------------------------------------------------------------------------------
/Tests/Resources/Google.com/GeoTrust_Global_CA-cross.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/Google.com/GeoTrust_Global_CA-cross.cer
--------------------------------------------------------------------------------
/Tests/Resources/Google.com/GeoTrust_Global_CA_Root.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/Google.com/GeoTrust_Global_CA_Root.cer
--------------------------------------------------------------------------------
/Tests/Resources/Google.com/GoogleComServerTrustChainPath1/googlecom_0.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/Google.com/GoogleComServerTrustChainPath1/googlecom_0.cer
--------------------------------------------------------------------------------
/Tests/Resources/Google.com/GoogleComServerTrustChainPath1/googlecom_1.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/Google.com/GoogleComServerTrustChainPath1/googlecom_1.cer
--------------------------------------------------------------------------------
/Tests/Resources/Google.com/GoogleComServerTrustChainPath2/googlecom_0.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/Google.com/GoogleComServerTrustChainPath2/googlecom_0.cer
--------------------------------------------------------------------------------
/Tests/Resources/Google.com/GoogleComServerTrustChainPath2/googlecom_1.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/Google.com/GoogleComServerTrustChainPath2/googlecom_1.cer
--------------------------------------------------------------------------------
/Tests/Resources/Google.com/GoogleComServerTrustChainPath2/googlecom_2.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/Google.com/GoogleComServerTrustChainPath2/googlecom_2.cer
--------------------------------------------------------------------------------
/Tests/Resources/Google.com/GoogleInternetAuthorityG2.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/Google.com/GoogleInternetAuthorityG2.cer
--------------------------------------------------------------------------------
/Tests/Resources/Google.com/google.com.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/Google.com/google.com.cer
--------------------------------------------------------------------------------
/Tests/Resources/HTTPBin.org/DST Root CA X3.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/HTTPBin.org/DST Root CA X3.cer
--------------------------------------------------------------------------------
/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_0.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_0.cer
--------------------------------------------------------------------------------
/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_1.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_1.cer
--------------------------------------------------------------------------------
/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_2.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_2.cer
--------------------------------------------------------------------------------
/Tests/Resources/HTTPBin.org/Let's Encrypt Authority X3.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/HTTPBin.org/Let's Encrypt Authority X3.cer
--------------------------------------------------------------------------------
/Tests/Resources/HTTPBin.org/httpbinorg_04112018.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/HTTPBin.org/httpbinorg_04112018.cer
--------------------------------------------------------------------------------
/Tests/Resources/SelfSigned/AltName.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/SelfSigned/AltName.cer
--------------------------------------------------------------------------------
/Tests/Resources/SelfSigned/NoDomains.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/SelfSigned/NoDomains.cer
--------------------------------------------------------------------------------
/Tests/Resources/SelfSigned/foobar.com.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/SelfSigned/foobar.com.cer
--------------------------------------------------------------------------------
/Tests/Resources/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LeeWongSnail/AFNetworkingNotes/d77d3ac218d55499e0e92130bd7ea08e9eee7749/Tests/Resources/logo.png
--------------------------------------------------------------------------------
/Tests/Tests-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #ifdef __OBJC__
8 | #import
9 | #endif
10 |
--------------------------------------------------------------------------------
/Tests/Tests/AFImageResponseSerializerTests.m:
--------------------------------------------------------------------------------
1 | // AFImageResponseSerializerTests.m
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 | #import "AFTestCase.h"
24 | #import "AFURLResponseSerialization.h"
25 |
26 | @interface AFImageResponseSerializerTests : AFTestCase
27 |
28 | @end
29 |
30 | @implementation AFImageResponseSerializerTests
31 |
32 | #pragma mark NSCopying
33 |
34 | - (void)testImageSerializerCanBeCopied {
35 | AFImageResponseSerializer *responseSerializer = [AFImageResponseSerializer serializer];
36 | [responseSerializer setAcceptableContentTypes:[NSSet setWithObject:@"test/type"]];
37 | [responseSerializer setAcceptableStatusCodes:[NSIndexSet indexSetWithIndex:100]];
38 |
39 | AFImageResponseSerializer *copiedSerializer = [responseSerializer copy];
40 | XCTAssertNotNil(copiedSerializer);
41 | XCTAssertNotEqual(copiedSerializer, responseSerializer);
42 | XCTAssertEqual(copiedSerializer.acceptableContentTypes, responseSerializer.acceptableContentTypes);
43 | XCTAssertEqual(copiedSerializer.acceptableStatusCodes, responseSerializer.acceptableStatusCodes);
44 | #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
45 | XCTAssertTrue(copiedSerializer.automaticallyInflatesResponseImage == responseSerializer.automaticallyInflatesResponseImage);
46 | XCTAssertTrue(fabs(copiedSerializer.imageScale - responseSerializer.imageScale) <= 0.001);
47 | #endif
48 |
49 | }
50 |
51 | #pragma mark NSSecureCoding
52 |
53 | - (void)testImageSerializerSupportsSecureCoding {
54 | XCTAssertTrue([AFImageResponseSerializer supportsSecureCoding]);
55 | }
56 |
57 | - (void)testImageSerializerCanBeArchivedAndUnarchived {
58 | AFImageResponseSerializer *responseSerializer = [AFImageResponseSerializer serializer];
59 | NSData *archive = nil;
60 |
61 | archive = [NSKeyedArchiver archivedDataWithRootObject:responseSerializer];
62 | XCTAssertNotNil(archive);
63 | AFImageResponseSerializer *unarchivedSerializer = [NSKeyedUnarchiver unarchiveObjectWithData:archive];
64 | XCTAssertNotNil(unarchivedSerializer);
65 | XCTAssertNotEqual(unarchivedSerializer, responseSerializer);
66 | XCTAssertTrue([unarchivedSerializer.acceptableContentTypes isEqualToSet:responseSerializer.acceptableContentTypes]);
67 | XCTAssertTrue([unarchivedSerializer.acceptableStatusCodes isEqualToIndexSet:responseSerializer.acceptableStatusCodes]);
68 |
69 | #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
70 | XCTAssertTrue(unarchivedSerializer.automaticallyInflatesResponseImage == responseSerializer.automaticallyInflatesResponseImage);
71 | XCTAssertTrue(fabs(unarchivedSerializer.imageScale - responseSerializer.imageScale) <= 0.001);
72 | #endif
73 |
74 | }
75 |
76 | - (void)testImageSerializerCanBeArchivedAndUnarchivedWithNonDefaultPropertyValues {
77 | AFImageResponseSerializer *responseSerializer = [AFImageResponseSerializer serializer];
78 | NSData *archive = nil;
79 |
80 | // Customize the default property values
81 | #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
82 | responseSerializer.automaticallyInflatesResponseImage = !responseSerializer.automaticallyInflatesResponseImage;
83 | responseSerializer.imageScale = responseSerializer.imageScale * 2.0f;
84 | #endif
85 |
86 | archive = [NSKeyedArchiver archivedDataWithRootObject:responseSerializer];
87 | XCTAssertNotNil(archive);
88 | AFImageResponseSerializer *unarchivedSerializer = [NSKeyedUnarchiver unarchiveObjectWithData:archive];
89 | XCTAssertNotNil(unarchivedSerializer);
90 | XCTAssertNotEqual(unarchivedSerializer, responseSerializer);
91 |
92 | #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
93 | XCTAssertTrue(unarchivedSerializer.automaticallyInflatesResponseImage == responseSerializer.automaticallyInflatesResponseImage);
94 | XCTAssertTrue(fabs(unarchivedSerializer.imageScale - responseSerializer.imageScale) <= 0.001);
95 | #endif
96 | }
97 |
98 | @end
99 |
--------------------------------------------------------------------------------
/Tests/Tests/AFNetworkReachabilityManagerTests.m:
--------------------------------------------------------------------------------
1 | // AFNetworkReachabilityManagerTests.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "AFTestCase.h"
23 |
24 | #import "AFNetworkReachabilityManager.h"
25 | #import
26 |
27 | @interface AFNetworkReachabilityManagerTests : AFTestCase
28 | @property (nonatomic, strong) AFNetworkReachabilityManager *addressReachability;
29 | @property (nonatomic, strong) AFNetworkReachabilityManager *domainReachability;
30 | @end
31 |
32 | @implementation AFNetworkReachabilityManagerTests
33 |
34 | - (void)setUp {
35 | [super setUp];
36 |
37 | //both of these manager objects should always be reachable when the tests are run
38 | self.domainReachability = [AFNetworkReachabilityManager managerForDomain:@"localhost"];
39 | self.addressReachability = [AFNetworkReachabilityManager manager];
40 | }
41 |
42 | - (void)tearDown
43 | {
44 | [self.addressReachability stopMonitoring];
45 | [self.domainReachability stopMonitoring];
46 |
47 | [super tearDown];
48 | }
49 |
50 | - (void)testAddressReachabilityStartsInUnknownState {
51 | XCTAssertEqual(self.addressReachability.networkReachabilityStatus, AFNetworkReachabilityStatusUnknown,
52 | @"Reachability should start in an unknown state");
53 | }
54 |
55 | - (void)testDomainReachabilityStartsInUnknownState {
56 | XCTAssertEqual(self.domainReachability.networkReachabilityStatus, AFNetworkReachabilityStatusUnknown,
57 | @"Reachability should start in an unknown state");
58 | }
59 |
60 | - (void)verifyReachabilityNotificationGetsPostedWithManager:(AFNetworkReachabilityManager *)manager
61 | {
62 | [self expectationForNotification:AFNetworkingReachabilityDidChangeNotification
63 | object:nil
64 | handler:^BOOL(NSNotification *note) {
65 | AFNetworkReachabilityStatus status;
66 | status = [note.userInfo[AFNetworkingReachabilityNotificationStatusItem] integerValue];
67 | BOOL isReachable = (status == AFNetworkReachabilityStatusReachableViaWiFi
68 | || status == AFNetworkReachabilityStatusReachableViaWWAN);
69 | return isReachable;
70 | }];
71 |
72 | [manager startMonitoring];
73 |
74 | [self waitForExpectationsWithCommonTimeout];
75 | }
76 |
77 | - (void)testAddressReachabilityNotification {
78 | [self verifyReachabilityNotificationGetsPostedWithManager:self.addressReachability];
79 | }
80 |
81 | - (void)testDomainReachabilityNotification {
82 | [self verifyReachabilityNotificationGetsPostedWithManager:self.domainReachability];
83 | }
84 |
85 | - (void)verifyReachabilityStatusBlockGetsCalledWithManager:(AFNetworkReachabilityManager *)manager
86 | {
87 | __weak __block XCTestExpectation *expectation = [self expectationWithDescription:@"reachability status change block gets called"];
88 |
89 | [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
90 | BOOL isReachable = (status == AFNetworkReachabilityStatusReachableViaWiFi
91 | || status == AFNetworkReachabilityStatusReachableViaWWAN);
92 | if (isReachable) {
93 | [expectation fulfill];
94 | expectation = nil;
95 | }
96 | }];
97 |
98 | [manager startMonitoring];
99 |
100 | [self waitForExpectationsWithCommonTimeout];
101 | [manager setReachabilityStatusChangeBlock:nil];
102 |
103 | }
104 |
105 | - (void)testAddressReachabilityBlock {
106 | [self verifyReachabilityStatusBlockGetsCalledWithManager:self.addressReachability];
107 | }
108 |
109 | - (void)testDomainReachabilityBlock {
110 | [self verifyReachabilityStatusBlockGetsCalledWithManager:self.domainReachability];
111 | }
112 |
113 | @end
114 |
--------------------------------------------------------------------------------
/Tests/Tests/AFPropertyListRequestSerializerTests.m:
--------------------------------------------------------------------------------
1 | // AFPropertyListRequestSerializerTests.m
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "AFTestCase.h"
23 |
24 | #import "AFURLRequestSerialization.h"
25 |
26 | @interface AFPropertyListRequestSerializerTests : AFTestCase
27 | @property (nonatomic, strong) AFPropertyListRequestSerializer *requestSerializer;
28 | @end
29 |
30 | @implementation AFPropertyListRequestSerializerTests
31 |
32 | - (void)setUp {
33 | [super setUp];
34 | self.requestSerializer = [AFPropertyListRequestSerializer serializer];
35 | }
36 |
37 | #pragma mark -
38 |
39 | - (void)testThatPropertyListRequestSerializerAcceptsPlist {
40 | NSDictionary *parameters = @{@"key":@"value"};
41 | NSError *error = nil;
42 | NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"POST" URLString:self.baseURL.absoluteString parameters:parameters error:&error];
43 |
44 | XCTAssertNotNil(request, @"Expected non-nil request.");
45 | }
46 |
47 | - (void)testThatPropertyListRequestSerializerHandlesInvalidPlist {
48 | NSDictionary *parameters = @{@42:@"value"};
49 | NSError *error = nil;
50 | NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"POST" URLString:self.baseURL.absoluteString parameters:parameters error:&error];
51 |
52 | XCTAssertNil(request, @"Expected nil request.");
53 | XCTAssertNotNil(error, @"Expected non-nil error.");
54 | }
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/Tests/Tests/AFPropertyListResponseSerializerTests.m:
--------------------------------------------------------------------------------
1 | // AFPropertyListResponseSerializerTests.m
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "AFTestCase.h"
23 |
24 | #import "AFURLResponseSerialization.h"
25 |
26 | @interface AFPropertyListResponseSerializerTests : AFTestCase
27 | @property (nonatomic, strong) AFPropertyListResponseSerializer *responseSerializer;
28 | @end
29 |
30 | @implementation AFPropertyListResponseSerializerTests
31 |
32 | - (void)setUp {
33 | [super setUp];
34 | self.responseSerializer = [AFPropertyListResponseSerializer serializer];
35 | }
36 |
37 | #pragma mark -
38 |
39 | - (void)testThatPropertyListResponseSerializerAcceptsPlistData {
40 | NSData *data = [NSPropertyListSerialization dataWithPropertyList:@{@"foo": @"bar"} format:NSPropertyListXMLFormat_v1_0 options:0 error:NULL];
41 |
42 | NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:200 HTTPVersion:@"1.1" headerFields:@{@"Content-Type": @"application/x-plist"}];
43 | NSError *error = nil;
44 | id responseObject = [self.responseSerializer responseObjectForResponse:response data:data error:&error];
45 |
46 | XCTAssertTrue([responseObject isKindOfClass:[NSDictionary class]], @"Expected valid dictionary.");
47 | }
48 |
49 | - (void)testThatPropertyListResponseSerializerHandlesInvalidPlistData {
50 | NSData *data = [NSJSONSerialization dataWithJSONObject:@{@"foo": @"bar"} options:(NSJSONWritingOptions)0 error:nil];
51 |
52 | NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:200 HTTPVersion:@"1.1" headerFields:@{@"Content-Type": @"application/x-plist"}];
53 | NSError *error = nil;
54 | id responseObject = [self.responseSerializer responseObjectForResponse:response data:data error:&error];
55 |
56 | XCTAssertNil(responseObject, @"Expected nil responseObject.");
57 | XCTAssertNotNil(error, @"Expected non-nil error.");
58 | }
59 |
60 | - (void)testThatPropertyListResponseSerializerHandles204 {
61 | NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:204 HTTPVersion:@"1.1" headerFields:@{@"Content-Type": @"application/x-plist"}];
62 | NSError *error;
63 | id responseObject = [self.responseSerializer responseObjectForResponse:response data:nil error:&error];
64 |
65 | XCTAssertNil(responseObject, @"Response should be nil when handling 204 with application/x-plist");
66 | XCTAssertNil(error, @"Error handling application/x-plist");
67 | }
68 |
69 | - (void)testResponseSerializerCanBeCopied {
70 | [self.responseSerializer setAcceptableContentTypes:[NSSet setWithObject:@"test/type"]];
71 | [self.responseSerializer setAcceptableStatusCodes:[NSIndexSet indexSetWithIndex:100]];
72 | [self.responseSerializer setFormat:NSPropertyListXMLFormat_v1_0];
73 | [self.responseSerializer setReadOptions:NSPropertyListMutableContainers];
74 |
75 | AFPropertyListResponseSerializer *copiedSerializer = [self.responseSerializer copy];
76 | XCTAssertNotNil(copiedSerializer);
77 | XCTAssertNotEqual(copiedSerializer, self.responseSerializer);
78 | XCTAssertEqual(copiedSerializer.format, self.responseSerializer.format);
79 | XCTAssertEqual(copiedSerializer.readOptions, self.responseSerializer.readOptions);
80 | XCTAssertEqual(copiedSerializer.acceptableContentTypes, self.responseSerializer.acceptableContentTypes);
81 | XCTAssertEqual(copiedSerializer.acceptableStatusCodes, self.responseSerializer.acceptableStatusCodes);
82 | }
83 |
84 | - (void)testResponseSerializerCanBeArchivedAndUnarchived {
85 | NSData *archive = [NSKeyedArchiver archivedDataWithRootObject:self.responseSerializer];
86 | XCTAssertNotNil(archive);
87 | AFPropertyListResponseSerializer *unarchivedSerializer = [NSKeyedUnarchiver unarchiveObjectWithData:archive];
88 | XCTAssertNotNil(unarchivedSerializer);
89 | XCTAssertNotEqual(unarchivedSerializer, self.responseSerializer);
90 | XCTAssertTrue(unarchivedSerializer.format == self.responseSerializer.format);
91 | XCTAssertTrue(unarchivedSerializer.readOptions == self.responseSerializer.readOptions);
92 | }
93 |
94 | @end
95 |
--------------------------------------------------------------------------------
/Tests/Tests/AFTestCase.h:
--------------------------------------------------------------------------------
1 | // AFTestCase.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | @interface AFTestCase : XCTestCase
25 |
26 | @property (nonatomic, strong, readonly) NSURL *baseURL;
27 | @property (nonatomic, strong, readonly) NSURL *pngURL;
28 | @property (nonatomic, strong, readonly) NSURL *jpegURL;
29 | @property (nonatomic, strong, readonly) NSURL *delayURL;
30 | - (NSURL *)URLWithStatusCode:(NSInteger)statusCode;
31 |
32 | @property (nonatomic, assign) NSTimeInterval networkTimeout;
33 |
34 | - (void)waitForExpectationsWithCommonTimeout;
35 | - (void)waitForExpectationsWithCommonTimeoutUsingHandler:(XCWaitCompletionHandler)handler;
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/Tests/Tests/AFTestCase.m:
--------------------------------------------------------------------------------
1 | // AFTestCase.m
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "AFTestCase.h"
23 |
24 | @implementation AFTestCase
25 |
26 | - (void)setUp {
27 | [super setUp];
28 | self.networkTimeout = 20.0;
29 | }
30 |
31 | - (void)tearDown {
32 | [super tearDown];
33 | }
34 |
35 | #pragma mark -
36 |
37 | - (NSURL *)baseURL {
38 | NSDictionary *environment = [[NSProcessInfo processInfo] environment];
39 | return [NSURL URLWithString:environment[@"HTTPBIN_BASE_URL"] ?: @"https://httpbin.org"];
40 | }
41 |
42 | - (NSURL *)pngURL {
43 | return [self.baseURL URLByAppendingPathComponent:@"image/png"];
44 | }
45 |
46 | - (NSURL *)jpegURL {
47 | return [self.baseURL URLByAppendingPathComponent:@"image/jpeg"];
48 | }
49 |
50 | - (NSURL *)delayURL {
51 | return [self.baseURL URLByAppendingPathComponent:@"delay/1"];
52 | }
53 |
54 | - (NSURL *)URLWithStatusCode:(NSInteger)statusCode {
55 | return [self.baseURL URLByAppendingPathComponent:[NSString stringWithFormat:@"status/%@", @(statusCode)]];
56 | }
57 |
58 | - (void)waitForExpectationsWithCommonTimeout {
59 | [self waitForExpectationsWithCommonTimeoutUsingHandler:nil];
60 | }
61 |
62 | - (void)waitForExpectationsWithCommonTimeoutUsingHandler:(XCWaitCompletionHandler)handler {
63 | [self waitForExpectationsWithTimeout:self.networkTimeout handler:handler];
64 | }
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/Tests/Tests/AFUIButtonTests.m:
--------------------------------------------------------------------------------
1 | // AFUIButtonTests.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 | #import "AFTestCase.h"
24 | #import "UIButton+AFNetworking.h"
25 | #import "AFImageDownloader.h"
26 |
27 | @interface AFUIButtonTests : AFTestCase
28 | @property (nonatomic, strong) UIImage *cachedImage;
29 | @property (nonatomic, strong) NSURLRequest *cachedImageRequest;
30 | @property (nonatomic, strong) UIButton *button;
31 |
32 | @property (nonatomic, strong) NSURLRequest *error404URLRequest;
33 |
34 | @property (nonatomic, strong) NSURLRequest *jpegURLRequest;
35 | @end
36 |
37 | @implementation AFUIButtonTests
38 |
39 | - (void)setUp {
40 | [super setUp];
41 | [[UIButton sharedImageDownloader].imageCache removeAllImages];
42 | [[[[[[UIButton sharedImageDownloader] sessionManager] session] configuration] URLCache] removeAllCachedResponses];
43 | [UIButton setSharedImageDownloader:[[AFImageDownloader alloc] init]];
44 |
45 | self.button = [UIButton new];
46 |
47 | self.jpegURLRequest = [NSURLRequest requestWithURL:self.jpegURL];
48 |
49 | self.error404URLRequest = [NSURLRequest requestWithURL:[self URLWithStatusCode:404]];
50 | }
51 |
52 | - (void)tearDown {
53 | self.button = nil;
54 | [super tearDown];
55 |
56 | }
57 |
58 | - (void)testThatBackgroundImageChanges {
59 | XCTAssertNil([self.button backgroundImageForState:UIControlStateNormal]);
60 | [self.button setBackgroundImageForState:UIControlStateNormal withURL:self.jpegURL];
61 | NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(UIButton * _Nonnull button, NSDictionary * _Nullable bindings) {
62 | return [button backgroundImageForState:UIControlStateNormal] != nil;
63 | }];
64 |
65 | [self expectationForPredicate:predicate
66 | evaluatedWithObject:self.button
67 | handler:nil];
68 |
69 | [self waitForExpectationsWithCommonTimeout];
70 | }
71 |
72 | - (void)testThatForegroundImageCanBeCancelledAndDownloadedImmediately {
73 | //https://github.com/Alamofire/AlamofireImage/issues/55
74 | XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
75 | [self.button setImageForState:UIControlStateNormal withURL:self.jpegURL];
76 | [self.button cancelImageDownloadTaskForState:UIControlStateNormal];
77 | __block UIImage *responseImage;
78 | [self.button
79 | setImageForState:UIControlStateNormal
80 | withURLRequest:self.jpegURLRequest
81 | placeholderImage:nil
82 | success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull image) {
83 | responseImage = image;
84 | [expectation fulfill];
85 | }
86 | failure:nil];
87 | [self waitForExpectationsWithCommonTimeout];
88 | XCTAssertNotNil(responseImage);
89 | }
90 |
91 | - (void)testThatBackgroundImageCanBeCancelledAndDownloadedImmediately {
92 | //https://github.com/Alamofire/AlamofireImage/issues/55
93 | XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
94 | [self.button setBackgroundImageForState:UIControlStateNormal withURL:self.jpegURL];
95 | [self.button cancelBackgroundImageDownloadTaskForState:UIControlStateNormal];
96 | __block UIImage *responseImage;
97 | [self.button
98 | setBackgroundImageForState:UIControlStateNormal
99 | withURLRequest:self.jpegURLRequest
100 | placeholderImage:nil
101 | success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull image) {
102 | responseImage = image;
103 | [expectation fulfill];
104 | }
105 | failure:nil];
106 | [self waitForExpectationsWithCommonTimeout];
107 | XCTAssertNotNil(responseImage);
108 | }
109 |
110 | @end
111 |
--------------------------------------------------------------------------------
/Tests/Tests/AFUIWebViewTests.m:
--------------------------------------------------------------------------------
1 | // AFUIWebViewTests.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 | #import "AFTestCase.h"
24 | #import "UIWebView+AFNetworking.h"
25 |
26 | @interface AFUIWebViewTests : AFTestCase
27 |
28 | @property (nonatomic, strong) UIWebView *webView;
29 | @property (nonatomic, strong) NSURLRequest *HTMLRequest;
30 |
31 | @end
32 |
33 | @implementation AFUIWebViewTests
34 |
35 | - (void)setUp {
36 | [super setUp];
37 | self.webView = [UIWebView new];
38 | self.HTMLRequest = [NSURLRequest requestWithURL:[self.baseURL URLByAppendingPathComponent:@"html"]];
39 | }
40 |
41 | - (void)testNilProgressDoesNotCauseCrash {
42 | XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
43 | [self.webView
44 | loadRequest:self.HTMLRequest
45 | progress:nil
46 | success:^NSString * _Nonnull(NSHTTPURLResponse * _Nonnull response, NSString * _Nonnull HTML) {
47 | [expectation fulfill];
48 | return HTML;
49 | }
50 | failure:nil];
51 | [self waitForExpectationsWithCommonTimeout];
52 | }
53 |
54 | - (void)testNULLProgressDoesNotCauseCrash {
55 | XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
56 | [self.webView
57 | loadRequest:self.HTMLRequest
58 | progress:NULL
59 | success:^NSString * _Nonnull(NSHTTPURLResponse * _Nonnull response, NSString * _Nonnull HTML) {
60 | [expectation fulfill];
61 | return HTML;
62 | }
63 | failure:nil];
64 | [self waitForExpectationsWithCommonTimeout];
65 | }
66 |
67 | - (void)testProgressIsSet {
68 | NSProgress* progress = nil;
69 | XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
70 | [self.webView
71 | loadRequest:self.HTMLRequest
72 | progress:&progress
73 | success:^NSString * _Nonnull(NSHTTPURLResponse * _Nonnull response, NSString * _Nonnull HTML) {
74 | [expectation fulfill];
75 | return HTML;
76 | }
77 | failure:nil];
78 | [self keyValueObservingExpectationForObject:progress
79 | keyPath:@"fractionCompleted"
80 | expectedValue:@(1.0)];
81 | [self waitForExpectationsWithCommonTimeout];
82 | }
83 |
84 | - (void)testRequestWithCustomHeaders {
85 | NSMutableURLRequest *customHeaderRequest = [NSMutableURLRequest requestWithURL:[self.baseURL URLByAppendingPathComponent:@"headers"]];
86 | [customHeaderRequest setValue:@"Custom-Header-Value" forHTTPHeaderField:@"Custom-Header-Field"];
87 | XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
88 | [self.webView
89 | loadRequest:customHeaderRequest
90 | progress:NULL
91 | success:^NSString * _Nonnull(NSHTTPURLResponse * _Nonnull response, NSString * _Nonnull string) {
92 | // Here string is actually JSON.
93 | NSDictionary *responseObject = [NSJSONSerialization JSONObjectWithData:[string dataUsingEncoding:NSUTF8StringEncoding] options:(NSJSONReadingOptions)0 error:nil];
94 |
95 | NSDictionary *headers = responseObject[@"headers"];
96 | XCTAssertTrue([headers[@"Custom-Header-Field"] isEqualToString:@"Custom-Header-Value"]);
97 | [expectation fulfill];
98 | return string;
99 | }
100 | failure:nil];
101 | [self waitForExpectationsWithCommonTimeout];
102 | }
103 |
104 | @end
105 |
--------------------------------------------------------------------------------
/Tests/Tests/AFXMLDocumentResponseSerializerTests.m:
--------------------------------------------------------------------------------
1 | // AFXMLDocumentResponseSerializerTests.m
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "AFTestCase.h"
23 |
24 | #import "AFURLRequestSerialization.h"
25 | #import "AFURLResponseSerialization.h"
26 |
27 | #import
28 |
29 | static NSData * AFXMLTestData() {
30 | return [@"someValue" dataUsingEncoding:NSUTF8StringEncoding];
31 | }
32 |
33 | #pragma mark -
34 |
35 | @interface AFXMLDocumentResponseSerializerTests : AFTestCase
36 | @property (nonatomic, strong) AFXMLDocumentResponseSerializer *responseSerializer;
37 | @end
38 |
39 | #pragma mark -
40 |
41 | @implementation AFXMLDocumentResponseSerializerTests
42 |
43 | - (void)setUp {
44 | [super setUp];
45 | self.responseSerializer = [AFXMLDocumentResponseSerializer serializer];
46 | }
47 |
48 | - (void)testThatXMLDocumentResponseSerializerAcceptsApplicationXMLMimeType {
49 | NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:200 HTTPVersion:@"1.1" headerFields:@{@"Content-Type": @"application/xml"}];
50 | NSError *error = nil;
51 | [self.responseSerializer validateResponse:response data:AFXMLTestData() error:&error];
52 |
53 | XCTAssertNil(error, @"Error handling application/xml");
54 | }
55 |
56 | - (void)testThatXMLDocumentResponseSerializerAcceptsTextXMLMimeType {
57 | NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:200 HTTPVersion:@"1.1" headerFields:@{@"Content-Type": @"text/xml"}];
58 | NSError *error = nil;
59 | [self.responseSerializer validateResponse:response data:AFXMLTestData() error:&error];
60 |
61 | XCTAssertNil(error, @"Error handling text/xml");
62 | }
63 |
64 | - (void)testThatXMLDocumentResponseSerializerDoesNotAcceptsNonStandardXMLMimeType {
65 | NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:200 HTTPVersion:@"1.1" headerFields:@{@"Content-Type": @"nonstandard/xml"}];
66 | NSError *error = nil;
67 | [self.responseSerializer validateResponse:response data:AFXMLTestData() error:&error];
68 |
69 | XCTAssertNotNil(error, @"Error should have been thrown for nonstandard/xml");
70 | }
71 |
72 | - (void)testThatXMLDocumentResponseSerializerReturnsNSXMLDocumentObjectForValidXML {
73 | NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:200 HTTPVersion:@"1.1" headerFields:@{@"Content-Type": @"application/xml"}];
74 | NSError *error = nil;
75 | id responseObject = [self.responseSerializer responseObjectForResponse:response data:AFXMLTestData() error:&error];
76 |
77 | XCTAssertNil(error, @"Serialization error should be nil");
78 | XCTAssert([responseObject isKindOfClass:[NSXMLDocument class]], @"Expected response to be a NSXMLDocument");
79 | }
80 |
81 | - (void)testThatXMLDocumentResponseSerializerReturnsErrorForInvalidXML {
82 | NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:200 HTTPVersion:@"1.1" headerFields:@{@"Content-Type": @"application/xml"}];
83 | NSError *error = nil;
84 | [self.responseSerializer responseObjectForResponse:response data:[@"someValue" dataUsingEncoding:NSUTF8StringEncoding];
29 | }
30 |
31 | #pragma mark -
32 |
33 | @interface AFXMLParserResponseSerializerTests : AFTestCase
34 | @property (nonatomic, strong) AFXMLParserResponseSerializer *responseSerializer;
35 | @end
36 |
37 | #pragma mark -
38 |
39 | @implementation AFXMLParserResponseSerializerTests
40 |
41 | - (void)setUp {
42 | [super setUp];
43 | self.responseSerializer = [AFXMLParserResponseSerializer serializer];
44 | }
45 |
46 | - (void)testThatXMLParserResponseSerializerAcceptsApplicationXMLMimeType {
47 | NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:200 HTTPVersion:@"1.1" headerFields:@{@"Content-Type": @"application/xml"}];
48 | NSError *error = nil;
49 | [self.responseSerializer validateResponse:response data:AFXMLTestData() error:&error];
50 |
51 | XCTAssertNil(error, @"Error handling application/xml");
52 | }
53 |
54 | - (void)testThatXMLParserResponseSerializerAcceptsTextXMLMimeType {
55 | NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:200 HTTPVersion:@"1.1" headerFields:@{@"Content-Type": @"text/xml"}];
56 | NSError *error = nil;
57 | [self.responseSerializer validateResponse:response data:AFXMLTestData() error:&error];
58 |
59 | XCTAssertNil(error, @"Error handling text/xml");
60 | }
61 |
62 | - (void)testThatXMLParserResponseSerializerDoesNotAcceptsNonStandardXMLMimeType {
63 | NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:200 HTTPVersion:@"1.1" headerFields:@{@"Content-Type": @"nonstandard/xml"}];
64 | NSError *error = nil;
65 | [self.responseSerializer validateResponse:response data:AFXMLTestData() error:&error];
66 |
67 | XCTAssertNotNil(error, @"Error should have been thrown for nonstandard/xml");
68 | }
69 |
70 | - (void)testThatXMLParserResponseSerializerReturnsNSXMLParserObjectForValidXML {
71 | NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:200 HTTPVersion:@"1.1" headerFields:@{@"Content-Type": @"application/xml"}];
72 | NSError *error = nil;
73 | id responseObject = [self.responseSerializer responseObjectForResponse:response data:AFXMLTestData() error:&error];
74 |
75 | XCTAssertNil(error, @"Serialization error should be nil");
76 | XCTAssert([responseObject isKindOfClass:[NSXMLParser class]], @"Expected response to be a NSXMLParser");
77 | }
78 |
79 | - (void)testThatXMLParserResponseSerializerCanBeCopied {
80 | [self.responseSerializer setAcceptableStatusCodes:[NSIndexSet indexSetWithIndex:100]];
81 | [self.responseSerializer setAcceptableContentTypes:[NSSet setWithObject:@"test/type"]];
82 |
83 | AFXMLParserResponseSerializer *copiedSerializer = [self.responseSerializer copy];
84 | XCTAssertNotEqual(copiedSerializer, self.responseSerializer);
85 | XCTAssertEqual(copiedSerializer.acceptableStatusCodes, self.responseSerializer.acceptableStatusCodes);
86 | XCTAssertEqual(copiedSerializer.acceptableContentTypes, self.responseSerializer.acceptableContentTypes);
87 | }
88 |
89 | @end
90 |
--------------------------------------------------------------------------------
/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIActivityIndicatorView+AFNetworking.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS || TARGET_OS_TV
27 |
28 | #import
29 |
30 | /**
31 | This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task.
32 | */
33 | @interface UIActivityIndicatorView (AFNetworking)
34 |
35 | ///----------------------------------
36 | /// @name Animating for Session Tasks
37 | ///----------------------------------
38 |
39 | /**
40 | Binds the animating state to the state of the specified task.
41 |
42 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
43 | */
44 | - (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task;
45 |
46 | @end
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIActivityIndicatorView+AFNetworking.m
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "UIActivityIndicatorView+AFNetworking.h"
23 | #import
24 |
25 | #if TARGET_OS_IOS || TARGET_OS_TV
26 |
27 | #import "AFURLSessionManager.h"
28 |
29 | @interface AFActivityIndicatorViewNotificationObserver : NSObject
30 | @property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView;
31 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView;
32 |
33 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task;
34 |
35 | @end
36 |
37 | @implementation UIActivityIndicatorView (AFNetworking)
38 |
39 | - (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver {
40 | AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver));
41 | if (notificationObserver == nil) {
42 | notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self];
43 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
44 | }
45 | return notificationObserver;
46 | }
47 |
48 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task {
49 | [[self af_notificationObserver] setAnimatingWithStateOfTask:task];
50 | }
51 |
52 | @end
53 |
54 | @implementation AFActivityIndicatorViewNotificationObserver
55 |
56 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView
57 | {
58 | self = [super init];
59 | if (self) {
60 | _activityIndicatorView = activityIndicatorView;
61 | }
62 | return self;
63 | }
64 |
65 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task {
66 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
67 |
68 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
69 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
70 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
71 |
72 | if (task) {
73 | if (task.state != NSURLSessionTaskStateCompleted) {
74 | UIActivityIndicatorView *activityIndicatorView = self.activityIndicatorView;
75 | if (task.state == NSURLSessionTaskStateRunning) {
76 | [activityIndicatorView startAnimating];
77 | } else {
78 | [activityIndicatorView stopAnimating];
79 | }
80 |
81 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task];
82 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task];
83 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task];
84 | }
85 | }
86 | }
87 |
88 | #pragma mark -
89 |
90 | - (void)af_startAnimating {
91 | dispatch_async(dispatch_get_main_queue(), ^{
92 | [self.activityIndicatorView startAnimating];
93 | });
94 | }
95 |
96 | - (void)af_stopAnimating {
97 | dispatch_async(dispatch_get_main_queue(), ^{
98 | [self.activityIndicatorView stopAnimating];
99 | });
100 | }
101 |
102 | #pragma mark -
103 |
104 | - (void)dealloc {
105 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
106 |
107 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
108 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
109 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
110 | }
111 |
112 | @end
113 |
114 | #endif
115 |
--------------------------------------------------------------------------------
/UIKit+AFNetworking/UIImage+AFNetworking.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+AFNetworking.h
3 | //
4 | //
5 | // Created by Paulo Ferreira on 08/07/15.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #if TARGET_OS_IOS || TARGET_OS_TV
26 |
27 | #import
28 |
29 | @interface UIImage (AFNetworking)
30 |
31 | + (UIImage*) safeImageWithData:(NSData*)data;
32 |
33 | @end
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/UIKit+AFNetworking/UIKit+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIKit+AFNetworking.h
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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 | #if TARGET_OS_IOS || TARGET_OS_TV
24 | #import
25 |
26 | #ifndef _UIKIT_AFNETWORKING_
27 | #define _UIKIT_AFNETWORKING_
28 |
29 | #if TARGET_OS_IOS
30 | #import "AFAutoPurgingImageCache.h"
31 | #import "AFImageDownloader.h"
32 | #import "AFNetworkActivityIndicatorManager.h"
33 | #import "UIRefreshControl+AFNetworking.h"
34 | #import "UIWebView+AFNetworking.h"
35 | #endif
36 |
37 | #import "UIActivityIndicatorView+AFNetworking.h"
38 | #import "UIButton+AFNetworking.h"
39 | #import "UIImageView+AFNetworking.h"
40 | #import "UIProgressView+AFNetworking.h"
41 | #endif /* _UIKIT_AFNETWORKING_ */
42 | #endif
43 |
--------------------------------------------------------------------------------
/UIKit+AFNetworking/UIProgressView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIProgressView+AFNetworking.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS || TARGET_OS_TV
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 |
33 | /**
34 | This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task.
35 | */
36 | @interface UIProgressView (AFNetworking)
37 |
38 | ///------------------------------------
39 | /// @name Setting Session Task Progress
40 | ///------------------------------------
41 |
42 | /**
43 | Binds the progress to the upload progress of the specified session task.
44 |
45 | @param task The session task.
46 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
47 | */
48 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
49 | animated:(BOOL)animated;
50 |
51 | /**
52 | Binds the progress to the download progress of the specified session task.
53 |
54 | @param task The session task.
55 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
56 | */
57 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
58 | animated:(BOOL)animated;
59 |
60 | @end
61 |
62 | NS_ASSUME_NONNULL_END
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIRefreshControl+AFNetworking.m
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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
24 |
25 | #import
26 |
27 | #if TARGET_OS_IOS
28 |
29 | #import
30 |
31 | NS_ASSUME_NONNULL_BEGIN
32 |
33 | /**
34 | This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a session task.
35 | */
36 | @interface UIRefreshControl (AFNetworking)
37 |
38 | ///-----------------------------------
39 | /// @name Refreshing for Session Tasks
40 | ///-----------------------------------
41 |
42 | /**
43 | Binds the refreshing state to the state of the specified task.
44 |
45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
46 | */
47 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task;
48 |
49 | @end
50 |
51 | NS_ASSUME_NONNULL_END
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIRefreshControl+AFNetworking.m
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
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 "UIRefreshControl+AFNetworking.h"
24 | #import
25 |
26 | #if TARGET_OS_IOS
27 |
28 | #import "AFURLSessionManager.h"
29 |
30 | @interface AFRefreshControlNotificationObserver : NSObject
31 | @property (readonly, nonatomic, weak) UIRefreshControl *refreshControl;
32 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl;
33 |
34 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task;
35 |
36 | @end
37 |
38 | @implementation UIRefreshControl (AFNetworking)
39 |
40 | - (AFRefreshControlNotificationObserver *)af_notificationObserver {
41 | AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver));
42 | if (notificationObserver == nil) {
43 | notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self];
44 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
45 | }
46 | return notificationObserver;
47 | }
48 |
49 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task {
50 | [[self af_notificationObserver] setRefreshingWithStateOfTask:task];
51 | }
52 |
53 | @end
54 |
55 | @implementation AFRefreshControlNotificationObserver
56 |
57 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl
58 | {
59 | self = [super init];
60 | if (self) {
61 | _refreshControl = refreshControl;
62 | }
63 | return self;
64 | }
65 |
66 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task {
67 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
68 |
69 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
70 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
71 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
72 |
73 | if (task) {
74 | UIRefreshControl *refreshControl = self.refreshControl;
75 | if (task.state == NSURLSessionTaskStateRunning) {
76 | [refreshControl beginRefreshing];
77 |
78 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task];
79 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task];
80 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task];
81 | } else {
82 | [refreshControl endRefreshing];
83 | }
84 | }
85 | }
86 |
87 | #pragma mark -
88 |
89 | - (void)af_beginRefreshing {
90 | dispatch_async(dispatch_get_main_queue(), ^{
91 | [self.refreshControl beginRefreshing];
92 | });
93 | }
94 |
95 | - (void)af_endRefreshing {
96 | dispatch_async(dispatch_get_main_queue(), ^{
97 | [self.refreshControl endRefreshing];
98 | });
99 | }
100 |
101 | #pragma mark -
102 |
103 | - (void)dealloc {
104 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
105 |
106 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
107 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
108 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
109 | }
110 |
111 | @end
112 |
113 | #endif
114 |
--------------------------------------------------------------------------------
/UIKit+AFNetworking/UIWebView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIWebView+AFNetworking.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | @class AFHTTPSessionManager;
33 |
34 | /**
35 | This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling.
36 |
37 | @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly.
38 | */
39 | @interface UIWebView (AFNetworking)
40 |
41 | /**
42 | The session manager used to download all requests.
43 | */
44 | @property (nonatomic, strong) AFHTTPSessionManager *sessionManager;
45 |
46 | /**
47 | Asynchronously loads the specified request.
48 |
49 | @param request A URL request identifying the location of the content to load. This must not be `nil`.
50 | @param progress A progress object monitoring the current download progress.
51 | @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string.
52 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
53 | */
54 | - (void)loadRequest:(NSURLRequest *)request
55 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
56 | success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success
57 | failure:(nullable void (^)(NSError *error))failure;
58 |
59 | /**
60 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding.
61 |
62 | @param request A URL request identifying the location of the content to load. This must not be `nil`.
63 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified.
64 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified.
65 | @param progress A progress object monitoring the current download progress.
66 | @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data.
67 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
68 | */
69 | - (void)loadRequest:(NSURLRequest *)request
70 | MIMEType:(nullable NSString *)MIMEType
71 | textEncodingName:(nullable NSString *)textEncodingName
72 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
73 | success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success
74 | failure:(nullable void (^)(NSError *error))failure;
75 |
76 | @end
77 |
78 | NS_ASSUME_NONNULL_END
79 |
80 | #endif
81 |
--------------------------------------------------------------------------------
/fastlane/.env:
--------------------------------------------------------------------------------
1 | AF_WORKSPACE="AFNetworking.xcworkspace"
2 |
3 | AF_IOS_FRAMEWORK_SCHEME="AFNetworking iOS"
4 | AF_TVOS_FRAMEWORK_SCHEME="AFNetworking tvOS"
5 | AF_OSX_FRAMEWORK_SCHEME="AFNetworking macOS"
6 |
7 | AF_IOS_EXAMPLE_SCHEME="iOS Example"
8 | AF_TVOS_EXAMPLE_SCHEME="tvOS Example"
9 | AF_OSX_EXAMPLE_SCHEME="macOS Example"
10 |
11 | FASTLANE_EXPLICIT_OPEN_SIMULATOR=1
12 |
--------------------------------------------------------------------------------
/fastlane/.env.default:
--------------------------------------------------------------------------------
1 | AF_IOS_SDK=iphonesimulator11.2
2 | AF_MAC_SDK=macosx10.13
3 | AF_TVOS_SDK=appletvsimulator11.2
4 |
5 | AF_CONFIGURATION=Release
6 |
7 | SCAN_WORKSPACE=$AF_WORKSPACE
8 | SCAN_SCHEME=$AF_IOS_FRAMEWORK_SCHEME
9 | SCAN_SDK=$AF_IOS_SDK
10 | SCAN_OUTPUT_DIRECTORY=fastlane/test-output
11 |
12 | EXAMPLE_WORKSPACE=$AF_WORKSPACE
13 | EXAMPLE_SCHEME=$AF_IOS_EXAMPLE_SCHEME
14 | EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 8"
15 |
--------------------------------------------------------------------------------
/fastlane/.env.deploy:
--------------------------------------------------------------------------------
1 | DEPLOY_BRANCH=master
2 | DEPLOY_PLIST_PATH=Framework/Info.plist
3 | DEPLOY_PODSPEC=AFNetworking.podspec
4 | DEPLOY_REMOTE=origin
5 |
6 | DEPLOY_CHANGELOG_PATH=CHANGELOG.md
7 | DEPLOY_CHANGELOG_DELIMITER=---
8 |
9 | # Used for CHANGELOG Generation and Github Release Management
10 | GITHUB_OWNER=AFNetworking
11 | GITHUB_REPOSITORY=AFNetworking
12 | # CI Should Provide GITHUB_API_TOKEN
13 |
14 | CARTHAGE_FRAMEWORK_NAME=AFNetworking
--------------------------------------------------------------------------------
/fastlane/.env.ios10_xcode8:
--------------------------------------------------------------------------------
1 | SCAN_DEVICE="iPhone 7"
2 | SCAN_SDK="iphonesimulator10.3"
3 | EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 7"
4 |
--------------------------------------------------------------------------------
/fastlane/.env.ios11_xcode93:
--------------------------------------------------------------------------------
1 | SCAN_DEVICE="iPhone 8"
2 | SCAN_SDK=$AF_IOS_SDK
3 | EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 8"
4 |
--------------------------------------------------------------------------------
/fastlane/.env.ios8_xcode7:
--------------------------------------------------------------------------------
1 | SCAN_DEVICE="iPhone 5"
2 | SCAN_SDK=iphonesimulator9.3
3 | EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 5,OS=8.1"
--------------------------------------------------------------------------------
/fastlane/.env.ios9_xcode7:
--------------------------------------------------------------------------------
1 | SCAN_DEVICE="iPhone 6s"
2 | SCAN_SDK=iphonesimulator9.3
3 | EXAMPLE_DESTINATION="platform=iOS Simulator,name=iPhone 6s"
--------------------------------------------------------------------------------
/fastlane/.env.osx:
--------------------------------------------------------------------------------
1 | SCAN_SCHEME=$AF_OSX_FRAMEWORK_SCHEME
2 | SCAN_SDK=$AF_OSX_SDK
3 |
4 | EXAMPLE_SCHEME=$AF_OSX_EXAMPLE_SCHEME
5 | EXAMPLE_DESTINATION="platform=macOS"
--------------------------------------------------------------------------------
/fastlane/.env.tvos11_xcode9:
--------------------------------------------------------------------------------
1 | SCAN_SCHEME=$AF_TVOS_FRAMEWORK_SCHEME
2 | SCAN_DEVICE="Apple TV 4K"
3 | SCAN_SDK=$AF_TVOS_SDK
4 |
5 | EXAMPLE_SCHEME=$AF_TVOS_EXAMPLE_SCHEME
6 | EXAMPLE_DESTINATION="platform=tvOS Simulator,name=Apple TV 4K"
7 |
--------------------------------------------------------------------------------
/fastlane/Fastfile:
--------------------------------------------------------------------------------
1 | import_from_git(
2 | url: 'https://github.com/AFNetworking/fastlane.git',
3 | branch: '0.0.6'
4 | )
5 |
--------------------------------------------------------------------------------