GuijiAI commited on
Commit
bbbb146
·
verified ·
1 Parent(s): 9f7afb0

Upload 119 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.pbxproj +668 -0
  2. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  3. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  4. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/xcshareddata/xcschemes/GJLocalDigitalDemo.xcscheme +77 -0
  5. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/contents.xcworkspacedata +10 -0
  6. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  7. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcuserdata/guiji.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  8. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcuserdata/guiji.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +72 -0
  9. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/GJLocalDigitalSDK +0 -0
  10. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Headers/GJLDigitalManager.h +51 -0
  11. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Headers/GJLocalDigitalSDK.h +19 -0
  12. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Info.plist +0 -0
  13. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Modules/module.modulemap +6 -0
  14. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/_CodeSignature/CodeResources +135 -0
  15. GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.md +181 -0
  16. GJLocalDigitalDemo/GJLocalDigitalDemo/Podfile +31 -0
  17. GJLocalDigitalDemo/GJLocalDigitalDemo/Podfile.lock +34 -0
  18. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFCompatibilityMacros.h +49 -0
  19. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h +285 -0
  20. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m +357 -0
  21. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h +216 -0
  22. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m +269 -0
  23. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworking.h +41 -0
  24. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h +161 -0
  25. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m +341 -0
  26. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h +479 -0
  27. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m +1399 -0
  28. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h +313 -0
  29. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m +836 -0
  30. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h +516 -0
  31. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m +1274 -0
  32. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/LICENSE +19 -0
  33. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/README.md +298 -0
  34. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h +160 -0
  35. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m +205 -0
  36. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h +171 -0
  37. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m +421 -0
  38. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h +103 -0
  39. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m +239 -0
  40. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h +48 -0
  41. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m +114 -0
  42. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h +175 -0
  43. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m +302 -0
  44. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h +109 -0
  45. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m +159 -0
  46. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h +43 -0
  47. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h +64 -0
  48. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m +126 -0
  49. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h +53 -0
  50. GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m +113 -0
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.pbxproj ADDED
@@ -0,0 +1,668 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // !$*UTF8*$!
2
+ {
3
+ archiveVersion = 1;
4
+ classes = {
5
+ };
6
+ objectVersion = 56;
7
+ objects = {
8
+
9
+ /* Begin PBXBuildFile section */
10
+ 7FA77A706ADB2579D0F321CD /* Pods_GJLocalDigitalDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9463708D551DF8AC78746988 /* Pods_GJLocalDigitalDemo.framework */; };
11
+ A037D5F12B3D0B1800E1AF98 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A037D5F02B3D0B1800E1AF98 /* AVFoundation.framework */; };
12
+ A04821D12B2C48BC005E06BD /* HttpClient.m in Sources */ = {isa = PBXBuildFile; fileRef = A04821CD2B2C48BC005E06BD /* HttpClient.m */; };
13
+ A04821D92B2C49CC005E06BD /* OpenUDID.m in Sources */ = {isa = PBXBuildFile; fileRef = A04821D62B2C49CC005E06BD /* OpenUDID.m */; };
14
+ A04821E42B2C4EC8005E06BD /* SVRadialGradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A04821DB2B2C4EC8005E06BD /* SVRadialGradientLayer.m */; };
15
+ A04821E52B2C4EC8005E06BD /* SVProgressAnimatedView.m in Sources */ = {isa = PBXBuildFile; fileRef = A04821DE2B2C4EC8005E06BD /* SVProgressAnimatedView.m */; };
16
+ A04821E62B2C4EC8005E06BD /* SVProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = A04821E02B2C4EC8005E06BD /* SVProgressHUD.m */; };
17
+ A04821E72B2C4EC8005E06BD /* SVIndefiniteAnimatedView.m in Sources */ = {isa = PBXBuildFile; fileRef = A04821E12B2C4EC8005E06BD /* SVIndefiniteAnimatedView.m */; };
18
+ A04821E82B2C4EC8005E06BD /* SVProgressHUD.bundle in Resources */ = {isa = PBXBuildFile; fileRef = A04821E22B2C4EC8005E06BD /* SVProgressHUD.bundle */; };
19
+ A04821F12B2C5650005E06BD /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A04821E92B2C5429005E06BD /* Security.framework */; };
20
+ A04821F42B2C5695005E06BD /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = A04821EF2B2C5608005E06BD /* libz.tbd */; };
21
+ A04822222B2C5FF6005E06BD /* GJCheckNetwork.m in Sources */ = {isa = PBXBuildFile; fileRef = A04822212B2C5FF6005E06BD /* GJCheckNetwork.m */; };
22
+ A0B1C4262B299D66009E0716 /* GJLocalDigitalSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A0FC3DBE2B282FC70069EA0E /* GJLocalDigitalSDK.framework */; };
23
+ A0B1C4272B299D66009E0716 /* GJLocalDigitalSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = A0FC3DBE2B282FC70069EA0E /* GJLocalDigitalSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
24
+ A0B1C4362B29C1F2009E0716 /* 1.wav in Resources */ = {isa = PBXBuildFile; fileRef = A0B1C4352B29C1F2009E0716 /* 1.wav */; };
25
+ A0BB09402B3C34A700BF0CC1 /* GJLDigitalAnswerModel.m in Sources */ = {isa = PBXBuildFile; fileRef = A0BB093F2B3C34A700BF0CC1 /* GJLDigitalAnswerModel.m */; };
26
+ A0BB09432B3C34B800BF0CC1 /* GJDownWavTool.m in Sources */ = {isa = PBXBuildFile; fileRef = A0BB09422B3C34B800BF0CC1 /* GJDownWavTool.m */; };
27
+ A0D3B8A52B3D740500983153 /* GYAccess.m in Sources */ = {isa = PBXBuildFile; fileRef = A0D3B8A42B3D740500983153 /* GYAccess.m */; };
28
+ A0D81D9B2B299568002F98C1 /* bg2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = A0D81D9A2B299568002F98C1 /* bg2.jpg */; };
29
+ A0F908C32B32E97500962346 /* 2.wav in Resources */ = {isa = PBXBuildFile; fileRef = A0F908C02B32E97500962346 /* 2.wav */; };
30
+ A0F908C42B32E97500962346 /* 3.wav in Resources */ = {isa = PBXBuildFile; fileRef = A0F908C22B32E97500962346 /* 3.wav */; };
31
+ A0FC3DA02B282F1B0069EA0E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A0FC3D9F2B282F1B0069EA0E /* AppDelegate.m */; };
32
+ A0FC3DA62B282F1B0069EA0E /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = A0FC3DA52B282F1B0069EA0E /* ViewController.mm */; };
33
+ A0FC3DA92B282F1B0069EA0E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A0FC3DA72B282F1B0069EA0E /* Main.storyboard */; };
34
+ A0FC3DAB2B282F1D0069EA0E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A0FC3DAA2B282F1D0069EA0E /* Assets.xcassets */; };
35
+ A0FC3DAE2B282F1D0069EA0E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A0FC3DAC2B282F1D0069EA0E /* LaunchScreen.storyboard */; };
36
+ A0FC3DB12B282F1D0069EA0E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A0FC3DB02B282F1D0069EA0E /* main.m */; };
37
+ /* End PBXBuildFile section */
38
+
39
+ /* Begin PBXContainerItemProxy section */
40
+ A0FC3DBD2B282FC70069EA0E /* PBXContainerItemProxy */ = {
41
+ isa = PBXContainerItemProxy;
42
+ containerPortal = A0FC3DB92B282FC70069EA0E /* GJLocalDigitalSDK.xcodeproj */;
43
+ proxyType = 2;
44
+ remoteGlobalIDString = A0FC3D822B282DC40069EA0E;
45
+ remoteInfo = GJLocalDigitalSDK;
46
+ };
47
+ /* End PBXContainerItemProxy section */
48
+
49
+ /* Begin PBXCopyFilesBuildPhase section */
50
+ A0B1C4282B299D66009E0716 /* Embed Frameworks */ = {
51
+ isa = PBXCopyFilesBuildPhase;
52
+ buildActionMask = 2147483647;
53
+ dstPath = "";
54
+ dstSubfolderSpec = 10;
55
+ files = (
56
+ A0B1C4272B299D66009E0716 /* GJLocalDigitalSDK.framework in Embed Frameworks */,
57
+ );
58
+ name = "Embed Frameworks";
59
+ runOnlyForDeploymentPostprocessing = 0;
60
+ };
61
+ /* End PBXCopyFilesBuildPhase section */
62
+
63
+ /* Begin PBXFileReference section */
64
+ 9463708D551DF8AC78746988 /* Pods_GJLocalDigitalDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_GJLocalDigitalDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; };
65
+ A037D5F02B3D0B1800E1AF98 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
66
+ A04821CD2B2C48BC005E06BD /* HttpClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HttpClient.m; sourceTree = "<group>"; };
67
+ A04821CF2B2C48BC005E06BD /* HttpClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpClient.h; sourceTree = "<group>"; };
68
+ A04821D62B2C49CC005E06BD /* OpenUDID.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OpenUDID.m; sourceTree = "<group>"; };
69
+ A04821D72B2C49CC005E06BD /* OpenUDID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenUDID.h; sourceTree = "<group>"; };
70
+ A04821DB2B2C4EC8005E06BD /* SVRadialGradientLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVRadialGradientLayer.m; sourceTree = "<group>"; };
71
+ A04821DC2B2C4EC8005E06BD /* SVIndefiniteAnimatedView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVIndefiniteAnimatedView.h; sourceTree = "<group>"; };
72
+ A04821DD2B2C4EC8005E06BD /* SVProgressHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVProgressHUD.h; sourceTree = "<group>"; };
73
+ A04821DE2B2C4EC8005E06BD /* SVProgressAnimatedView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVProgressAnimatedView.m; sourceTree = "<group>"; };
74
+ A04821DF2B2C4EC8005E06BD /* SVRadialGradientLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVRadialGradientLayer.h; sourceTree = "<group>"; };
75
+ A04821E02B2C4EC8005E06BD /* SVProgressHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVProgressHUD.m; sourceTree = "<group>"; };
76
+ A04821E12B2C4EC8005E06BD /* SVIndefiniteAnimatedView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVIndefiniteAnimatedView.m; sourceTree = "<group>"; };
77
+ A04821E22B2C4EC8005E06BD /* SVProgressHUD.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = SVProgressHUD.bundle; sourceTree = "<group>"; };
78
+ A04821E32B2C4EC8005E06BD /* SVProgressAnimatedView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVProgressAnimatedView.h; sourceTree = "<group>"; };
79
+ A04821E92B2C5429005E06BD /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
80
+ A04821EB2B2C5508005E06BD /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
81
+ A04821ED2B2C550D005E06BD /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
82
+ A04821EF2B2C5608005E06BD /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
83
+ A04821F22B2C567E005E06BD /* libz.1.2.8.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.1.2.8.tbd; path = usr/lib/libz.1.2.8.tbd; sourceTree = SDKROOT; };
84
+ A04822202B2C5FF6005E06BD /* GJCheckNetwork.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GJCheckNetwork.h; sourceTree = "<group>"; };
85
+ A04822212B2C5FF6005E06BD /* GJCheckNetwork.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GJCheckNetwork.m; sourceTree = "<group>"; };
86
+ A0B1C4352B29C1F2009E0716 /* 1.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = 1.wav; sourceTree = "<group>"; };
87
+ A0BB093E2B3C34A700BF0CC1 /* GJLDigitalAnswerModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GJLDigitalAnswerModel.h; sourceTree = "<group>"; };
88
+ A0BB093F2B3C34A700BF0CC1 /* GJLDigitalAnswerModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GJLDigitalAnswerModel.m; sourceTree = "<group>"; };
89
+ A0BB09412B3C34B800BF0CC1 /* GJDownWavTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GJDownWavTool.h; sourceTree = "<group>"; };
90
+ A0BB09422B3C34B800BF0CC1 /* GJDownWavTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GJDownWavTool.m; sourceTree = "<group>"; };
91
+ A0D3B8A32B3D740500983153 /* GYAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GYAccess.h; sourceTree = "<group>"; };
92
+ A0D3B8A42B3D740500983153 /* GYAccess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GYAccess.m; sourceTree = "<group>"; };
93
+ A0D81D6D2B298F7A002F98C1 /* GJLocalDigitalSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GJLocalDigitalSDK.framework; path = "../../Library/Developer/Xcode/DerivedData/GJLocalDigitalDemo-gebpkaexfkvglzatozdgkldxlnvo/Build/Products/Debug-iphoneos/GJLocalDigitalSDK.framework"; sourceTree = "<group>"; };
94
+ A0D81D7F2B29915D002F98C1 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; };
95
+ A0D81D852B2992AD002F98C1 /* opencv2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = opencv2.framework; path = ../GJLocalDigitalSDK/GJLocalDigitalSDK/GJFrameWork/opencv2.framework; sourceTree = "<group>"; };
96
+ A0D81D892B2992B2002F98C1 /* ncnn.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ncnn.framework; path = ../GJLocalDigitalSDK/GJLocalDigitalSDK/GJFrameWork/ncnn.framework; sourceTree = "<group>"; };
97
+ A0D81D8C2B2992B4002F98C1 /* openmp.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = openmp.framework; path = ../GJLocalDigitalSDK/GJLocalDigitalSDK/GJFrameWork/openmp.framework; sourceTree = "<group>"; };
98
+ A0D81D8F2B2992C1002F98C1 /* onnxruntime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = onnxruntime.framework; path = ../GJLocalDigitalSDK/GJLocalDigitalSDK/GJFrameWork/onnxruntime.framework; sourceTree = "<group>"; };
99
+ A0D81D9A2B299568002F98C1 /* bg2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = bg2.jpg; sourceTree = "<group>"; };
100
+ A0F908C02B32E97500962346 /* 2.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = 2.wav; sourceTree = "<group>"; };
101
+ A0F908C22B32E97500962346 /* 3.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = 3.wav; sourceTree = "<group>"; };
102
+ A0FC3D9B2B282F1B0069EA0E /* GJLocalDigitalDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GJLocalDigitalDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
103
+ A0FC3D9E2B282F1B0069EA0E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
104
+ A0FC3D9F2B282F1B0069EA0E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
105
+ A0FC3DA42B282F1B0069EA0E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
106
+ A0FC3DA52B282F1B0069EA0E /* ViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewController.mm; sourceTree = "<group>"; };
107
+ A0FC3DA82B282F1B0069EA0E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
108
+ A0FC3DAA2B282F1D0069EA0E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
109
+ A0FC3DAD2B282F1D0069EA0E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
110
+ A0FC3DAF2B282F1D0069EA0E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
111
+ A0FC3DB02B282F1D0069EA0E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
112
+ A0FC3DB92B282FC70069EA0E /* GJLocalDigitalSDK.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GJLocalDigitalSDK.xcodeproj; path = ../GJLocalDigitalSDK/GJLocalDigitalSDK.xcodeproj; sourceTree = "<group>"; };
113
+ A0FC3EAE2B2855AC0069EA0E /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; };
114
+ CC0F95EC41CD11CE487F313E /* Pods-GJLocalDigitalDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GJLocalDigitalDemo.release.xcconfig"; path = "Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.release.xcconfig"; sourceTree = "<group>"; };
115
+ CDE763B79F6CA6E21DE1F3CE /* Pods-GJLocalDigitalDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GJLocalDigitalDemo.debug.xcconfig"; path = "Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.debug.xcconfig"; sourceTree = "<group>"; };
116
+ /* End PBXFileReference section */
117
+
118
+ /* Begin PBXFrameworksBuildPhase section */
119
+ A0FC3D982B282F1B0069EA0E /* Frameworks */ = {
120
+ isa = PBXFrameworksBuildPhase;
121
+ buildActionMask = 2147483647;
122
+ files = (
123
+ A037D5F12B3D0B1800E1AF98 /* AVFoundation.framework in Frameworks */,
124
+ A04821F42B2C5695005E06BD /* libz.tbd in Frameworks */,
125
+ A04821F12B2C5650005E06BD /* Security.framework in Frameworks */,
126
+ A0B1C4262B299D66009E0716 /* GJLocalDigitalSDK.framework in Frameworks */,
127
+ 7FA77A706ADB2579D0F321CD /* Pods_GJLocalDigitalDemo.framework in Frameworks */,
128
+ );
129
+ runOnlyForDeploymentPostprocessing = 0;
130
+ };
131
+ /* End PBXFrameworksBuildPhase section */
132
+
133
+ /* Begin PBXGroup section */
134
+ A04821CC2B2C48BC005E06BD /* HttpClient */ = {
135
+ isa = PBXGroup;
136
+ children = (
137
+ A04821CF2B2C48BC005E06BD /* HttpClient.h */,
138
+ A04821CD2B2C48BC005E06BD /* HttpClient.m */,
139
+ );
140
+ path = HttpClient;
141
+ sourceTree = "<group>";
142
+ };
143
+ A04821D52B2C49CC005E06BD /* OpenUDID-master */ = {
144
+ isa = PBXGroup;
145
+ children = (
146
+ A04821D62B2C49CC005E06BD /* OpenUDID.m */,
147
+ A04821D72B2C49CC005E06BD /* OpenUDID.h */,
148
+ );
149
+ path = "OpenUDID-master";
150
+ sourceTree = "<group>";
151
+ };
152
+ A04821DA2B2C4EC8005E06BD /* SVProgressHUD */ = {
153
+ isa = PBXGroup;
154
+ children = (
155
+ A04821DB2B2C4EC8005E06BD /* SVRadialGradientLayer.m */,
156
+ A04821DC2B2C4EC8005E06BD /* SVIndefiniteAnimatedView.h */,
157
+ A04821DD2B2C4EC8005E06BD /* SVProgressHUD.h */,
158
+ A04821DE2B2C4EC8005E06BD /* SVProgressAnimatedView.m */,
159
+ A04821DF2B2C4EC8005E06BD /* SVRadialGradientLayer.h */,
160
+ A04821E02B2C4EC8005E06BD /* SVProgressHUD.m */,
161
+ A04821E12B2C4EC8005E06BD /* SVIndefiniteAnimatedView.m */,
162
+ A04821E22B2C4EC8005E06BD /* SVProgressHUD.bundle */,
163
+ A04821E32B2C4EC8005E06BD /* SVProgressAnimatedView.h */,
164
+ );
165
+ path = SVProgressHUD;
166
+ sourceTree = "<group>";
167
+ };
168
+ A048221F2B2C5FF6005E06BD /* GJCheckNetwork */ = {
169
+ isa = PBXGroup;
170
+ children = (
171
+ A04822202B2C5FF6005E06BD /* GJCheckNetwork.h */,
172
+ A04822212B2C5FF6005E06BD /* GJCheckNetwork.m */,
173
+ );
174
+ path = GJCheckNetwork;
175
+ sourceTree = "<group>";
176
+ };
177
+ A0BB093D2B3C34A700BF0CC1 /* DigitalAnswerModel */ = {
178
+ isa = PBXGroup;
179
+ children = (
180
+ A0BB093E2B3C34A700BF0CC1 /* GJLDigitalAnswerModel.h */,
181
+ A0BB093F2B3C34A700BF0CC1 /* GJLDigitalAnswerModel.m */,
182
+ A0BB09412B3C34B800BF0CC1 /* GJDownWavTool.h */,
183
+ A0BB09422B3C34B800BF0CC1 /* GJDownWavTool.m */,
184
+ );
185
+ path = DigitalAnswerModel;
186
+ sourceTree = "<group>";
187
+ };
188
+ A0D3B8A22B3D740500983153 /* GYAccess */ = {
189
+ isa = PBXGroup;
190
+ children = (
191
+ A0D3B8A32B3D740500983153 /* GYAccess.h */,
192
+ A0D3B8A42B3D740500983153 /* GYAccess.m */,
193
+ );
194
+ path = GYAccess;
195
+ sourceTree = "<group>";
196
+ };
197
+ A0D81D992B299558002F98C1 /* Resources */ = {
198
+ isa = PBXGroup;
199
+ children = (
200
+ A0B1C4352B29C1F2009E0716 /* 1.wav */,
201
+ A0F908C02B32E97500962346 /* 2.wav */,
202
+ A0F908C22B32E97500962346 /* 3.wav */,
203
+ A0D81D9A2B299568002F98C1 /* bg2.jpg */,
204
+ );
205
+ path = Resources;
206
+ sourceTree = "<group>";
207
+ };
208
+ A0FC3D922B282F1B0069EA0E = {
209
+ isa = PBXGroup;
210
+ children = (
211
+ A0FC3DB92B282FC70069EA0E /* GJLocalDigitalSDK.xcodeproj */,
212
+ A0FC3D9D2B282F1B0069EA0E /* GJLocalDigitalDemo */,
213
+ A0FC3D9C2B282F1B0069EA0E /* Products */,
214
+ A0FC3EAC2B2855AC0069EA0E /* Frameworks */,
215
+ ECE2CDAA117EDC79BA8F9D60 /* Pods */,
216
+ );
217
+ sourceTree = "<group>";
218
+ };
219
+ A0FC3D9C2B282F1B0069EA0E /* Products */ = {
220
+ isa = PBXGroup;
221
+ children = (
222
+ A0FC3D9B2B282F1B0069EA0E /* GJLocalDigitalDemo.app */,
223
+ );
224
+ name = Products;
225
+ sourceTree = "<group>";
226
+ };
227
+ A0FC3D9D2B282F1B0069EA0E /* GJLocalDigitalDemo */ = {
228
+ isa = PBXGroup;
229
+ children = (
230
+ A0D3B8A22B3D740500983153 /* GYAccess */,
231
+ A0BB093D2B3C34A700BF0CC1 /* DigitalAnswerModel */,
232
+ A048221F2B2C5FF6005E06BD /* GJCheckNetwork */,
233
+ A04821DA2B2C4EC8005E06BD /* SVProgressHUD */,
234
+ A04821D52B2C49CC005E06BD /* OpenUDID-master */,
235
+ A04821CC2B2C48BC005E06BD /* HttpClient */,
236
+ A0D81D992B299558002F98C1 /* Resources */,
237
+ A0FC3D9E2B282F1B0069EA0E /* AppDelegate.h */,
238
+ A0FC3D9F2B282F1B0069EA0E /* AppDelegate.m */,
239
+ A0FC3DA42B282F1B0069EA0E /* ViewController.h */,
240
+ A0FC3DA52B282F1B0069EA0E /* ViewController.mm */,
241
+ A0FC3DA72B282F1B0069EA0E /* Main.storyboard */,
242
+ A0FC3DAA2B282F1D0069EA0E /* Assets.xcassets */,
243
+ A0FC3DAC2B282F1D0069EA0E /* LaunchScreen.storyboard */,
244
+ A0FC3DAF2B282F1D0069EA0E /* Info.plist */,
245
+ A0FC3DB02B282F1D0069EA0E /* main.m */,
246
+ );
247
+ path = GJLocalDigitalDemo;
248
+ sourceTree = "<group>";
249
+ };
250
+ A0FC3DBA2B282FC70069EA0E /* Products */ = {
251
+ isa = PBXGroup;
252
+ children = (
253
+ A0FC3DBE2B282FC70069EA0E /* GJLocalDigitalSDK.framework */,
254
+ );
255
+ name = Products;
256
+ sourceTree = "<group>";
257
+ };
258
+ A0FC3EAC2B2855AC0069EA0E /* Frameworks */ = {
259
+ isa = PBXGroup;
260
+ children = (
261
+ A037D5F02B3D0B1800E1AF98 /* AVFoundation.framework */,
262
+ A04821F22B2C567E005E06BD /* libz.1.2.8.tbd */,
263
+ A04821EF2B2C5608005E06BD /* libz.tbd */,
264
+ A04821ED2B2C550D005E06BD /* Foundation.framework */,
265
+ A04821EB2B2C5508005E06BD /* UIKit.framework */,
266
+ A04821E92B2C5429005E06BD /* Security.framework */,
267
+ A0D81D8F2B2992C1002F98C1 /* onnxruntime.framework */,
268
+ A0D81D8C2B2992B4002F98C1 /* openmp.framework */,
269
+ A0D81D892B2992B2002F98C1 /* ncnn.framework */,
270
+ A0D81D852B2992AD002F98C1 /* opencv2.framework */,
271
+ A0D81D7F2B29915D002F98C1 /* Metal.framework */,
272
+ A0D81D6D2B298F7A002F98C1 /* GJLocalDigitalSDK.framework */,
273
+ A0FC3EAE2B2855AC0069EA0E /* MetalKit.framework */,
274
+ 9463708D551DF8AC78746988 /* Pods_GJLocalDigitalDemo.framework */,
275
+ );
276
+ name = Frameworks;
277
+ sourceTree = "<group>";
278
+ };
279
+ ECE2CDAA117EDC79BA8F9D60 /* Pods */ = {
280
+ isa = PBXGroup;
281
+ children = (
282
+ CDE763B79F6CA6E21DE1F3CE /* Pods-GJLocalDigitalDemo.debug.xcconfig */,
283
+ CC0F95EC41CD11CE487F313E /* Pods-GJLocalDigitalDemo.release.xcconfig */,
284
+ );
285
+ path = Pods;
286
+ sourceTree = "<group>";
287
+ };
288
+ /* End PBXGroup section */
289
+
290
+ /* Begin PBXNativeTarget section */
291
+ A0FC3D9A2B282F1B0069EA0E /* GJLocalDigitalDemo */ = {
292
+ isa = PBXNativeTarget;
293
+ buildConfigurationList = A0FC3DB42B282F1D0069EA0E /* Build configuration list for PBXNativeTarget "GJLocalDigitalDemo" */;
294
+ buildPhases = (
295
+ 520A0B9D7BC7E31018FF2800 /* [CP] Check Pods Manifest.lock */,
296
+ A0FC3D972B282F1B0069EA0E /* Sources */,
297
+ A0FC3D982B282F1B0069EA0E /* Frameworks */,
298
+ A0FC3D992B282F1B0069EA0E /* Resources */,
299
+ A0B1C4282B299D66009E0716 /* Embed Frameworks */,
300
+ AEFFC1C636473627C8C0E111 /* [CP] Embed Pods Frameworks */,
301
+ );
302
+ buildRules = (
303
+ );
304
+ dependencies = (
305
+ );
306
+ name = GJLocalDigitalDemo;
307
+ productName = GJLocalDigitalDemo;
308
+ productReference = A0FC3D9B2B282F1B0069EA0E /* GJLocalDigitalDemo.app */;
309
+ productType = "com.apple.product-type.application";
310
+ };
311
+ /* End PBXNativeTarget section */
312
+
313
+ /* Begin PBXProject section */
314
+ A0FC3D932B282F1B0069EA0E /* Project object */ = {
315
+ isa = PBXProject;
316
+ attributes = {
317
+ BuildIndependentTargetsInParallel = 1;
318
+ LastUpgradeCheck = 1500;
319
+ TargetAttributes = {
320
+ A0FC3D9A2B282F1B0069EA0E = {
321
+ CreatedOnToolsVersion = 15.0.1;
322
+ };
323
+ };
324
+ };
325
+ buildConfigurationList = A0FC3D962B282F1B0069EA0E /* Build configuration list for PBXProject "GJLocalDigitalDemo" */;
326
+ compatibilityVersion = "Xcode 14.0";
327
+ developmentRegion = en;
328
+ hasScannedForEncodings = 0;
329
+ knownRegions = (
330
+ en,
331
+ Base,
332
+ );
333
+ mainGroup = A0FC3D922B282F1B0069EA0E;
334
+ productRefGroup = A0FC3D9C2B282F1B0069EA0E /* Products */;
335
+ projectDirPath = "";
336
+ projectReferences = (
337
+ {
338
+ ProductGroup = A0FC3DBA2B282FC70069EA0E /* Products */;
339
+ ProjectRef = A0FC3DB92B282FC70069EA0E /* GJLocalDigitalSDK.xcodeproj */;
340
+ },
341
+ );
342
+ projectRoot = "";
343
+ targets = (
344
+ A0FC3D9A2B282F1B0069EA0E /* GJLocalDigitalDemo */,
345
+ );
346
+ };
347
+ /* End PBXProject section */
348
+
349
+ /* Begin PBXReferenceProxy section */
350
+ A0FC3DBE2B282FC70069EA0E /* GJLocalDigitalSDK.framework */ = {
351
+ isa = PBXReferenceProxy;
352
+ fileType = wrapper.framework;
353
+ path = GJLocalDigitalSDK.framework;
354
+ remoteRef = A0FC3DBD2B282FC70069EA0E /* PBXContainerItemProxy */;
355
+ sourceTree = BUILT_PRODUCTS_DIR;
356
+ };
357
+ /* End PBXReferenceProxy section */
358
+
359
+ /* Begin PBXResourcesBuildPhase section */
360
+ A0FC3D992B282F1B0069EA0E /* Resources */ = {
361
+ isa = PBXResourcesBuildPhase;
362
+ buildActionMask = 2147483647;
363
+ files = (
364
+ A0B1C4362B29C1F2009E0716 /* 1.wav in Resources */,
365
+ A0FC3DAE2B282F1D0069EA0E /* LaunchScreen.storyboard in Resources */,
366
+ A0D81D9B2B299568002F98C1 /* bg2.jpg in Resources */,
367
+ A04821E82B2C4EC8005E06BD /* SVProgressHUD.bundle in Resources */,
368
+ A0F908C42B32E97500962346 /* 3.wav in Resources */,
369
+ A0F908C32B32E97500962346 /* 2.wav in Resources */,
370
+ A0FC3DAB2B282F1D0069EA0E /* Assets.xcassets in Resources */,
371
+ A0FC3DA92B282F1B0069EA0E /* Main.storyboard in Resources */,
372
+ );
373
+ runOnlyForDeploymentPostprocessing = 0;
374
+ };
375
+ /* End PBXResourcesBuildPhase section */
376
+
377
+ /* Begin PBXShellScriptBuildPhase section */
378
+ 520A0B9D7BC7E31018FF2800 /* [CP] Check Pods Manifest.lock */ = {
379
+ isa = PBXShellScriptBuildPhase;
380
+ buildActionMask = 2147483647;
381
+ files = (
382
+ );
383
+ inputFileListPaths = (
384
+ );
385
+ inputPaths = (
386
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
387
+ "${PODS_ROOT}/Manifest.lock",
388
+ );
389
+ name = "[CP] Check Pods Manifest.lock";
390
+ outputFileListPaths = (
391
+ );
392
+ outputPaths = (
393
+ "$(DERIVED_FILE_DIR)/Pods-GJLocalDigitalDemo-checkManifestLockResult.txt",
394
+ );
395
+ runOnlyForDeploymentPostprocessing = 0;
396
+ shellPath = /bin/sh;
397
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
398
+ showEnvVarsInLog = 0;
399
+ };
400
+ AEFFC1C636473627C8C0E111 /* [CP] Embed Pods Frameworks */ = {
401
+ isa = PBXShellScriptBuildPhase;
402
+ buildActionMask = 2147483647;
403
+ files = (
404
+ );
405
+ inputFileListPaths = (
406
+ "${PODS_ROOT}/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-${CONFIGURATION}-input-files.xcfilelist",
407
+ );
408
+ name = "[CP] Embed Pods Frameworks";
409
+ outputFileListPaths = (
410
+ "${PODS_ROOT}/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-${CONFIGURATION}-output-files.xcfilelist",
411
+ );
412
+ runOnlyForDeploymentPostprocessing = 0;
413
+ shellPath = /bin/sh;
414
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks.sh\"\n";
415
+ showEnvVarsInLog = 0;
416
+ };
417
+ /* End PBXShellScriptBuildPhase section */
418
+
419
+ /* Begin PBXSourcesBuildPhase section */
420
+ A0FC3D972B282F1B0069EA0E /* Sources */ = {
421
+ isa = PBXSourcesBuildPhase;
422
+ buildActionMask = 2147483647;
423
+ files = (
424
+ A04821E42B2C4EC8005E06BD /* SVRadialGradientLayer.m in Sources */,
425
+ A0FC3DA62B282F1B0069EA0E /* ViewController.mm in Sources */,
426
+ A0BB09402B3C34A700BF0CC1 /* GJLDigitalAnswerModel.m in Sources */,
427
+ A0FC3DA02B282F1B0069EA0E /* AppDelegate.m in Sources */,
428
+ A04821D12B2C48BC005E06BD /* HttpClient.m in Sources */,
429
+ A04821D92B2C49CC005E06BD /* OpenUDID.m in Sources */,
430
+ A04821E72B2C4EC8005E06BD /* SVIndefiniteAnimatedView.m in Sources */,
431
+ A0BB09432B3C34B800BF0CC1 /* GJDownWavTool.m in Sources */,
432
+ A0D3B8A52B3D740500983153 /* GYAccess.m in Sources */,
433
+ A04821E62B2C4EC8005E06BD /* SVProgressHUD.m in Sources */,
434
+ A04822222B2C5FF6005E06BD /* GJCheckNetwork.m in Sources */,
435
+ A0FC3DB12B282F1D0069EA0E /* main.m in Sources */,
436
+ A04821E52B2C4EC8005E06BD /* SVProgressAnimatedView.m in Sources */,
437
+ );
438
+ runOnlyForDeploymentPostprocessing = 0;
439
+ };
440
+ /* End PBXSourcesBuildPhase section */
441
+
442
+ /* Begin PBXVariantGroup section */
443
+ A0FC3DA72B282F1B0069EA0E /* Main.storyboard */ = {
444
+ isa = PBXVariantGroup;
445
+ children = (
446
+ A0FC3DA82B282F1B0069EA0E /* Base */,
447
+ );
448
+ name = Main.storyboard;
449
+ sourceTree = "<group>";
450
+ };
451
+ A0FC3DAC2B282F1D0069EA0E /* LaunchScreen.storyboard */ = {
452
+ isa = PBXVariantGroup;
453
+ children = (
454
+ A0FC3DAD2B282F1D0069EA0E /* Base */,
455
+ );
456
+ name = LaunchScreen.storyboard;
457
+ sourceTree = "<group>";
458
+ };
459
+ /* End PBXVariantGroup section */
460
+
461
+ /* Begin XCBuildConfiguration section */
462
+ A0FC3DB22B282F1D0069EA0E /* Debug */ = {
463
+ isa = XCBuildConfiguration;
464
+ buildSettings = {
465
+ ALWAYS_SEARCH_USER_PATHS = NO;
466
+ ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
467
+ CLANG_ANALYZER_NONNULL = YES;
468
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
469
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
470
+ CLANG_ENABLE_MODULES = YES;
471
+ CLANG_ENABLE_OBJC_ARC = YES;
472
+ CLANG_ENABLE_OBJC_WEAK = YES;
473
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
474
+ CLANG_WARN_BOOL_CONVERSION = YES;
475
+ CLANG_WARN_COMMA = YES;
476
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
477
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
478
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
479
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
480
+ CLANG_WARN_EMPTY_BODY = YES;
481
+ CLANG_WARN_ENUM_CONVERSION = YES;
482
+ CLANG_WARN_INFINITE_RECURSION = YES;
483
+ CLANG_WARN_INT_CONVERSION = YES;
484
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
485
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
486
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
487
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
488
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
489
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
490
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
491
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
492
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
493
+ CLANG_WARN_UNREACHABLE_CODE = YES;
494
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
495
+ COPY_PHASE_STRIP = NO;
496
+ DEBUG_INFORMATION_FORMAT = dwarf;
497
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
498
+ ENABLE_TESTABILITY = YES;
499
+ ENABLE_USER_SCRIPT_SANDBOXING = YES;
500
+ GCC_C_LANGUAGE_STANDARD = gnu17;
501
+ GCC_DYNAMIC_NO_PIC = NO;
502
+ GCC_NO_COMMON_BLOCKS = YES;
503
+ GCC_OPTIMIZATION_LEVEL = 0;
504
+ GCC_PREPROCESSOR_DEFINITIONS = (
505
+ "DEBUG=1",
506
+ "$(inherited)",
507
+ );
508
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
509
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
510
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
511
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
512
+ GCC_WARN_UNUSED_FUNCTION = YES;
513
+ GCC_WARN_UNUSED_VARIABLE = YES;
514
+ IPHONEOS_DEPLOYMENT_TARGET = 17.0;
515
+ LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
516
+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
517
+ MTL_FAST_MATH = YES;
518
+ ONLY_ACTIVE_ARCH = YES;
519
+ SDKROOT = iphoneos;
520
+ };
521
+ name = Debug;
522
+ };
523
+ A0FC3DB32B282F1D0069EA0E /* Release */ = {
524
+ isa = XCBuildConfiguration;
525
+ buildSettings = {
526
+ ALWAYS_SEARCH_USER_PATHS = NO;
527
+ ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
528
+ CLANG_ANALYZER_NONNULL = YES;
529
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
530
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
531
+ CLANG_ENABLE_MODULES = YES;
532
+ CLANG_ENABLE_OBJC_ARC = YES;
533
+ CLANG_ENABLE_OBJC_WEAK = YES;
534
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
535
+ CLANG_WARN_BOOL_CONVERSION = YES;
536
+ CLANG_WARN_COMMA = YES;
537
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
538
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
539
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
540
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
541
+ CLANG_WARN_EMPTY_BODY = YES;
542
+ CLANG_WARN_ENUM_CONVERSION = YES;
543
+ CLANG_WARN_INFINITE_RECURSION = YES;
544
+ CLANG_WARN_INT_CONVERSION = YES;
545
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
546
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
547
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
548
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
549
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
550
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
551
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
552
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
553
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
554
+ CLANG_WARN_UNREACHABLE_CODE = YES;
555
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
556
+ COPY_PHASE_STRIP = NO;
557
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
558
+ ENABLE_NS_ASSERTIONS = NO;
559
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
560
+ ENABLE_USER_SCRIPT_SANDBOXING = YES;
561
+ GCC_C_LANGUAGE_STANDARD = gnu17;
562
+ GCC_NO_COMMON_BLOCKS = YES;
563
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
564
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
565
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
566
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
567
+ GCC_WARN_UNUSED_FUNCTION = YES;
568
+ GCC_WARN_UNUSED_VARIABLE = YES;
569
+ IPHONEOS_DEPLOYMENT_TARGET = 17.0;
570
+ LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
571
+ MTL_ENABLE_DEBUG_INFO = NO;
572
+ MTL_FAST_MATH = YES;
573
+ SDKROOT = iphoneos;
574
+ VALIDATE_PRODUCT = YES;
575
+ };
576
+ name = Release;
577
+ };
578
+ A0FC3DB52B282F1D0069EA0E /* Debug */ = {
579
+ isa = XCBuildConfiguration;
580
+ baseConfigurationReference = CDE763B79F6CA6E21DE1F3CE /* Pods-GJLocalDigitalDemo.debug.xcconfig */;
581
+ buildSettings = {
582
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
583
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
584
+ CODE_SIGN_STYLE = Automatic;
585
+ CURRENT_PROJECT_VERSION = 1;
586
+ DEVELOPMENT_TEAM = RHWTKM535Q;
587
+ ENABLE_USER_SCRIPT_SANDBOXING = NO;
588
+ FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/GJLocalDigitalDemo";
589
+ GENERATE_INFOPLIST_FILE = YES;
590
+ INFOPLIST_FILE = GJLocalDigitalDemo/Info.plist;
591
+ INFOPLIST_KEY_CFBundleDisplayName = SDKDemo1.0.2;
592
+ INFOPLIST_KEY_NSMicrophoneUsageDescription = "需要录音权限来语音识别";
593
+ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
594
+ INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
595
+ INFOPLIST_KEY_UIMainStoryboardFile = Main;
596
+ INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
597
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
598
+ LD_RUNPATH_SEARCH_PATHS = (
599
+ "$(inherited)",
600
+ "@executable_path/Frameworks",
601
+ );
602
+ MARKETING_VERSION = 1.1;
603
+ OTHER_LDFLAGS = "$(inherited)";
604
+ PRODUCT_BUNDLE_IDENTIFIER = com.wanruyi.sdkdemo;
605
+ PRODUCT_NAME = "$(TARGET_NAME)";
606
+ SWIFT_EMIT_LOC_STRINGS = YES;
607
+ TARGETED_DEVICE_FAMILY = "1,2";
608
+ };
609
+ name = Debug;
610
+ };
611
+ A0FC3DB62B282F1D0069EA0E /* Release */ = {
612
+ isa = XCBuildConfiguration;
613
+ baseConfigurationReference = CC0F95EC41CD11CE487F313E /* Pods-GJLocalDigitalDemo.release.xcconfig */;
614
+ buildSettings = {
615
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
616
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
617
+ CODE_SIGN_STYLE = Automatic;
618
+ CURRENT_PROJECT_VERSION = 1;
619
+ DEVELOPMENT_TEAM = RHWTKM535Q;
620
+ ENABLE_USER_SCRIPT_SANDBOXING = NO;
621
+ FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/GJLocalDigitalDemo";
622
+ GENERATE_INFOPLIST_FILE = YES;
623
+ INFOPLIST_FILE = GJLocalDigitalDemo/Info.plist;
624
+ INFOPLIST_KEY_CFBundleDisplayName = SDKDemo1.0.2;
625
+ INFOPLIST_KEY_NSMicrophoneUsageDescription = "需要录音权限来语音识别";
626
+ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
627
+ INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
628
+ INFOPLIST_KEY_UIMainStoryboardFile = Main;
629
+ INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
630
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
631
+ LD_RUNPATH_SEARCH_PATHS = (
632
+ "$(inherited)",
633
+ "@executable_path/Frameworks",
634
+ );
635
+ MARKETING_VERSION = 1.1;
636
+ OTHER_LDFLAGS = "$(inherited)";
637
+ PRODUCT_BUNDLE_IDENTIFIER = com.wanruyi.sdkdemo;
638
+ PRODUCT_NAME = "$(TARGET_NAME)";
639
+ SWIFT_EMIT_LOC_STRINGS = YES;
640
+ TARGETED_DEVICE_FAMILY = "1,2";
641
+ };
642
+ name = Release;
643
+ };
644
+ /* End XCBuildConfiguration section */
645
+
646
+ /* Begin XCConfigurationList section */
647
+ A0FC3D962B282F1B0069EA0E /* Build configuration list for PBXProject "GJLocalDigitalDemo" */ = {
648
+ isa = XCConfigurationList;
649
+ buildConfigurations = (
650
+ A0FC3DB22B282F1D0069EA0E /* Debug */,
651
+ A0FC3DB32B282F1D0069EA0E /* Release */,
652
+ );
653
+ defaultConfigurationIsVisible = 0;
654
+ defaultConfigurationName = Release;
655
+ };
656
+ A0FC3DB42B282F1D0069EA0E /* Build configuration list for PBXNativeTarget "GJLocalDigitalDemo" */ = {
657
+ isa = XCConfigurationList;
658
+ buildConfigurations = (
659
+ A0FC3DB52B282F1D0069EA0E /* Debug */,
660
+ A0FC3DB62B282F1D0069EA0E /* Release */,
661
+ );
662
+ defaultConfigurationIsVisible = 0;
663
+ defaultConfigurationName = Release;
664
+ };
665
+ /* End XCConfigurationList section */
666
+ };
667
+ rootObject = A0FC3D932B282F1B0069EA0E /* Project object */;
668
+ }
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/xcshareddata/xcschemes/GJLocalDigitalDemo.xcscheme ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Scheme
3
+ LastUpgradeVersion = "1500"
4
+ version = "1.7">
5
+ <BuildAction
6
+ parallelizeBuildables = "YES"
7
+ buildImplicitDependencies = "YES">
8
+ <BuildActionEntries>
9
+ <BuildActionEntry
10
+ buildForTesting = "YES"
11
+ buildForRunning = "YES"
12
+ buildForProfiling = "YES"
13
+ buildForArchiving = "YES"
14
+ buildForAnalyzing = "YES">
15
+ <BuildableReference
16
+ BuildableIdentifier = "primary"
17
+ BlueprintIdentifier = "A0FC3D9A2B282F1B0069EA0E"
18
+ BuildableName = "GJLocalDigitalDemo.app"
19
+ BlueprintName = "GJLocalDigitalDemo"
20
+ ReferencedContainer = "container:GJLocalDigitalDemo.xcodeproj">
21
+ </BuildableReference>
22
+ </BuildActionEntry>
23
+ </BuildActionEntries>
24
+ </BuildAction>
25
+ <TestAction
26
+ buildConfiguration = "Debug"
27
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29
+ shouldUseLaunchSchemeArgsEnv = "YES"
30
+ shouldAutocreateTestPlan = "YES">
31
+ </TestAction>
32
+ <LaunchAction
33
+ buildConfiguration = "Debug"
34
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
35
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
36
+ launchStyle = "0"
37
+ useCustomWorkingDirectory = "NO"
38
+ ignoresPersistentStateOnLaunch = "NO"
39
+ debugDocumentVersioning = "YES"
40
+ debugServiceExtension = "internal"
41
+ allowLocationSimulation = "YES">
42
+ <BuildableProductRunnable
43
+ runnableDebuggingMode = "0">
44
+ <BuildableReference
45
+ BuildableIdentifier = "primary"
46
+ BlueprintIdentifier = "A0FC3D9A2B282F1B0069EA0E"
47
+ BuildableName = "GJLocalDigitalDemo.app"
48
+ BlueprintName = "GJLocalDigitalDemo"
49
+ ReferencedContainer = "container:GJLocalDigitalDemo.xcodeproj">
50
+ </BuildableReference>
51
+ </BuildableProductRunnable>
52
+ </LaunchAction>
53
+ <ProfileAction
54
+ buildConfiguration = "Release"
55
+ shouldUseLaunchSchemeArgsEnv = "YES"
56
+ savedToolIdentifier = ""
57
+ useCustomWorkingDirectory = "NO"
58
+ debugDocumentVersioning = "YES">
59
+ <BuildableProductRunnable
60
+ runnableDebuggingMode = "0">
61
+ <BuildableReference
62
+ BuildableIdentifier = "primary"
63
+ BlueprintIdentifier = "A0FC3D9A2B282F1B0069EA0E"
64
+ BuildableName = "GJLocalDigitalDemo.app"
65
+ BlueprintName = "GJLocalDigitalDemo"
66
+ ReferencedContainer = "container:GJLocalDigitalDemo.xcodeproj">
67
+ </BuildableReference>
68
+ </BuildableProductRunnable>
69
+ </ProfileAction>
70
+ <AnalyzeAction
71
+ buildConfiguration = "Debug">
72
+ </AnalyzeAction>
73
+ <ArchiveAction
74
+ buildConfiguration = "Release"
75
+ revealArchiveInOrganizer = "YES">
76
+ </ArchiveAction>
77
+ </Scheme>
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/contents.xcworkspacedata ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "group:GJLocalDigitalDemo.xcodeproj">
6
+ </FileRef>
7
+ <FileRef
8
+ location = "group:Pods/Pods.xcodeproj">
9
+ </FileRef>
10
+ </Workspace>
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcuserdata/guiji.xcuserdatad/UserInterfaceState.xcuserstate ADDED
Binary file (134 kB). View file
 
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcuserdata/guiji.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Bucket
3
+ uuid = "F8F4CC37-558B-4EC5-AEC4-914D5802CB5B"
4
+ type = "0"
5
+ version = "2.0">
6
+ <Breakpoints>
7
+ <BreakpointProxy
8
+ BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
9
+ <BreakpointContent
10
+ uuid = "4E520AB8-036D-4663-BC11-A46DEACDD7A8"
11
+ shouldBeEnabled = "No"
12
+ ignoreCount = "0"
13
+ continueAfterRunningActions = "No"
14
+ filePath = "../GJLocalDigitalSDK/GJLocalDigitalSDK/GJLDigitalManager.mm"
15
+ startingColumnNumber = "9223372036854775807"
16
+ endingColumnNumber = "9223372036854775807"
17
+ startingLineNumber = "878"
18
+ endingLineNumber = "878"
19
+ landmarkName = "-toGetPlayImageIndex::"
20
+ landmarkType = "7">
21
+ </BreakpointContent>
22
+ </BreakpointProxy>
23
+ <BreakpointProxy
24
+ BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
25
+ <BreakpointContent
26
+ uuid = "7640C6F7-1009-4AEB-A9BE-2FEBAA4CABE4"
27
+ shouldBeEnabled = "No"
28
+ ignoreCount = "0"
29
+ continueAfterRunningActions = "No"
30
+ filePath = "../GJLocalDigitalSDK/GJLocalDigitalSDK/GJLDigitalManager.mm"
31
+ startingColumnNumber = "9223372036854775807"
32
+ endingColumnNumber = "9223372036854775807"
33
+ startingLineNumber = "865"
34
+ endingLineNumber = "865"
35
+ landmarkName = "-toPlayNextByRanges"
36
+ landmarkType = "7">
37
+ </BreakpointContent>
38
+ </BreakpointProxy>
39
+ <BreakpointProxy
40
+ BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
41
+ <BreakpointContent
42
+ uuid = "F7510F76-D60C-4102-99DB-FD77C9FD4746"
43
+ shouldBeEnabled = "Yes"
44
+ ignoreCount = "0"
45
+ continueAfterRunningActions = "No"
46
+ filePath = "../GJLocalDigitalSDK/GJLocalDigitalSDK/DIMetalView/DIMetalView.mm"
47
+ startingColumnNumber = "9223372036854775807"
48
+ endingColumnNumber = "9223372036854775807"
49
+ startingLineNumber = "103"
50
+ endingLineNumber = "103"
51
+ landmarkName = "-setupPipeline"
52
+ landmarkType = "7">
53
+ </BreakpointContent>
54
+ </BreakpointProxy>
55
+ <BreakpointProxy
56
+ BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
57
+ <BreakpointContent
58
+ uuid = "F47C960D-8B99-4C02-896B-EB5551198CB3"
59
+ shouldBeEnabled = "No"
60
+ ignoreCount = "0"
61
+ continueAfterRunningActions = "No"
62
+ filePath = "../GJLocalDigitalSDK/GJLocalDigitalSDK/GJLDigitalManager.mm"
63
+ startingColumnNumber = "9223372036854775807"
64
+ endingColumnNumber = "9223372036854775807"
65
+ startingLineNumber = "559"
66
+ endingLineNumber = "559"
67
+ landmarkName = "-toStop"
68
+ landmarkType = "7">
69
+ </BreakpointContent>
70
+ </BreakpointProxy>
71
+ </Breakpoints>
72
+ </Bucket>
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/GJLocalDigitalSDK ADDED
Binary file (71.6 kB). View file
 
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Headers/GJLDigitalManager.h ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // GJLDigitalManager.h
3
+ // GJLocalDigitalSDK
4
+ //
5
+ // Created by guiji on 2023/12/12.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <UIKit/UIKit.h>
10
+
11
+ @interface GJLDigitalManager : NSObject
12
+ //本地数字人模型下的最大帧数
13
+ @property (nonatomic, assign)NSInteger maxCount;
14
+
15
+ + (GJLDigitalManager*)manager;
16
+ /*
17
+ *basePath 底层通用模型路径-保持不变
18
+ *digitalPath 数字人模型路径- 替换数字人只需要替换这个路径
19
+ *return 1 返回成功 -1 基本模型路径错误 -2 基本模型路径错误 -3 数字人模型路径错误 -4 数字人模型路径错误 -5数字人模型配置文件错误
20
+ */
21
+ -(NSInteger)initBaseModel:(NSString*)basePath digitalModel:(NSString*)digitalPath;
22
+ /*
23
+ 显示界面
24
+ */
25
+ -(void)toShow:(UIView*)view;
26
+ /*
27
+ *playImageIndex 播放数字人画面到第几帧
28
+ *audioIndex 播放音频到第几帧
29
+ *bbgPath 数字人背景-可替换
30
+ */
31
+ -(void)toPlayNext:(NSInteger)playImageIndex audioIndex:(NSInteger)audioIndex bbgPath:(NSString*)bbgPath;
32
+ /*
33
+ wavPath 音频的本地路径
34
+ */
35
+ -(void)onewavWithPath:(NSString*)wavPath;
36
+ /*
37
+ 音频播放结束调用
38
+ */
39
+ -(void)toWavPlayEnd;
40
+ /*
41
+ 释放
42
+ */
43
+ -(void)toFree;
44
+ /*
45
+ 初始化模型过后才能获取
46
+ getDigitalSize 数字人模型的宽度 数字人模型的高度
47
+ */
48
+ -(CGSize)getDigitalSize;
49
+ @end
50
+
51
+
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Headers/GJLocalDigitalSDK.h ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // GJLocalDigitalSDK.h
3
+ // GJLocalDigitalSDK
4
+ //
5
+ // Created by guiji on 2023/12/12.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+ //! Project version number for GJLocalDigitalSDK.
11
+ FOUNDATION_EXPORT double GJLocalDigitalSDKVersionNumber;
12
+
13
+ //! Project version string for GJLocalDigitalSDK.
14
+ FOUNDATION_EXPORT const unsigned char GJLocalDigitalSDKVersionString[];
15
+
16
+ // In this header, you should import all the public headers of your framework using statements like #import <GJLocalDigitalSDK/PublicHeader.h>
17
+
18
+ #import <GJLocalDigitalSDK/GJLDigitalManager.h>
19
+
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Info.plist ADDED
Binary file (767 Bytes). View file
 
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Modules/module.modulemap ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ framework module GJLocalDigitalSDK {
2
+ umbrella header "GJLocalDigitalSDK.h"
3
+ export *
4
+
5
+ module * { export * }
6
+ }
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/_CodeSignature/CodeResources ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>files</key>
6
+ <dict>
7
+ <key>Headers/GJLDigitalManager.h</key>
8
+ <data>
9
+ 5uaZHkukbAcZpPsq+CzQtyCQUUE=
10
+ </data>
11
+ <key>Headers/GJLocalDigitalSDK.h</key>
12
+ <data>
13
+ 3rBnLcGNU++wbCXGPIzZGr3dZrs=
14
+ </data>
15
+ <key>Info.plist</key>
16
+ <data>
17
+ Vpt2kAslfkyJxCgTSAZhn7z4BpQ=
18
+ </data>
19
+ <key>Modules/module.modulemap</key>
20
+ <data>
21
+ ypoW1ByUmKNew8insDYa6LlBgks=
22
+ </data>
23
+ </dict>
24
+ <key>files2</key>
25
+ <dict>
26
+ <key>Headers/GJLDigitalManager.h</key>
27
+ <dict>
28
+ <key>hash2</key>
29
+ <data>
30
+ qQWHeaapKyJwJFHjW5RmhNLTpCfUDu+Y0ifCqQ4qTxY=
31
+ </data>
32
+ </dict>
33
+ <key>Headers/GJLocalDigitalSDK.h</key>
34
+ <dict>
35
+ <key>hash2</key>
36
+ <data>
37
+ H/1XlUfF+cVfaXPWADLRF7ypkwcM+3R5XcQy/Iup3mU=
38
+ </data>
39
+ </dict>
40
+ <key>Modules/module.modulemap</key>
41
+ <dict>
42
+ <key>hash2</key>
43
+ <data>
44
+ UQmfiVmcinF15NRuEvyVP1de+1M7FRLzO2cPbsIhj+Y=
45
+ </data>
46
+ </dict>
47
+ </dict>
48
+ <key>rules</key>
49
+ <dict>
50
+ <key>^.*</key>
51
+ <true/>
52
+ <key>^.*\.lproj/</key>
53
+ <dict>
54
+ <key>optional</key>
55
+ <true/>
56
+ <key>weight</key>
57
+ <real>1000</real>
58
+ </dict>
59
+ <key>^.*\.lproj/locversion.plist$</key>
60
+ <dict>
61
+ <key>omit</key>
62
+ <true/>
63
+ <key>weight</key>
64
+ <real>1100</real>
65
+ </dict>
66
+ <key>^Base\.lproj/</key>
67
+ <dict>
68
+ <key>weight</key>
69
+ <real>1010</real>
70
+ </dict>
71
+ <key>^version.plist$</key>
72
+ <true/>
73
+ </dict>
74
+ <key>rules2</key>
75
+ <dict>
76
+ <key>.*\.dSYM($|/)</key>
77
+ <dict>
78
+ <key>weight</key>
79
+ <real>11</real>
80
+ </dict>
81
+ <key>^(.*/)?\.DS_Store$</key>
82
+ <dict>
83
+ <key>omit</key>
84
+ <true/>
85
+ <key>weight</key>
86
+ <real>2000</real>
87
+ </dict>
88
+ <key>^.*</key>
89
+ <true/>
90
+ <key>^.*\.lproj/</key>
91
+ <dict>
92
+ <key>optional</key>
93
+ <true/>
94
+ <key>weight</key>
95
+ <real>1000</real>
96
+ </dict>
97
+ <key>^.*\.lproj/locversion.plist$</key>
98
+ <dict>
99
+ <key>omit</key>
100
+ <true/>
101
+ <key>weight</key>
102
+ <real>1100</real>
103
+ </dict>
104
+ <key>^Base\.lproj/</key>
105
+ <dict>
106
+ <key>weight</key>
107
+ <real>1010</real>
108
+ </dict>
109
+ <key>^Info\.plist$</key>
110
+ <dict>
111
+ <key>omit</key>
112
+ <true/>
113
+ <key>weight</key>
114
+ <real>20</real>
115
+ </dict>
116
+ <key>^PkgInfo$</key>
117
+ <dict>
118
+ <key>omit</key>
119
+ <true/>
120
+ <key>weight</key>
121
+ <real>20</real>
122
+ </dict>
123
+ <key>^embedded\.provisionprofile$</key>
124
+ <dict>
125
+ <key>weight</key>
126
+ <real>20</real>
127
+ </dict>
128
+ <key>^version\.plist$</key>
129
+ <dict>
130
+ <key>weight</key>
131
+ <real>20</real>
132
+ </dict>
133
+ </dict>
134
+ </dict>
135
+ </plist>
GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.md ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## 硅基本地版DUIX SDK使⽤⽂档 (1.0.3)
2
+ ##两个人物模型(切换男女形象,修改./GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo/ViewController.mm的DIGITALMODELURL变量即可)
3
+ ```
4
+ 女:https://cdn.guiji.ai/duix/digital/model/1712034391673/bendi1_0329.zip
5
+ 男:https://digital-public.obs.cn-east-3.myhuaweicloud.com/duix/digital/model/1706009711636/liangwei_540s.zip
6
+ ```
7
+ ### 开发环境
8
+ 开发⼯具: Xcode  ios12.0以上 iphoneX及以上
9
+
10
+ ## 快速开始
11
+ ```
12
+
13
+ NSString *basePath =[NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] bundlePath],@"gj_dh_res"];
14
+ NSString *digitalPath =[NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] bundlePath],@"lixin_a_540s"];
15
+
16
+ //初始化
17
+ NSInteger result= [[GJLDigitalManager manager] initBaseModel:basePath digitalModel:digitalPath showView:weakSelf.showView];
18
+ if(result==1)
19
+ {
20
+ //开始
21
+ [[GJLDigitalManager manager] toStart:^(BOOL isSuccess, NSString *errorMsg) {
22
+ if(!isSuccess)
23
+ {
24
+ [SVProgressHUD showInfoWithStatus:errorMsg];
25
+ }
26
+ }];
27
+ }
28
+
29
+ ```
30
+ ## 调用流程
31
+ ```
32
+ 1. 启动服务前需要准备好同步数字人需要的基础配置和模型文件。
33
+ 2. 初始化数字人渲染服务。
34
+ 3. 调用toStart函数开始渲染数字人
35
+ 4. 调用toSpeakWithPath函数驱动数字人播报。
36
+ 5. 调用cancelAudioPlay函数可以主动停止播报。
37
+ 6. 调用toStop结束并释放数字人渲染
38
+ ```
39
+
40
+ ### SDK回调
41
+
42
+ ```
43
+ /*
44
+ *数字人渲染报错回调
45
+ *0 未授权 -1未初始化 50009资源超时或未配置
46
+ */
47
+ @property (nonatomic, copy) void (^playFailed)(NSInteger code,NSString *errorMsg);
48
+
49
+ /*
50
+ *音频播放结束回调
51
+ */
52
+ @property (nonatomic, copy) void (^audioPlayEnd)(void);
53
+
54
+ /*
55
+ *音频播放进度回调
56
+ /
57
+ @property (nonatomic, copy) void (^audioPlayProgress)(float current,float total);
58
+ ```
59
+
60
+ ## 方法
61
+
62
+ ### 初始化
63
+
64
+ ```
65
+ /*
66
+ *basePath 底层通用模型路径-保持不变
67
+ *digitalPath 数字人模型路径- 替换数字人只需要替换这个路径
68
+ *return 1 返回成功 0未授权 -1 初始化失败
69
+ *showView 显示界面
70
+ */
71
+ -(NSInteger)initBaseModel:(NSString*)basePath digitalModel:(NSString*)digitalPath showView:(UIView*)showView;
72
+ ```
73
+
74
+ ### 替换背景
75
+
76
+ ```
77
+ /*
78
+ * bbgPath 替换背景
79
+ * 注意: -jpg格式 ----背景size等于数字人模型的getDigitalSize-----------
80
+ */
81
+ -(void)toChangeBBGWithPath:(NSString*)bbgPath;
82
+ ```
83
+
84
+ ### 播放音频
85
+
86
+ ```
87
+ /*
88
+ *wavPath 音频的本地路径 
89
+ */
90
+ -(void)toSpeakWithPath:(NSString*)wavPath;
91
+ ```
92
+
93
+ ### 开始渲染数字人
94
+
95
+ ```
96
+ /*
97
+ *开始
98
+ */
99
+ -(void)toStart:(void (^) (BOOL isSuccess, NSString *errorMsg))block;
100
+ ```
101
+
102
+ ### 结束渲染数字人并释放
103
+ ```
104
+ /*
105
+ *结束
106
+ */
107
+ -(void)toStop;
108
+ ```
109
+
110
+ ### 数字人模型的宽度高度
111
+
112
+ ```
113
+ /*
114
+ *初始化模型过后才能获取
115
+ *getDigitalSize 数字人模型的宽度 数字人模型的高度
116
+ */
117
+ -(CGSize)getDigitalSize;
118
+ ```
119
+
120
+ ### 取消播放音频
121
+
122
+ ```
123
+ /*
124
+ *取消播放音频
125
+ */
126
+ -(void)cancelAudioPlay;
127
+ ```
128
+
129
+
130
+
131
+
132
+ ## 动作
133
+
134
+ ### 随机动作
135
+
136
+ ```
137
+ /*
138
+ * 开始动作前调用
139
+ * 随机动作(一段文字包含多个音频,建议第一个音频开始时设置随机动作)
140
+ * return 0 数字人模型不支持随机动作 1 数字人模型支持随机动作
141
+ */
142
+ -(NSInteger)toRandomMotion;
143
+ ```
144
+
145
+ ### 开始动作
146
+
147
+ ```
148
+ /*
149
+ * 开始动作 (一段文字包含多个音频,第一个音频开始时设置)
150
+ * return 0 数字人模型不支持开始动作 1 数字人模型支持开始动作
151
+ */
152
+ -(NSInteger)toStartMotion;
153
+ ```
154
+
155
+ ### 结束动作
156
+ ```
157
+ /*
158
+ * 结束动作 (一段文字包含多个音频,最后一个音频播放结束时设置)
159
+ *isQuickly YES 立即结束动作 NO 等待动作播放完成再静默
160
+ *return 0 数字人模型不支持结束动作 1 数字人模型支持结束动作
161
+ */
162
+ -(NSInteger)toSopMotion:(BOOL)isQuickly;
163
+ ```
164
+
165
+ ### 暂停后开始播放数字人
166
+ ```
167
+ /*
168
+ *暂停后才需执行播放数字人
169
+ */
170
+ -(void)toPlay;
171
+ ```
172
+
173
+ ### 暂停数字人播放
174
+ ```
175
+ /*
176
+ *暂停数字人播放
177
+ */
178
+ -(void)toPause;
179
+ ```
180
+
181
+
GJLocalDigitalDemo/GJLocalDigitalDemo/Podfile ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Uncomment the next line to define a global platform for your project
2
+ # platform :ios, '9.0'
3
+ post_install do |installer|
4
+ installer.generated_projects.each do |project|
5
+ project.targets.each do |target|
6
+ target.build_configurations.each do |config|
7
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
8
+ end
9
+ end
10
+ end
11
+ project_path = "GJLocalDigitalDemo.xcodeproj"
12
+ project = Xcodeproj::Project.open(project_path)
13
+ project.targets.each do |target|
14
+ shell_script_path = "Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-"+target.name+"-frameworks.sh"
15
+ shell_script_input_lines = File.readlines(shell_script_path)
16
+ shell_script_output_lines = shell_script_input_lines.map { |line| line.sub("source=\"$(readlink \"${source}\")\"", "source=\"$(readlink -f \"${source}\")\"") }
17
+ File.open(shell_script_path, 'w') do |f|
18
+ shell_script_output_lines.each do |line|
19
+ f.write line
20
+ end
21
+ end
22
+ end
23
+ end
24
+ target 'GJLocalDigitalDemo' do
25
+ # Comment the next line if you don't want to use dynamic frameworks
26
+ use_frameworks!
27
+ pod 'AFNetworking'
28
+ pod 'SSZipArchive'
29
+ # Pods for GJLocalDigitalDemo
30
+
31
+ end
GJLocalDigitalDemo/GJLocalDigitalDemo/Podfile.lock ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ PODS:
2
+ - AFNetworking (4.0.1):
3
+ - AFNetworking/NSURLSession (= 4.0.1)
4
+ - AFNetworking/Reachability (= 4.0.1)
5
+ - AFNetworking/Security (= 4.0.1)
6
+ - AFNetworking/Serialization (= 4.0.1)
7
+ - AFNetworking/UIKit (= 4.0.1)
8
+ - AFNetworking/NSURLSession (4.0.1):
9
+ - AFNetworking/Reachability
10
+ - AFNetworking/Security
11
+ - AFNetworking/Serialization
12
+ - AFNetworking/Reachability (4.0.1)
13
+ - AFNetworking/Security (4.0.1)
14
+ - AFNetworking/Serialization (4.0.1)
15
+ - AFNetworking/UIKit (4.0.1):
16
+ - AFNetworking/NSURLSession
17
+ - SSZipArchive (2.4.3)
18
+
19
+ DEPENDENCIES:
20
+ - AFNetworking
21
+ - SSZipArchive
22
+
23
+ SPEC REPOS:
24
+ trunk:
25
+ - AFNetworking
26
+ - SSZipArchive
27
+
28
+ SPEC CHECKSUMS:
29
+ AFNetworking: 3bd23d814e976cd148d7d44c3ab78017b744cd58
30
+ SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
31
+
32
+ PODFILE CHECKSUM: 2206843f5bf8d13c4bb6ed97fc38d3ba27152b2e
33
+
34
+ COCOAPODS: 1.14.3
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFCompatibilityMacros.h ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFCompatibilityMacros.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
+ #ifndef AFCompatibilityMacros_h
23
+ #define AFCompatibilityMacros_h
24
+
25
+ #ifdef API_AVAILABLE
26
+ #define AF_API_AVAILABLE(...) API_AVAILABLE(__VA_ARGS__)
27
+ #else
28
+ #define AF_API_AVAILABLE(...)
29
+ #endif // API_AVAILABLE
30
+
31
+ #ifdef API_UNAVAILABLE
32
+ #define AF_API_UNAVAILABLE(...) API_UNAVAILABLE(__VA_ARGS__)
33
+ #else
34
+ #define AF_API_UNAVAILABLE(...)
35
+ #endif // API_UNAVAILABLE
36
+
37
+ #if __has_warning("-Wunguarded-availability-new")
38
+ #define AF_CAN_USE_AT_AVAILABLE 1
39
+ #else
40
+ #define AF_CAN_USE_AT_AVAILABLE 0
41
+ #endif
42
+
43
+ #if ((__IPHONE_OS_VERSION_MAX_ALLOWED && __IPHONE_OS_VERSION_MAX_ALLOWED < 100000) || (__MAC_OS_VERSION_MAX_ALLOWED && __MAC_OS_VERSION_MAX_ALLOWED < 101200) ||(__WATCH_OS_MAX_VERSION_ALLOWED && __WATCH_OS_MAX_VERSION_ALLOWED < 30000) ||(__TV_OS_MAX_VERSION_ALLOWED && __TV_OS_MAX_VERSION_ALLOWED < 100000))
44
+ #define AF_CAN_INCLUDE_SESSION_TASK_METRICS 0
45
+ #else
46
+ #define AF_CAN_INCLUDE_SESSION_TASK_METRICS 1
47
+ #endif
48
+
49
+ #endif /* AFCompatibilityMacros_h */
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFHTTPSessionManager.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 <Foundation/Foundation.h>
23
+ #if !TARGET_OS_WATCH
24
+ #import <SystemConfiguration/SystemConfiguration.h>
25
+ #endif
26
+ #import <TargetConditionals.h>
27
+
28
+ #import "AFURLSessionManager.h"
29
+
30
+ /**
31
+ `AFHTTPSessionManager` is a subclass of `AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths.
32
+
33
+ ## Subclassing Notes
34
+
35
+ Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application.
36
+
37
+ ## Methods to Override
38
+
39
+ To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:`.
40
+
41
+ ## Serialization
42
+
43
+ Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to `<AFURLRequestSerialization>`.
44
+
45
+ Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `<AFURLResponseSerialization>`
46
+
47
+ ## URL Construction Using Relative Paths
48
+
49
+ For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`.
50
+
51
+ Below are a few examples of how `baseURL` and relative paths interact:
52
+
53
+ NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];
54
+ [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo
55
+ [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz
56
+ [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo
57
+ [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo
58
+ [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/
59
+ [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
60
+
61
+ Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash.
62
+
63
+ @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance.
64
+ */
65
+
66
+ NS_ASSUME_NONNULL_BEGIN
67
+
68
+ @interface AFHTTPSessionManager : AFURLSessionManager <NSSecureCoding, NSCopying>
69
+
70
+ /**
71
+ The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods.
72
+ */
73
+ @property (readonly, nonatomic, strong, nullable) NSURL *baseURL;
74
+
75
+ /**
76
+ Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies.
77
+
78
+ @warning `requestSerializer` must not be `nil`.
79
+ */
80
+ @property (nonatomic, strong) AFHTTPRequestSerializer <AFURLRequestSerialization> * requestSerializer;
81
+
82
+ /**
83
+ Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`.
84
+
85
+ @warning `responseSerializer` must not be `nil`.
86
+ */
87
+ @property (nonatomic, strong) AFHTTPResponseSerializer <AFURLResponseSerialization> * responseSerializer;
88
+
89
+ ///-------------------------------
90
+ /// @name Managing Security Policy
91
+ ///-------------------------------
92
+
93
+ /**
94
+ The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified. A security policy configured with `AFSSLPinningModePublicKey` or `AFSSLPinningModeCertificate` can only be applied on a session manager initialized with a secure base URL (i.e. https). Applying a security policy with pinning enabled on an insecure session manager throws an `Invalid Security Policy` exception.
95
+ */
96
+ @property (nonatomic, strong) AFSecurityPolicy *securityPolicy;
97
+
98
+ ///---------------------
99
+ /// @name Initialization
100
+ ///---------------------
101
+
102
+ /**
103
+ Creates and returns an `AFHTTPSessionManager` object.
104
+ */
105
+ + (instancetype)manager;
106
+
107
+ /**
108
+ Initializes an `AFHTTPSessionManager` object with the specified base URL.
109
+
110
+ @param url The base URL for the HTTP client.
111
+
112
+ @return The newly-initialized HTTP client
113
+ */
114
+ - (instancetype)initWithBaseURL:(nullable NSURL *)url;
115
+
116
+ /**
117
+ Initializes an `AFHTTPSessionManager` object with the specified base URL.
118
+
119
+ This is the designated initializer.
120
+
121
+ @param url The base URL for the HTTP client.
122
+ @param configuration The configuration used to create the managed session.
123
+
124
+ @return The newly-initialized HTTP client
125
+ */
126
+ - (instancetype)initWithBaseURL:(nullable NSURL *)url
127
+ sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
128
+
129
+ ///---------------------------
130
+ /// @name Making HTTP Requests
131
+ ///---------------------------
132
+
133
+ /**
134
+ Creates and runs an `NSURLSessionDataTask` with a `GET` request.
135
+
136
+ @param URLString The URL string used to create the request URL.
137
+ @param parameters The parameters to be encoded according to the client request serializer.
138
+ @param headers The headers appended to the default headers for this request.
139
+ @param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
140
+ @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
141
+ @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
142
+
143
+ @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
144
+ */
145
+ - (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
146
+ parameters:(nullable id)parameters
147
+ headers:(nullable NSDictionary <NSString *, NSString *> *)headers
148
+ progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress
149
+ success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
150
+ failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
151
+
152
+ /**
153
+ Creates and runs an `NSURLSessionDataTask` with a `HEAD` request.
154
+
155
+ @param URLString The URL string used to create the request URL.
156
+ @param parameters The parameters to be encoded according to the client request serializer.
157
+ @param headers The headers appended to the default headers for this request.
158
+ @param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task.
159
+ @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
160
+
161
+ @see -dataTaskWithRequest:completionHandler:
162
+ */
163
+ - (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString
164
+ parameters:(nullable id)parameters
165
+ headers:(nullable NSDictionary <NSString *, NSString *> *)headers
166
+ success:(nullable void (^)(NSURLSessionDataTask *task))success
167
+ failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
168
+
169
+ /**
170
+ Creates and runs an `NSURLSessionDataTask` with a `POST` request.
171
+
172
+ @param URLString The URL string used to create the request URL.
173
+ @param parameters The parameters to be encoded according to the client request serializer.
174
+ @param headers The headers appended to the default headers for this request.
175
+ @param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
176
+ @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
177
+ @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
178
+
179
+ @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
180
+ */
181
+ - (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
182
+ parameters:(nullable id)parameters
183
+ headers:(nullable NSDictionary <NSString *, NSString *> *)headers
184
+ progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
185
+ success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
186
+ failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
187
+
188
+ /**
189
+ Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request.
190
+
191
+ @param URLString The URL string used to create the request URL.
192
+ @param parameters The parameters to be encoded according to the client request serializer.
193
+ @param headers The headers appended to the default headers for this request.
194
+ @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol.
195
+ @param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
196
+ @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
197
+ @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
198
+
199
+ @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
200
+ */
201
+ - (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
202
+ parameters:(nullable id)parameters
203
+ headers:(nullable NSDictionary <NSString *, NSString *> *)headers
204
+ constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block
205
+ progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
206
+ success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
207
+ failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
208
+
209
+ /**
210
+ Creates and runs an `NSURLSessionDataTask` with a `PUT` request.
211
+
212
+ @param URLString The URL string used to create the request URL.
213
+ @param parameters The parameters to be encoded according to the client request serializer.
214
+ @param headers The headers appended to the default headers for this request.
215
+ @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
216
+ @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
217
+
218
+ @see -dataTaskWithRequest:completionHandler:
219
+ */
220
+ - (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString
221
+ parameters:(nullable id)parameters
222
+ headers:(nullable NSDictionary <NSString *, NSString *> *)headers
223
+ success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
224
+ failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
225
+
226
+ /**
227
+ Creates and runs an `NSURLSessionDataTask` with a `PATCH` request.
228
+
229
+ @param URLString The URL string used to create the request URL.
230
+ @param parameters The parameters to be encoded according to the client request serializer.
231
+ @param headers The headers appended to the default headers for this request.
232
+ @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
233
+ @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
234
+
235
+ @see -dataTaskWithRequest:completionHandler:
236
+ */
237
+ - (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString
238
+ parameters:(nullable id)parameters
239
+ headers:(nullable NSDictionary <NSString *, NSString *> *)headers
240
+ success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
241
+ failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
242
+
243
+ /**
244
+ Creates and runs an `NSURLSessionDataTask` with a `DELETE` request.
245
+
246
+ @param URLString The URL string used to create the request URL.
247
+ @param parameters The parameters to be encoded according to the client request serializer.
248
+ @param headers The headers appended to the default headers for this request.
249
+ @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
250
+ @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
251
+
252
+ @see -dataTaskWithRequest:completionHandler:
253
+ */
254
+ - (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString
255
+ parameters:(nullable id)parameters
256
+ headers:(nullable NSDictionary <NSString *, NSString *> *)headers
257
+ success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
258
+ failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
259
+
260
+ /**
261
+ Creates an `NSURLSessionDataTask` with a custom `HTTPMethod` request.
262
+
263
+ @param method The HTTPMethod string used to create the request.
264
+ @param URLString The URL string used to create the request URL.
265
+ @param parameters The parameters to be encoded according to the client request serializer.
266
+ @param headers The headers appended to the default headers for this request.
267
+ @param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
268
+ @param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
269
+ @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
270
+ @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
271
+
272
+ @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
273
+ */
274
+ - (nullable NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method
275
+ URLString:(NSString *)URLString
276
+ parameters:(nullable id)parameters
277
+ headers:(nullable NSDictionary <NSString *, NSString *> *)headers
278
+ uploadProgress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
279
+ downloadProgress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress
280
+ success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
281
+ failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
282
+
283
+ @end
284
+
285
+ NS_ASSUME_NONNULL_END
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFHTTPSessionManager.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 "AFHTTPSessionManager.h"
23
+
24
+ #import "AFURLRequestSerialization.h"
25
+ #import "AFURLResponseSerialization.h"
26
+
27
+ #import <Availability.h>
28
+ #import <TargetConditionals.h>
29
+ #import <Security/Security.h>
30
+
31
+ #import <netinet/in.h>
32
+ #import <netinet6/in6.h>
33
+ #import <arpa/inet.h>
34
+ #import <ifaddrs.h>
35
+ #import <netdb.h>
36
+
37
+ #if TARGET_OS_IOS || TARGET_OS_TV
38
+ #import <UIKit/UIKit.h>
39
+ #elif TARGET_OS_WATCH
40
+ #import <WatchKit/WatchKit.h>
41
+ #endif
42
+
43
+ @interface AFHTTPSessionManager ()
44
+ @property (readwrite, nonatomic, strong) NSURL *baseURL;
45
+ @end
46
+
47
+ @implementation AFHTTPSessionManager
48
+ @dynamic responseSerializer;
49
+
50
+ + (instancetype)manager {
51
+ return [[[self class] alloc] initWithBaseURL:nil];
52
+ }
53
+
54
+ - (instancetype)init {
55
+ return [self initWithBaseURL:nil];
56
+ }
57
+
58
+ - (instancetype)initWithBaseURL:(NSURL *)url {
59
+ return [self initWithBaseURL:url sessionConfiguration:nil];
60
+ }
61
+
62
+ - (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration {
63
+ return [self initWithBaseURL:nil sessionConfiguration:configuration];
64
+ }
65
+
66
+ - (instancetype)initWithBaseURL:(NSURL *)url
67
+ sessionConfiguration:(NSURLSessionConfiguration *)configuration
68
+ {
69
+ self = [super initWithSessionConfiguration:configuration];
70
+ if (!self) {
71
+ return nil;
72
+ }
73
+
74
+ // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected
75
+ if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) {
76
+ url = [url URLByAppendingPathComponent:@""];
77
+ }
78
+
79
+ self.baseURL = url;
80
+
81
+ self.requestSerializer = [AFHTTPRequestSerializer serializer];
82
+ self.responseSerializer = [AFJSONResponseSerializer serializer];
83
+
84
+ return self;
85
+ }
86
+
87
+ #pragma mark -
88
+
89
+ - (void)setRequestSerializer:(AFHTTPRequestSerializer <AFURLRequestSerialization> *)requestSerializer {
90
+ NSParameterAssert(requestSerializer);
91
+
92
+ _requestSerializer = requestSerializer;
93
+ }
94
+
95
+ - (void)setResponseSerializer:(AFHTTPResponseSerializer <AFURLResponseSerialization> *)responseSerializer {
96
+ NSParameterAssert(responseSerializer);
97
+
98
+ [super setResponseSerializer:responseSerializer];
99
+ }
100
+
101
+ @dynamic securityPolicy;
102
+
103
+ - (void)setSecurityPolicy:(AFSecurityPolicy *)securityPolicy {
104
+ if (securityPolicy.SSLPinningMode != AFSSLPinningModeNone && ![self.baseURL.scheme isEqualToString:@"https"]) {
105
+ NSString *pinningMode = @"Unknown Pinning Mode";
106
+ switch (securityPolicy.SSLPinningMode) {
107
+ case AFSSLPinningModeNone: pinningMode = @"AFSSLPinningModeNone"; break;
108
+ case AFSSLPinningModeCertificate: pinningMode = @"AFSSLPinningModeCertificate"; break;
109
+ case AFSSLPinningModePublicKey: pinningMode = @"AFSSLPinningModePublicKey"; break;
110
+ }
111
+ NSString *reason = [NSString stringWithFormat:@"A security policy configured with `%@` can only be applied on a manager with a secure base URL (i.e. https)", pinningMode];
112
+ @throw [NSException exceptionWithName:@"Invalid Security Policy" reason:reason userInfo:nil];
113
+ }
114
+
115
+ [super setSecurityPolicy:securityPolicy];
116
+ }
117
+
118
+ #pragma mark -
119
+
120
+ - (NSURLSessionDataTask *)GET:(NSString *)URLString
121
+ parameters:(nullable id)parameters
122
+ headers:(nullable NSDictionary <NSString *, NSString *> *)headers
123
+ progress:(nullable void (^)(NSProgress * _Nonnull))downloadProgress
124
+ success:(nullable void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
125
+ failure:(nullable void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
126
+ {
127
+
128
+ NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"GET"
129
+ URLString:URLString
130
+ parameters:parameters
131
+ headers:headers
132
+ uploadProgress:nil
133
+ downloadProgress:downloadProgress
134
+ success:success
135
+ failure:failure];
136
+
137
+ [dataTask resume];
138
+
139
+ return dataTask;
140
+ }
141
+
142
+ - (NSURLSessionDataTask *)HEAD:(NSString *)URLString
143
+ parameters:(nullable id)parameters
144
+ headers:(nullable NSDictionary<NSString *,NSString *> *)headers
145
+ success:(nullable void (^)(NSURLSessionDataTask * _Nonnull))success
146
+ failure:(nullable void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
147
+ {
148
+ NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters headers:headers uploadProgress:nil downloadProgress:nil success:^(NSURLSessionDataTask *task, __unused id responseObject) {
149
+ if (success) {
150
+ success(task);
151
+ }
152
+ } failure:failure];
153
+
154
+ [dataTask resume];
155
+
156
+ return dataTask;
157
+ }
158
+
159
+ - (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
160
+ parameters:(nullable id)parameters
161
+ headers:(nullable NSDictionary <NSString *, NSString *> *)headers
162
+ progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
163
+ success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
164
+ failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure
165
+ {
166
+ NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters headers:headers uploadProgress:uploadProgress downloadProgress:nil success:success failure:failure];
167
+
168
+ [dataTask resume];
169
+
170
+ return dataTask;
171
+ }
172
+
173
+ - (NSURLSessionDataTask *)POST:(NSString *)URLString
174
+ parameters:(nullable id)parameters
175
+ headers:(nullable NSDictionary<NSString *,NSString *> *)headers
176
+ constructingBodyWithBlock:(nullable void (^)(id<AFMultipartFormData> _Nonnull))block
177
+ progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgress
178
+ success:(nullable void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
179
+ {
180
+ NSError *serializationError = nil;
181
+ NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError];
182
+ for (NSString *headerField in headers.keyEnumerator) {
183
+ [request setValue:headers[headerField] forHTTPHeaderField:headerField];
184
+ }
185
+ if (serializationError) {
186
+ if (failure) {
187
+ dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
188
+ failure(nil, serializationError);
189
+ });
190
+ }
191
+
192
+ return nil;
193
+ }
194
+
195
+ __block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:uploadProgress completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
196
+ if (error) {
197
+ if (failure) {
198
+ failure(task, error);
199
+ }
200
+ } else {
201
+ if (success) {
202
+ success(task, responseObject);
203
+ }
204
+ }
205
+ }];
206
+
207
+ [task resume];
208
+
209
+ return task;
210
+ }
211
+
212
+ - (NSURLSessionDataTask *)PUT:(NSString *)URLString
213
+ parameters:(nullable id)parameters
214
+ headers:(nullable NSDictionary<NSString *,NSString *> *)headers
215
+ success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success
216
+ failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure
217
+ {
218
+ NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters headers:headers uploadProgress:nil downloadProgress:nil success:success failure:failure];
219
+
220
+ [dataTask resume];
221
+
222
+ return dataTask;
223
+ }
224
+
225
+ - (NSURLSessionDataTask *)PATCH:(NSString *)URLString
226
+ parameters:(nullable id)parameters
227
+ headers:(nullable NSDictionary<NSString *,NSString *> *)headers
228
+ success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success
229
+ failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure
230
+ {
231
+ NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters headers:headers uploadProgress:nil downloadProgress:nil success:success failure:failure];
232
+
233
+ [dataTask resume];
234
+
235
+ return dataTask;
236
+ }
237
+
238
+ - (NSURLSessionDataTask *)DELETE:(NSString *)URLString
239
+ parameters:(nullable id)parameters
240
+ headers:(nullable NSDictionary<NSString *,NSString *> *)headers
241
+ success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success
242
+ failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure
243
+ {
244
+ NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters headers:headers uploadProgress:nil downloadProgress:nil success:success failure:failure];
245
+
246
+ [dataTask resume];
247
+
248
+ return dataTask;
249
+ }
250
+
251
+
252
+ - (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method
253
+ URLString:(NSString *)URLString
254
+ parameters:(nullable id)parameters
255
+ headers:(nullable NSDictionary <NSString *, NSString *> *)headers
256
+ uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgress
257
+ downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgress
258
+ success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
259
+ failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure
260
+ {
261
+ NSError *serializationError = nil;
262
+ NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError];
263
+ for (NSString *headerField in headers.keyEnumerator) {
264
+ [request setValue:headers[headerField] forHTTPHeaderField:headerField];
265
+ }
266
+ if (serializationError) {
267
+ if (failure) {
268
+ dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
269
+ failure(nil, serializationError);
270
+ });
271
+ }
272
+
273
+ return nil;
274
+ }
275
+
276
+ __block NSURLSessionDataTask *dataTask = nil;
277
+ dataTask = [self dataTaskWithRequest:request
278
+ uploadProgress:uploadProgress
279
+ downloadProgress:downloadProgress
280
+ completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
281
+ if (error) {
282
+ if (failure) {
283
+ failure(dataTask, error);
284
+ }
285
+ } else {
286
+ if (success) {
287
+ success(dataTask, responseObject);
288
+ }
289
+ }
290
+ }];
291
+
292
+ return dataTask;
293
+ }
294
+
295
+ #pragma mark - NSObject
296
+
297
+ - (NSString *)description {
298
+ return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue];
299
+ }
300
+
301
+ #pragma mark - NSSecureCoding
302
+
303
+ + (BOOL)supportsSecureCoding {
304
+ return YES;
305
+ }
306
+
307
+ - (instancetype)initWithCoder:(NSCoder *)decoder {
308
+ NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))];
309
+ NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"];
310
+ if (!configuration) {
311
+ NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"];
312
+ if (configurationIdentifier) {
313
+ configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier];
314
+ }
315
+ }
316
+
317
+ self = [self initWithBaseURL:baseURL sessionConfiguration:configuration];
318
+ if (!self) {
319
+ return nil;
320
+ }
321
+
322
+ self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))];
323
+ self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))];
324
+ AFSecurityPolicy *decodedPolicy = [decoder decodeObjectOfClass:[AFSecurityPolicy class] forKey:NSStringFromSelector(@selector(securityPolicy))];
325
+ if (decodedPolicy) {
326
+ self.securityPolicy = decodedPolicy;
327
+ }
328
+
329
+ return self;
330
+ }
331
+
332
+ - (void)encodeWithCoder:(NSCoder *)coder {
333
+ [super encodeWithCoder:coder];
334
+
335
+ [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))];
336
+ if ([self.session.configuration conformsToProtocol:@protocol(NSCoding)]) {
337
+ [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"];
338
+ } else {
339
+ [coder encodeObject:self.session.configuration.identifier forKey:@"identifier"];
340
+ }
341
+ [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))];
342
+ [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))];
343
+ [coder encodeObject:self.securityPolicy forKey:NSStringFromSelector(@selector(securityPolicy))];
344
+ }
345
+
346
+ #pragma mark - NSCopying
347
+
348
+ - (instancetype)copyWithZone:(NSZone *)zone {
349
+ AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration];
350
+
351
+ HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone];
352
+ HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone];
353
+ HTTPClient.securityPolicy = [self.securityPolicy copyWithZone:zone];
354
+ return HTTPClient;
355
+ }
356
+
357
+ @end
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFNetworkReachabilityManager.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 <Foundation/Foundation.h>
23
+
24
+ #if !TARGET_OS_WATCH
25
+ #import <SystemConfiguration/SystemConfiguration.h>
26
+
27
+ typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) {
28
+ AFNetworkReachabilityStatusUnknown = -1,
29
+ AFNetworkReachabilityStatusNotReachable = 0,
30
+ AFNetworkReachabilityStatusReachableViaWWAN = 1,
31
+ AFNetworkReachabilityStatusReachableViaWiFi = 2,
32
+ };
33
+
34
+ NS_ASSUME_NONNULL_BEGIN
35
+
36
+ /**
37
+ `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
38
+
39
+ Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability.
40
+
41
+ See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ )
42
+
43
+ @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined.
44
+ */
45
+ @interface AFNetworkReachabilityManager : NSObject
46
+
47
+ /**
48
+ The current network reachability status.
49
+ */
50
+ @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
51
+
52
+ /**
53
+ Whether or not the network is currently reachable.
54
+ */
55
+ @property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable;
56
+
57
+ /**
58
+ Whether or not the network is currently reachable via WWAN.
59
+ */
60
+ @property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN;
61
+
62
+ /**
63
+ Whether or not the network is currently reachable via WiFi.
64
+ */
65
+ @property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi;
66
+
67
+ ///---------------------
68
+ /// @name Initialization
69
+ ///---------------------
70
+
71
+ /**
72
+ Returns the shared network reachability manager.
73
+ */
74
+ + (instancetype)sharedManager;
75
+
76
+ /**
77
+ Creates and returns a network reachability manager with the default socket address.
78
+
79
+ @return An initialized network reachability manager, actively monitoring the default socket address.
80
+ */
81
+ + (instancetype)manager;
82
+
83
+ /**
84
+ Creates and returns a network reachability manager for the specified domain.
85
+
86
+ @param domain The domain used to evaluate network reachability.
87
+
88
+ @return An initialized network reachability manager, actively monitoring the specified domain.
89
+ */
90
+ + (instancetype)managerForDomain:(NSString *)domain;
91
+
92
+ /**
93
+ Creates and returns a network reachability manager for the socket address.
94
+
95
+ @param address The socket address (`sockaddr_in6`) used to evaluate network reachability.
96
+
97
+ @return An initialized network reachability manager, actively monitoring the specified socket address.
98
+ */
99
+ + (instancetype)managerForAddress:(const void *)address;
100
+
101
+ /**
102
+ Initializes an instance of a network reachability manager from the specified reachability object.
103
+
104
+ @param reachability The reachability object to monitor.
105
+
106
+ @return An initialized network reachability manager, actively monitoring the specified reachability.
107
+ */
108
+ - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER;
109
+
110
+ /**
111
+ * Unavailable initializer
112
+ */
113
+ + (instancetype)new NS_UNAVAILABLE;
114
+
115
+ /**
116
+ * Unavailable initializer
117
+ */
118
+ - (instancetype)init NS_UNAVAILABLE;
119
+
120
+ ///--------------------------------------------------
121
+ /// @name Starting & Stopping Reachability Monitoring
122
+ ///--------------------------------------------------
123
+
124
+ /**
125
+ Starts monitoring for changes in network reachability status.
126
+ */
127
+ - (void)startMonitoring;
128
+
129
+ /**
130
+ Stops monitoring for changes in network reachability status.
131
+ */
132
+ - (void)stopMonitoring;
133
+
134
+ ///-------------------------------------------------
135
+ /// @name Getting Localized Reachability Description
136
+ ///-------------------------------------------------
137
+
138
+ /**
139
+ Returns a localized string representation of the current network reachability status.
140
+ */
141
+ - (NSString *)localizedNetworkReachabilityStatusString;
142
+
143
+ ///---------------------------------------------------
144
+ /// @name Setting Network Reachability Change Callback
145
+ ///---------------------------------------------------
146
+
147
+ /**
148
+ Sets a callback to be executed when the network availability of the `baseURL` host changes.
149
+
150
+ @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
151
+ */
152
+ - (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block;
153
+
154
+ @end
155
+
156
+ ///----------------
157
+ /// @name Constants
158
+ ///----------------
159
+
160
+ /**
161
+ ## Network Reachability
162
+
163
+ The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses.
164
+
165
+ enum {
166
+ AFNetworkReachabilityStatusUnknown,
167
+ AFNetworkReachabilityStatusNotReachable,
168
+ AFNetworkReachabilityStatusReachableViaWWAN,
169
+ AFNetworkReachabilityStatusReachableViaWiFi,
170
+ }
171
+
172
+ `AFNetworkReachabilityStatusUnknown`
173
+ The `baseURL` host reachability is not known.
174
+
175
+ `AFNetworkReachabilityStatusNotReachable`
176
+ The `baseURL` host cannot be reached.
177
+
178
+ `AFNetworkReachabilityStatusReachableViaWWAN`
179
+ The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
180
+
181
+ `AFNetworkReachabilityStatusReachableViaWiFi`
182
+ The `baseURL` host can be reached via a Wi-Fi connection.
183
+
184
+ ### Keys for Notification UserInfo Dictionary
185
+
186
+ Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
187
+
188
+ `AFNetworkingReachabilityNotificationStatusItem`
189
+ A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
190
+ The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
191
+ */
192
+
193
+ ///--------------------
194
+ /// @name Notifications
195
+ ///--------------------
196
+
197
+ /**
198
+ Posted when network reachability changes.
199
+ This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
200
+
201
+ @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
202
+ */
203
+ FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification;
204
+ FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem;
205
+
206
+ ///--------------------
207
+ /// @name Functions
208
+ ///--------------------
209
+
210
+ /**
211
+ Returns a localized string representation of an `AFNetworkReachabilityStatus` value.
212
+ */
213
+ FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status);
214
+
215
+ NS_ASSUME_NONNULL_END
216
+ #endif
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFNetworkReachabilityManager.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 "AFNetworkReachabilityManager.h"
23
+ #if !TARGET_OS_WATCH
24
+
25
+ #import <netinet/in.h>
26
+ #import <netinet6/in6.h>
27
+ #import <arpa/inet.h>
28
+ #import <ifaddrs.h>
29
+ #import <netdb.h>
30
+
31
+ NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change";
32
+ NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem";
33
+
34
+ typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status);
35
+ typedef AFNetworkReachabilityManager * (^AFNetworkReachabilityStatusCallback)(AFNetworkReachabilityStatus status);
36
+
37
+ NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) {
38
+ switch (status) {
39
+ case AFNetworkReachabilityStatusNotReachable:
40
+ return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil);
41
+ case AFNetworkReachabilityStatusReachableViaWWAN:
42
+ return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil);
43
+ case AFNetworkReachabilityStatusReachableViaWiFi:
44
+ return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil);
45
+ case AFNetworkReachabilityStatusUnknown:
46
+ default:
47
+ return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil);
48
+ }
49
+ }
50
+
51
+ static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) {
52
+ BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0);
53
+ BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0);
54
+ BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0));
55
+ BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0);
56
+ BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction));
57
+
58
+ AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown;
59
+ if (isNetworkReachable == NO) {
60
+ status = AFNetworkReachabilityStatusNotReachable;
61
+ }
62
+ #if TARGET_OS_IPHONE
63
+ else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) {
64
+ status = AFNetworkReachabilityStatusReachableViaWWAN;
65
+ }
66
+ #endif
67
+ else {
68
+ status = AFNetworkReachabilityStatusReachableViaWiFi;
69
+ }
70
+
71
+ return status;
72
+ }
73
+
74
+ /**
75
+ * Queue a status change notification for the main thread.
76
+ *
77
+ * This is done to ensure that the notifications are received in the same order
78
+ * as they are sent. If notifications are sent directly, it is possible that
79
+ * a queued notification (for an earlier status condition) is processed after
80
+ * the later update, resulting in the listener being left in the wrong state.
81
+ */
82
+ static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusCallback block) {
83
+ AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags);
84
+ dispatch_async(dispatch_get_main_queue(), ^{
85
+ AFNetworkReachabilityManager *manager = nil;
86
+ if (block) {
87
+ manager = block(status);
88
+ }
89
+ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
90
+ NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) };
91
+ [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:manager userInfo:userInfo];
92
+ });
93
+ }
94
+
95
+ static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) {
96
+ AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusCallback)info);
97
+ }
98
+
99
+
100
+ static const void * AFNetworkReachabilityRetainCallback(const void *info) {
101
+ return Block_copy(info);
102
+ }
103
+
104
+ static void AFNetworkReachabilityReleaseCallback(const void *info) {
105
+ if (info) {
106
+ Block_release(info);
107
+ }
108
+ }
109
+
110
+ @interface AFNetworkReachabilityManager ()
111
+ @property (readonly, nonatomic, assign) SCNetworkReachabilityRef networkReachability;
112
+ @property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
113
+ @property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock;
114
+ @end
115
+
116
+ @implementation AFNetworkReachabilityManager
117
+
118
+ + (instancetype)sharedManager {
119
+ static AFNetworkReachabilityManager *_sharedManager = nil;
120
+ static dispatch_once_t onceToken;
121
+ dispatch_once(&onceToken, ^{
122
+ _sharedManager = [self manager];
123
+ });
124
+
125
+ return _sharedManager;
126
+ }
127
+
128
+ + (instancetype)managerForDomain:(NSString *)domain {
129
+ SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]);
130
+
131
+ AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
132
+
133
+ CFRelease(reachability);
134
+
135
+ return manager;
136
+ }
137
+
138
+ + (instancetype)managerForAddress:(const void *)address {
139
+ SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address);
140
+ AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
141
+
142
+ CFRelease(reachability);
143
+
144
+ return manager;
145
+ }
146
+
147
+ + (instancetype)manager
148
+ {
149
+ #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
150
+ struct sockaddr_in6 address;
151
+ bzero(&address, sizeof(address));
152
+ address.sin6_len = sizeof(address);
153
+ address.sin6_family = AF_INET6;
154
+ #else
155
+ struct sockaddr_in address;
156
+ bzero(&address, sizeof(address));
157
+ address.sin_len = sizeof(address);
158
+ address.sin_family = AF_INET;
159
+ #endif
160
+ return [self managerForAddress:&address];
161
+ }
162
+
163
+ - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability {
164
+ self = [super init];
165
+ if (!self) {
166
+ return nil;
167
+ }
168
+
169
+ _networkReachability = CFRetain(reachability);
170
+ self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown;
171
+
172
+ return self;
173
+ }
174
+
175
+ - (instancetype)init
176
+ {
177
+ @throw [NSException exceptionWithName:NSGenericException
178
+ reason:@"`-init` unavailable. Use `-initWithReachability:` instead"
179
+ userInfo:nil];
180
+ return nil;
181
+ }
182
+
183
+ - (void)dealloc {
184
+ [self stopMonitoring];
185
+
186
+ if (_networkReachability != NULL) {
187
+ CFRelease(_networkReachability);
188
+ }
189
+ }
190
+
191
+ #pragma mark -
192
+
193
+ - (BOOL)isReachable {
194
+ return [self isReachableViaWWAN] || [self isReachableViaWiFi];
195
+ }
196
+
197
+ - (BOOL)isReachableViaWWAN {
198
+ return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN;
199
+ }
200
+
201
+ - (BOOL)isReachableViaWiFi {
202
+ return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi;
203
+ }
204
+
205
+ #pragma mark -
206
+
207
+ - (void)startMonitoring {
208
+ [self stopMonitoring];
209
+
210
+ if (!self.networkReachability) {
211
+ return;
212
+ }
213
+
214
+ __weak __typeof(self)weakSelf = self;
215
+ AFNetworkReachabilityStatusCallback callback = ^(AFNetworkReachabilityStatus status) {
216
+ __strong __typeof(weakSelf)strongSelf = weakSelf;
217
+
218
+ strongSelf.networkReachabilityStatus = status;
219
+ if (strongSelf.networkReachabilityStatusBlock) {
220
+ strongSelf.networkReachabilityStatusBlock(status);
221
+ }
222
+
223
+ return strongSelf;
224
+ };
225
+
226
+ SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL};
227
+ SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context);
228
+ SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
229
+
230
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{
231
+ SCNetworkReachabilityFlags flags;
232
+ if (SCNetworkReachabilityGetFlags(self.networkReachability, &flags)) {
233
+ AFPostReachabilityStatusChange(flags, callback);
234
+ }
235
+ });
236
+ }
237
+
238
+ - (void)stopMonitoring {
239
+ if (!self.networkReachability) {
240
+ return;
241
+ }
242
+
243
+ SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
244
+ }
245
+
246
+ #pragma mark -
247
+
248
+ - (NSString *)localizedNetworkReachabilityStatusString {
249
+ return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus);
250
+ }
251
+
252
+ #pragma mark -
253
+
254
+ - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block {
255
+ self.networkReachabilityStatusBlock = block;
256
+ }
257
+
258
+ #pragma mark - NSKeyValueObserving
259
+
260
+ + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
261
+ if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) {
262
+ return [NSSet setWithObject:@"networkReachabilityStatus"];
263
+ }
264
+
265
+ return [super keyPathsForValuesAffectingValueForKey:key];
266
+ }
267
+
268
+ @end
269
+ #endif
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworking.h ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 <Foundation/Foundation.h>
24
+ #import <Availability.h>
25
+ #import <TargetConditionals.h>
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_ */
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFSecurityPolicy.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 <Foundation/Foundation.h>
23
+ #import <Security/Security.h>
24
+
25
+ typedef NS_ENUM(NSUInteger, AFSSLPinningMode) {
26
+ AFSSLPinningModeNone,
27
+ AFSSLPinningModePublicKey,
28
+ AFSSLPinningModeCertificate,
29
+ };
30
+
31
+ /**
32
+ `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections.
33
+
34
+ Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled.
35
+ */
36
+
37
+ NS_ASSUME_NONNULL_BEGIN
38
+
39
+ @interface AFSecurityPolicy : NSObject <NSSecureCoding, NSCopying>
40
+
41
+ /**
42
+ The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`.
43
+ */
44
+ @property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
45
+
46
+ /**
47
+ The certificates used to evaluate server trust according to the SSL pinning mode.
48
+
49
+ Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches.
50
+
51
+ @see policyWithPinningMode:withPinnedCertificates:
52
+ */
53
+ @property (nonatomic, strong, nullable) NSSet <NSData *> *pinnedCertificates;
54
+
55
+ /**
56
+ Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`.
57
+ */
58
+ @property (nonatomic, assign) BOOL allowInvalidCertificates;
59
+
60
+ /**
61
+ Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`.
62
+ */
63
+ @property (nonatomic, assign) BOOL validatesDomainName;
64
+
65
+ ///-----------------------------------------
66
+ /// @name Getting Certificates from the Bundle
67
+ ///-----------------------------------------
68
+
69
+ /**
70
+ Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`.
71
+
72
+ @return The certificates included in the given bundle.
73
+ */
74
+ + (NSSet <NSData *> *)certificatesInBundle:(NSBundle *)bundle;
75
+
76
+ ///-----------------------------------------
77
+ /// @name Getting Specific Security Policies
78
+ ///-----------------------------------------
79
+
80
+ /**
81
+ Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys.
82
+
83
+ @return The default security policy.
84
+ */
85
+ + (instancetype)defaultPolicy;
86
+
87
+ ///---------------------
88
+ /// @name Initialization
89
+ ///---------------------
90
+
91
+ /**
92
+ Creates and returns a security policy with the specified pinning mode.
93
+
94
+ Certificates with the `.cer` extension found in the main bundle will be pinned. If you want more control over which certificates are pinned, please use `policyWithPinningMode:withPinnedCertificates:` instead.
95
+
96
+ @param pinningMode The SSL pinning mode.
97
+
98
+ @return A new security policy.
99
+
100
+ @see -policyWithPinningMode:withPinnedCertificates:
101
+ */
102
+ + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode;
103
+
104
+ /**
105
+ Creates and returns a security policy with the specified pinning mode.
106
+
107
+ @param pinningMode The SSL pinning mode.
108
+ @param pinnedCertificates The certificates to pin against.
109
+
110
+ @return A new security policy.
111
+
112
+ @see +certificatesInBundle:
113
+ @see -pinnedCertificates
114
+ */
115
+ + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet <NSData *> *)pinnedCertificates;
116
+
117
+ ///------------------------------
118
+ /// @name Evaluating Server Trust
119
+ ///------------------------------
120
+
121
+ /**
122
+ Whether or not the specified server trust should be accepted, based on the security policy.
123
+
124
+ This method should be used when responding to an authentication challenge from a server.
125
+
126
+ @param serverTrust The X.509 certificate trust of the server.
127
+ @param domain The domain of serverTrust. If `nil`, the domain will not be validated.
128
+
129
+ @return Whether or not to trust the server.
130
+ */
131
+ - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
132
+ forDomain:(nullable NSString *)domain;
133
+
134
+ @end
135
+
136
+ NS_ASSUME_NONNULL_END
137
+
138
+ ///----------------
139
+ /// @name Constants
140
+ ///----------------
141
+
142
+ /**
143
+ ## SSL Pinning Modes
144
+
145
+ The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes.
146
+
147
+ enum {
148
+ AFSSLPinningModeNone,
149
+ AFSSLPinningModePublicKey,
150
+ AFSSLPinningModeCertificate,
151
+ }
152
+
153
+ `AFSSLPinningModeNone`
154
+ Do not used pinned certificates to validate servers.
155
+
156
+ `AFSSLPinningModePublicKey`
157
+ Validate host certificates against public keys of pinned certificates.
158
+
159
+ `AFSSLPinningModeCertificate`
160
+ Validate host certificates against pinned certificates.
161
+ */
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFSecurityPolicy.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 "AFSecurityPolicy.h"
23
+
24
+ #import <AssertMacros.h>
25
+
26
+ #if !TARGET_OS_IOS && !TARGET_OS_WATCH && !TARGET_OS_TV
27
+ static NSData * AFSecKeyGetData(SecKeyRef key) {
28
+ CFDataRef data = NULL;
29
+
30
+ __Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out);
31
+
32
+ return (__bridge_transfer NSData *)data;
33
+
34
+ _out:
35
+ if (data) {
36
+ CFRelease(data);
37
+ }
38
+
39
+ return nil;
40
+ }
41
+ #endif
42
+
43
+ static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) {
44
+ #if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
45
+ return [(__bridge id)key1 isEqual:(__bridge id)key2];
46
+ #else
47
+ return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)];
48
+ #endif
49
+ }
50
+
51
+ static id AFPublicKeyForCertificate(NSData *certificate) {
52
+ id allowedPublicKey = nil;
53
+ SecCertificateRef allowedCertificate;
54
+ SecPolicyRef policy = nil;
55
+ SecTrustRef allowedTrust = nil;
56
+ SecTrustResultType result;
57
+
58
+ allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate);
59
+ __Require_Quiet(allowedCertificate != NULL, _out);
60
+
61
+ policy = SecPolicyCreateBasicX509();
62
+ __Require_noErr_Quiet(SecTrustCreateWithCertificates(allowedCertificate, policy, &allowedTrust), _out);
63
+ #pragma clang diagnostic push
64
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
65
+ __Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out);
66
+ #pragma clang diagnostic pop
67
+
68
+ allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust);
69
+
70
+ _out:
71
+ if (allowedTrust) {
72
+ CFRelease(allowedTrust);
73
+ }
74
+
75
+ if (policy) {
76
+ CFRelease(policy);
77
+ }
78
+
79
+ if (allowedCertificate) {
80
+ CFRelease(allowedCertificate);
81
+ }
82
+
83
+ return allowedPublicKey;
84
+ }
85
+
86
+ static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) {
87
+ BOOL isValid = NO;
88
+ SecTrustResultType result;
89
+ #pragma clang diagnostic push
90
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
91
+ __Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out);
92
+ #pragma clang diagnostic pop
93
+
94
+ isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed);
95
+
96
+ _out:
97
+ return isValid;
98
+ }
99
+
100
+ static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) {
101
+ CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);
102
+ NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount];
103
+
104
+ for (CFIndex i = 0; i < certificateCount; i++) {
105
+ SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);
106
+ [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)];
107
+ }
108
+
109
+ return [NSArray arrayWithArray:trustChain];
110
+ }
111
+
112
+ static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
113
+ SecPolicyRef policy = SecPolicyCreateBasicX509();
114
+ CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);
115
+ NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount];
116
+ for (CFIndex i = 0; i < certificateCount; i++) {
117
+ SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);
118
+
119
+ SecCertificateRef someCertificates[] = {certificate};
120
+ CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL);
121
+
122
+ SecTrustRef trust;
123
+ __Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out);
124
+ SecTrustResultType result;
125
+ #pragma clang diagnostic push
126
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
127
+ __Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out);
128
+ #pragma clang diagnostic pop
129
+ [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)];
130
+
131
+ _out:
132
+ if (trust) {
133
+ CFRelease(trust);
134
+ }
135
+
136
+ if (certificates) {
137
+ CFRelease(certificates);
138
+ }
139
+
140
+ continue;
141
+ }
142
+ CFRelease(policy);
143
+
144
+ return [NSArray arrayWithArray:trustChain];
145
+ }
146
+
147
+ #pragma mark -
148
+
149
+ @interface AFSecurityPolicy()
150
+ @property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
151
+ @property (readwrite, nonatomic, strong) NSSet *pinnedPublicKeys;
152
+ @end
153
+
154
+ @implementation AFSecurityPolicy
155
+
156
+ + (NSSet *)certificatesInBundle:(NSBundle *)bundle {
157
+ NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."];
158
+
159
+ NSMutableSet *certificates = [NSMutableSet setWithCapacity:[paths count]];
160
+ for (NSString *path in paths) {
161
+ NSData *certificateData = [NSData dataWithContentsOfFile:path];
162
+ [certificates addObject:certificateData];
163
+ }
164
+
165
+ return [NSSet setWithSet:certificates];
166
+ }
167
+
168
+ + (instancetype)defaultPolicy {
169
+ AFSecurityPolicy *securityPolicy = [[self alloc] init];
170
+ securityPolicy.SSLPinningMode = AFSSLPinningModeNone;
171
+
172
+ return securityPolicy;
173
+ }
174
+
175
+ + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode {
176
+ NSSet <NSData *> *defaultPinnedCertificates = [self certificatesInBundle:[NSBundle mainBundle]];
177
+ return [self policyWithPinningMode:pinningMode withPinnedCertificates:defaultPinnedCertificates];
178
+ }
179
+
180
+ + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates {
181
+ AFSecurityPolicy *securityPolicy = [[self alloc] init];
182
+ securityPolicy.SSLPinningMode = pinningMode;
183
+
184
+ [securityPolicy setPinnedCertificates:pinnedCertificates];
185
+
186
+ return securityPolicy;
187
+ }
188
+
189
+ - (instancetype)init {
190
+ self = [super init];
191
+ if (!self) {
192
+ return nil;
193
+ }
194
+
195
+ self.validatesDomainName = YES;
196
+
197
+ return self;
198
+ }
199
+
200
+ - (void)setPinnedCertificates:(NSSet *)pinnedCertificates {
201
+ _pinnedCertificates = pinnedCertificates;
202
+
203
+ if (self.pinnedCertificates) {
204
+ NSMutableSet *mutablePinnedPublicKeys = [NSMutableSet setWithCapacity:[self.pinnedCertificates count]];
205
+ for (NSData *certificate in self.pinnedCertificates) {
206
+ id publicKey = AFPublicKeyForCertificate(certificate);
207
+ if (!publicKey) {
208
+ continue;
209
+ }
210
+ [mutablePinnedPublicKeys addObject:publicKey];
211
+ }
212
+ self.pinnedPublicKeys = [NSSet setWithSet:mutablePinnedPublicKeys];
213
+ } else {
214
+ self.pinnedPublicKeys = nil;
215
+ }
216
+ }
217
+
218
+ #pragma mark -
219
+
220
+ - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
221
+ forDomain:(NSString *)domain
222
+ {
223
+ if (domain && self.allowInvalidCertificates && self.validatesDomainName && (self.SSLPinningMode == AFSSLPinningModeNone || [self.pinnedCertificates count] == 0)) {
224
+ // https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html
225
+ // According to the docs, you should only trust your provided certs for evaluation.
226
+ // Pinned certificates are added to the trust. Without pinned certificates,
227
+ // there is nothing to evaluate against.
228
+ //
229
+ // From Apple Docs:
230
+ // "Do not implicitly trust self-signed certificates as anchors (kSecTrustOptionImplicitAnchors).
231
+ // Instead, add your own (self-signed) CA certificate to the list of trusted anchors."
232
+ NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning.");
233
+ return NO;
234
+ }
235
+
236
+ NSMutableArray *policies = [NSMutableArray array];
237
+ if (self.validatesDomainName) {
238
+ [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)];
239
+ } else {
240
+ [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()];
241
+ }
242
+
243
+ SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies);
244
+
245
+ if (self.SSLPinningMode == AFSSLPinningModeNone) {
246
+ return self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust);
247
+ } else if (!self.allowInvalidCertificates && !AFServerTrustIsValid(serverTrust)) {
248
+ return NO;
249
+ }
250
+
251
+ switch (self.SSLPinningMode) {
252
+ case AFSSLPinningModeCertificate: {
253
+ NSMutableArray *pinnedCertificates = [NSMutableArray array];
254
+ for (NSData *certificateData in self.pinnedCertificates) {
255
+ [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)];
256
+ }
257
+ SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates);
258
+
259
+ if (!AFServerTrustIsValid(serverTrust)) {
260
+ return NO;
261
+ }
262
+
263
+ // obtain the chain after being validated, which *should* contain the pinned certificate in the last position (if it's the Root CA)
264
+ NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust);
265
+
266
+ for (NSData *trustChainCertificate in [serverCertificates reverseObjectEnumerator]) {
267
+ if ([self.pinnedCertificates containsObject:trustChainCertificate]) {
268
+ return YES;
269
+ }
270
+ }
271
+
272
+ return NO;
273
+ }
274
+ case AFSSLPinningModePublicKey: {
275
+ NSUInteger trustedPublicKeyCount = 0;
276
+ NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust);
277
+
278
+ for (id trustChainPublicKey in publicKeys) {
279
+ for (id pinnedPublicKey in self.pinnedPublicKeys) {
280
+ if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) {
281
+ trustedPublicKeyCount += 1;
282
+ }
283
+ }
284
+ }
285
+ return trustedPublicKeyCount > 0;
286
+ }
287
+
288
+ default:
289
+ return NO;
290
+ }
291
+
292
+ return NO;
293
+ }
294
+
295
+ #pragma mark - NSKeyValueObserving
296
+
297
+ + (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys {
298
+ return [NSSet setWithObject:@"pinnedCertificates"];
299
+ }
300
+
301
+ #pragma mark - NSSecureCoding
302
+
303
+ + (BOOL)supportsSecureCoding {
304
+ return YES;
305
+ }
306
+
307
+ - (instancetype)initWithCoder:(NSCoder *)decoder {
308
+
309
+ self = [self init];
310
+ if (!self) {
311
+ return nil;
312
+ }
313
+
314
+ self.SSLPinningMode = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(SSLPinningMode))] unsignedIntegerValue];
315
+ self.allowInvalidCertificates = [decoder decodeBoolForKey:NSStringFromSelector(@selector(allowInvalidCertificates))];
316
+ self.validatesDomainName = [decoder decodeBoolForKey:NSStringFromSelector(@selector(validatesDomainName))];
317
+ self.pinnedCertificates = [decoder decodeObjectOfClass:[NSSet class] forKey:NSStringFromSelector(@selector(pinnedCertificates))];
318
+
319
+ return self;
320
+ }
321
+
322
+ - (void)encodeWithCoder:(NSCoder *)coder {
323
+ [coder encodeObject:[NSNumber numberWithUnsignedInteger:self.SSLPinningMode] forKey:NSStringFromSelector(@selector(SSLPinningMode))];
324
+ [coder encodeBool:self.allowInvalidCertificates forKey:NSStringFromSelector(@selector(allowInvalidCertificates))];
325
+ [coder encodeBool:self.validatesDomainName forKey:NSStringFromSelector(@selector(validatesDomainName))];
326
+ [coder encodeObject:self.pinnedCertificates forKey:NSStringFromSelector(@selector(pinnedCertificates))];
327
+ }
328
+
329
+ #pragma mark - NSCopying
330
+
331
+ - (instancetype)copyWithZone:(NSZone *)zone {
332
+ AFSecurityPolicy *securityPolicy = [[[self class] allocWithZone:zone] init];
333
+ securityPolicy.SSLPinningMode = self.SSLPinningMode;
334
+ securityPolicy.allowInvalidCertificates = self.allowInvalidCertificates;
335
+ securityPolicy.validatesDomainName = self.validatesDomainName;
336
+ securityPolicy.pinnedCertificates = [self.pinnedCertificates copyWithZone:zone];
337
+
338
+ return securityPolicy;
339
+ }
340
+
341
+ @end
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h ADDED
@@ -0,0 +1,479 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFURLRequestSerialization.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 <Foundation/Foundation.h>
23
+ #import <TargetConditionals.h>
24
+
25
+ #if TARGET_OS_IOS || TARGET_OS_TV
26
+ #import <UIKit/UIKit.h>
27
+ #elif TARGET_OS_WATCH
28
+ #import <WatchKit/WatchKit.h>
29
+ #endif
30
+
31
+ NS_ASSUME_NONNULL_BEGIN
32
+
33
+ /**
34
+ Returns a percent-escaped string following RFC 3986 for a query string key or value.
35
+ RFC 3986 states that the following characters are "reserved" characters.
36
+ - General Delimiters: ":", "#", "[", "]", "@", "?", "/"
37
+ - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="
38
+
39
+ In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow
40
+ query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/"
41
+ should be percent-escaped in the query string.
42
+
43
+ @param string The string to be percent-escaped.
44
+
45
+ @return The percent-escaped string.
46
+ */
47
+ FOUNDATION_EXPORT NSString * AFPercentEscapedStringFromString(NSString *string);
48
+
49
+ /**
50
+ A helper method to generate encoded url query parameters for appending to the end of a URL.
51
+
52
+ @param parameters A dictionary of key/values to be encoded.
53
+
54
+ @return A url encoded query string
55
+ */
56
+ FOUNDATION_EXPORT NSString * AFQueryStringFromParameters(NSDictionary *parameters);
57
+
58
+ /**
59
+ The `AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary.
60
+
61
+ For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`.
62
+ */
63
+ @protocol AFURLRequestSerialization <NSObject, NSSecureCoding, NSCopying>
64
+
65
+ /**
66
+ Returns a request with the specified parameters encoded into a copy of the original request.
67
+
68
+ @param request The original request.
69
+ @param parameters The parameters to be encoded.
70
+ @param error The error that occurred while attempting to encode the request parameters.
71
+
72
+ @return A serialized request.
73
+ */
74
+ - (nullable NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
75
+ withParameters:(nullable id)parameters
76
+ error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW;
77
+
78
+ @end
79
+
80
+ #pragma mark -
81
+
82
+ /**
83
+
84
+ */
85
+ typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) {
86
+ AFHTTPRequestQueryStringDefaultStyle = 0,
87
+ };
88
+
89
+ @protocol AFMultipartFormData;
90
+
91
+ /**
92
+ `AFHTTPRequestSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
93
+
94
+ Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior.
95
+ */
96
+ @interface AFHTTPRequestSerializer : NSObject <AFURLRequestSerialization>
97
+
98
+ /**
99
+ The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default.
100
+ */
101
+ @property (nonatomic, assign) NSStringEncoding stringEncoding;
102
+
103
+ /**
104
+ Whether created requests can use the device’s cellular radio (if present). `YES` by default.
105
+
106
+ @see NSMutableURLRequest -setAllowsCellularAccess:
107
+ */
108
+ @property (nonatomic, assign) BOOL allowsCellularAccess;
109
+
110
+ /**
111
+ The cache policy of created requests. `NSURLRequestUseProtocolCachePolicy` by default.
112
+
113
+ @see NSMutableURLRequest -setCachePolicy:
114
+ */
115
+ @property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy;
116
+
117
+ /**
118
+ Whether created requests should use the default cookie handling. `YES` by default.
119
+
120
+ @see NSMutableURLRequest -setHTTPShouldHandleCookies:
121
+ */
122
+ @property (nonatomic, assign) BOOL HTTPShouldHandleCookies;
123
+
124
+ /**
125
+ Whether created requests can continue transmitting data before receiving a response from an earlier transmission. `NO` by default
126
+
127
+ @see NSMutableURLRequest -setHTTPShouldUsePipelining:
128
+ */
129
+ @property (nonatomic, assign) BOOL HTTPShouldUsePipelining;
130
+
131
+ /**
132
+ The network service type for created requests. `NSURLNetworkServiceTypeDefault` by default.
133
+
134
+ @see NSMutableURLRequest -setNetworkServiceType:
135
+ */
136
+ @property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType;
137
+
138
+ /**
139
+ The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds.
140
+
141
+ @see NSMutableURLRequest -setTimeoutInterval:
142
+ */
143
+ @property (nonatomic, assign) NSTimeInterval timeoutInterval;
144
+
145
+ ///---------------------------------------
146
+ /// @name Configuring HTTP Request Headers
147
+ ///---------------------------------------
148
+
149
+ /**
150
+ Default HTTP header field values to be applied to serialized requests. By default, these include the following:
151
+
152
+ - `Accept-Language` with the contents of `NSLocale +preferredLanguages`
153
+ - `User-Agent` with the contents of various bundle identifiers and OS designations
154
+
155
+ @discussion To add or remove default request headers, use `setValue:forHTTPHeaderField:`.
156
+ */
157
+ @property (readonly, nonatomic, strong) NSDictionary <NSString *, NSString *> *HTTPRequestHeaders;
158
+
159
+ /**
160
+ Creates and returns a serializer with default configuration.
161
+ */
162
+ + (instancetype)serializer;
163
+
164
+ /**
165
+ Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header.
166
+
167
+ @param field The HTTP header to set a default value for
168
+ @param value The value set as default for the specified header, or `nil`
169
+ */
170
+ - (void)setValue:(nullable NSString *)value
171
+ forHTTPHeaderField:(NSString *)field;
172
+
173
+ /**
174
+ Returns the value for the HTTP headers set in the request serializer.
175
+
176
+ @param field The HTTP header to retrieve the default value for
177
+
178
+ @return The value set as default for the specified header, or `nil`
179
+ */
180
+ - (nullable NSString *)valueForHTTPHeaderField:(NSString *)field;
181
+
182
+ /**
183
+ Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
184
+
185
+ @param username The HTTP basic auth username
186
+ @param password The HTTP basic auth password
187
+ */
188
+ - (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username
189
+ password:(NSString *)password;
190
+
191
+ /**
192
+ Clears any existing value for the "Authorization" HTTP header.
193
+ */
194
+ - (void)clearAuthorizationHeader;
195
+
196
+ ///-------------------------------------------------------
197
+ /// @name Configuring Query String Parameter Serialization
198
+ ///-------------------------------------------------------
199
+
200
+ /**
201
+ HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default.
202
+ */
203
+ @property (nonatomic, strong) NSSet <NSString *> *HTTPMethodsEncodingParametersInURI;
204
+
205
+ /**
206
+ Set the method of query string serialization according to one of the pre-defined styles.
207
+
208
+ @param style The serialization style.
209
+
210
+ @see AFHTTPRequestQueryStringSerializationStyle
211
+ */
212
+ - (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style;
213
+
214
+ /**
215
+ Set the a custom method of query string serialization according to the specified block.
216
+
217
+ @param block A block that defines a process of encoding parameters into a query string. This block returns the query string and takes three arguments: the request, the parameters to encode, and the error that occurred when attempting to encode parameters for the given request.
218
+ */
219
+ - (void)setQueryStringSerializationWithBlock:(nullable NSString * _Nullable (^)(NSURLRequest *request, id parameters, NSError * __autoreleasing *error))block;
220
+
221
+ ///-------------------------------
222
+ /// @name Creating Request Objects
223
+ ///-------------------------------
224
+
225
+ /**
226
+ Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string.
227
+
228
+ If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body.
229
+
230
+ @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`.
231
+ @param URLString The URL string used to create the request URL.
232
+ @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body.
233
+ @param error The error that occurred while constructing the request.
234
+
235
+ @return An `NSMutableURLRequest` object.
236
+ */
237
+ - (nullable NSMutableURLRequest *)requestWithMethod:(NSString *)method
238
+ URLString:(NSString *)URLString
239
+ parameters:(nullable id)parameters
240
+ error:(NSError * _Nullable __autoreleasing *)error;
241
+
242
+ /**
243
+ Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2
244
+
245
+ Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream.
246
+
247
+ @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`.
248
+ @param URLString The URL string used to create the request URL.
249
+ @param parameters The parameters to be encoded and set in the request HTTP body.
250
+ @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol.
251
+ @param error The error that occurred while constructing the request.
252
+
253
+ @return An `NSMutableURLRequest` object
254
+ */
255
+ - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
256
+ URLString:(NSString *)URLString
257
+ parameters:(nullable NSDictionary <NSString *, id> *)parameters
258
+ constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block
259
+ error:(NSError * _Nullable __autoreleasing *)error;
260
+
261
+ /**
262
+ Creates an `NSMutableURLRequest` by removing the `HTTPBodyStream` from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished.
263
+
264
+ @param request The multipart form request. The `HTTPBodyStream` property of `request` must not be `nil`.
265
+ @param fileURL The file URL to write multipart form contents to.
266
+ @param handler A handler block to execute.
267
+
268
+ @discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request.
269
+
270
+ @see https://github.com/AFNetworking/AFNetworking/issues/1398
271
+ */
272
+ - (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request
273
+ writingStreamContentsToFile:(NSURL *)fileURL
274
+ completionHandler:(nullable void (^)(NSError * _Nullable error))handler;
275
+
276
+ @end
277
+
278
+ #pragma mark -
279
+
280
+ /**
281
+ The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPRequestSerializer -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:`.
282
+ */
283
+ @protocol AFMultipartFormData
284
+
285
+ /**
286
+ Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary.
287
+
288
+ The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively.
289
+
290
+ @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
291
+ @param name The name to be associated with the specified data. This parameter must not be `nil`.
292
+ @param error If an error occurs, upon return contains an `NSError` object that describes the problem.
293
+
294
+ @return `YES` if the file data was successfully appended, otherwise `NO`.
295
+ */
296
+ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL
297
+ name:(NSString *)name
298
+ error:(NSError * _Nullable __autoreleasing *)error;
299
+
300
+ /**
301
+ Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
302
+
303
+ @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
304
+ @param name The name to be associated with the specified data. This parameter must not be `nil`.
305
+ @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`.
306
+ @param mimeType The declared MIME type of the file data. This parameter must not be `nil`.
307
+ @param error If an error occurs, upon return contains an `NSError` object that describes the problem.
308
+
309
+ @return `YES` if the file data was successfully appended otherwise `NO`.
310
+ */
311
+ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL
312
+ name:(NSString *)name
313
+ fileName:(NSString *)fileName
314
+ mimeType:(NSString *)mimeType
315
+ error:(NSError * _Nullable __autoreleasing *)error;
316
+
317
+ /**
318
+ Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary.
319
+
320
+ @param inputStream The input stream to be appended to the form data
321
+ @param name The name to be associated with the specified input stream. This parameter must not be `nil`.
322
+ @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`.
323
+ @param length The length of the specified input stream in bytes.
324
+ @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
325
+ */
326
+ - (void)appendPartWithInputStream:(nullable NSInputStream *)inputStream
327
+ name:(NSString *)name
328
+ fileName:(NSString *)fileName
329
+ length:(int64_t)length
330
+ mimeType:(NSString *)mimeType;
331
+
332
+ /**
333
+ Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
334
+
335
+ @param data The data to be encoded and appended to the form data.
336
+ @param name The name to be associated with the specified data. This parameter must not be `nil`.
337
+ @param fileName The filename to be associated with the specified data. This parameter must not be `nil`.
338
+ @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
339
+ */
340
+ - (void)appendPartWithFileData:(NSData *)data
341
+ name:(NSString *)name
342
+ fileName:(NSString *)fileName
343
+ mimeType:(NSString *)mimeType;
344
+
345
+ /**
346
+ Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary.
347
+
348
+ @param data The data to be encoded and appended to the form data.
349
+ @param name The name to be associated with the specified data. This parameter must not be `nil`.
350
+ */
351
+
352
+ - (void)appendPartWithFormData:(NSData *)data
353
+ name:(NSString *)name;
354
+
355
+
356
+ /**
357
+ Appends HTTP headers, followed by the encoded data and the multipart form boundary.
358
+
359
+ @param headers The HTTP headers to be appended to the form data.
360
+ @param body The data to be encoded and appended to the form data. This parameter must not be `nil`.
361
+ */
362
+ - (void)appendPartWithHeaders:(nullable NSDictionary <NSString *, NSString *> *)headers
363
+ body:(NSData *)body;
364
+
365
+ /**
366
+ Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
367
+
368
+ When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, there is no definite way to distinguish between a 3G, EDGE, or LTE connection over `NSURLConnection`. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth.
369
+
370
+ @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 16kb.
371
+ @param delay Duration of delay each time a packet is read. By default, no delay is set.
372
+ */
373
+ - (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
374
+ delay:(NSTimeInterval)delay;
375
+
376
+ @end
377
+
378
+ #pragma mark -
379
+
380
+ /**
381
+ `AFJSONRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`.
382
+ */
383
+ @interface AFJSONRequestSerializer : AFHTTPRequestSerializer
384
+
385
+ /**
386
+ Options for writing the request JSON data from Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONWritingOptions". `0` by default.
387
+ */
388
+ @property (nonatomic, assign) NSJSONWritingOptions writingOptions;
389
+
390
+ /**
391
+ Creates and returns a JSON serializer with specified reading and writing options.
392
+
393
+ @param writingOptions The specified JSON writing options.
394
+ */
395
+ + (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions;
396
+
397
+ @end
398
+
399
+ #pragma mark -
400
+
401
+ /**
402
+ `AFPropertyListRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSPropertyListSerializer`, setting the `Content-Type` of the encoded request to `application/x-plist`.
403
+ */
404
+ @interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer
405
+
406
+ /**
407
+ The property list format. Possible values are described in "NSPropertyListFormat".
408
+ */
409
+ @property (nonatomic, assign) NSPropertyListFormat format;
410
+
411
+ /**
412
+ @warning The `writeOptions` property is currently unused.
413
+ */
414
+ @property (nonatomic, assign) NSPropertyListWriteOptions writeOptions;
415
+
416
+ /**
417
+ Creates and returns a property list serializer with a specified format, read options, and write options.
418
+
419
+ @param format The property list format.
420
+ @param writeOptions The property list write options.
421
+
422
+ @warning The `writeOptions` property is currently unused.
423
+ */
424
+ + (instancetype)serializerWithFormat:(NSPropertyListFormat)format
425
+ writeOptions:(NSPropertyListWriteOptions)writeOptions;
426
+
427
+ @end
428
+
429
+ #pragma mark -
430
+
431
+ ///----------------
432
+ /// @name Constants
433
+ ///----------------
434
+
435
+ /**
436
+ ## Error Domains
437
+
438
+ The following error domain is predefined.
439
+
440
+ - `NSString * const AFURLRequestSerializationErrorDomain`
441
+
442
+ ### Constants
443
+
444
+ `AFURLRequestSerializationErrorDomain`
445
+ AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
446
+ */
447
+ FOUNDATION_EXPORT NSString * const AFURLRequestSerializationErrorDomain;
448
+
449
+ /**
450
+ ## User info dictionary keys
451
+
452
+ These keys may exist in the user info dictionary, in addition to those defined for NSError.
453
+
454
+ - `NSString * const AFNetworkingOperationFailingURLRequestErrorKey`
455
+
456
+ ### Constants
457
+
458
+ `AFNetworkingOperationFailingURLRequestErrorKey`
459
+ The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`.
460
+ */
461
+ FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLRequestErrorKey;
462
+
463
+ /**
464
+ ## Throttling Bandwidth for HTTP Request Input Streams
465
+
466
+ @see -throttleBandwidthWithPacketSize:delay:
467
+
468
+ ### Constants
469
+
470
+ `kAFUploadStream3GSuggestedPacketSize`
471
+ Maximum packet size, in number of bytes. Equal to 16kb.
472
+
473
+ `kAFUploadStream3GSuggestedDelay`
474
+ Duration of delay each time a packet is read. Equal to 0.2 seconds.
475
+ */
476
+ FOUNDATION_EXPORT NSUInteger const kAFUploadStream3GSuggestedPacketSize;
477
+ FOUNDATION_EXPORT NSTimeInterval const kAFUploadStream3GSuggestedDelay;
478
+
479
+ NS_ASSUME_NONNULL_END
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m ADDED
@@ -0,0 +1,1399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFURLRequestSerialization.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 "AFURLRequestSerialization.h"
23
+
24
+ #if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
25
+ #import <MobileCoreServices/MobileCoreServices.h>
26
+ #else
27
+ #import <CoreServices/CoreServices.h>
28
+ #endif
29
+
30
+ NSString * const AFURLRequestSerializationErrorDomain = @"com.alamofire.error.serialization.request";
31
+ NSString * const AFNetworkingOperationFailingURLRequestErrorKey = @"com.alamofire.serialization.request.error.response";
32
+
33
+ typedef NSString * (^AFQueryStringSerializationBlock)(NSURLRequest *request, id parameters, NSError *__autoreleasing *error);
34
+
35
+ /**
36
+ Returns a percent-escaped string following RFC 3986 for a query string key or value.
37
+ RFC 3986 states that the following characters are "reserved" characters.
38
+ - General Delimiters: ":", "#", "[", "]", "@", "?", "/"
39
+ - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="
40
+
41
+ In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow
42
+ query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/"
43
+ should be percent-escaped in the query string.
44
+ - parameter string: The string to be percent-escaped.
45
+ - returns: The percent-escaped string.
46
+ */
47
+ NSString * AFPercentEscapedStringFromString(NSString *string) {
48
+ static NSString * const kAFCharactersGeneralDelimitersToEncode = @":#[]@"; // does not include "?" or "/" due to RFC 3986 - Section 3.4
49
+ static NSString * const kAFCharactersSubDelimitersToEncode = @"!$&'()*+,;=";
50
+
51
+ NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy];
52
+ [allowedCharacterSet removeCharactersInString:[kAFCharactersGeneralDelimitersToEncode stringByAppendingString:kAFCharactersSubDelimitersToEncode]];
53
+
54
+ // FIXME: https://github.com/AFNetworking/AFNetworking/pull/3028
55
+ // return [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet];
56
+
57
+ static NSUInteger const batchSize = 50;
58
+
59
+ NSUInteger index = 0;
60
+ NSMutableString *escaped = @"".mutableCopy;
61
+
62
+ while (index < string.length) {
63
+ NSUInteger length = MIN(string.length - index, batchSize);
64
+ NSRange range = NSMakeRange(index, length);
65
+
66
+ // To avoid breaking up character sequences such as 👴🏻👮🏽
67
+ range = [string rangeOfComposedCharacterSequencesForRange:range];
68
+
69
+ NSString *substring = [string substringWithRange:range];
70
+ NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet];
71
+ [escaped appendString:encoded];
72
+
73
+ index += range.length;
74
+ }
75
+
76
+ return escaped;
77
+ }
78
+
79
+ #pragma mark -
80
+
81
+ @interface AFQueryStringPair : NSObject
82
+ @property (readwrite, nonatomic, strong) id field;
83
+ @property (readwrite, nonatomic, strong) id value;
84
+
85
+ - (instancetype)initWithField:(id)field value:(id)value;
86
+
87
+ - (NSString *)URLEncodedStringValue;
88
+ @end
89
+
90
+ @implementation AFQueryStringPair
91
+
92
+ - (instancetype)initWithField:(id)field value:(id)value {
93
+ self = [super init];
94
+ if (!self) {
95
+ return nil;
96
+ }
97
+
98
+ self.field = field;
99
+ self.value = value;
100
+
101
+ return self;
102
+ }
103
+
104
+ - (NSString *)URLEncodedStringValue {
105
+ if (!self.value || [self.value isEqual:[NSNull null]]) {
106
+ return AFPercentEscapedStringFromString([self.field description]);
107
+ } else {
108
+ return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedStringFromString([self.field description]), AFPercentEscapedStringFromString([self.value description])];
109
+ }
110
+ }
111
+
112
+ @end
113
+
114
+ #pragma mark -
115
+
116
+ FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary);
117
+ FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value);
118
+
119
+ NSString * AFQueryStringFromParameters(NSDictionary *parameters) {
120
+ NSMutableArray *mutablePairs = [NSMutableArray array];
121
+ for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) {
122
+ [mutablePairs addObject:[pair URLEncodedStringValue]];
123
+ }
124
+
125
+ return [mutablePairs componentsJoinedByString:@"&"];
126
+ }
127
+
128
+ NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary) {
129
+ return AFQueryStringPairsFromKeyAndValue(nil, dictionary);
130
+ }
131
+
132
+ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) {
133
+ NSMutableArray *mutableQueryStringComponents = [NSMutableArray array];
134
+
135
+ NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(compare:)];
136
+
137
+ if ([value isKindOfClass:[NSDictionary class]]) {
138
+ NSDictionary *dictionary = value;
139
+ // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries
140
+ for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) {
141
+ id nestedValue = dictionary[nestedKey];
142
+ if (nestedValue) {
143
+ [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)];
144
+ }
145
+ }
146
+ } else if ([value isKindOfClass:[NSArray class]]) {
147
+ NSArray *array = value;
148
+ for (id nestedValue in array) {
149
+ [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)];
150
+ }
151
+ } else if ([value isKindOfClass:[NSSet class]]) {
152
+ NSSet *set = value;
153
+ for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) {
154
+ [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, obj)];
155
+ }
156
+ } else {
157
+ [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]];
158
+ }
159
+
160
+ return mutableQueryStringComponents;
161
+ }
162
+
163
+ #pragma mark -
164
+
165
+ @interface AFStreamingMultipartFormData : NSObject <AFMultipartFormData>
166
+ - (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest
167
+ stringEncoding:(NSStringEncoding)encoding;
168
+
169
+ - (NSMutableURLRequest *)requestByFinalizingMultipartFormData;
170
+ @end
171
+
172
+ #pragma mark -
173
+
174
+ static NSArray * AFHTTPRequestSerializerObservedKeyPaths() {
175
+ static NSArray *_AFHTTPRequestSerializerObservedKeyPaths = nil;
176
+ static dispatch_once_t onceToken;
177
+ dispatch_once(&onceToken, ^{
178
+ _AFHTTPRequestSerializerObservedKeyPaths = @[NSStringFromSelector(@selector(allowsCellularAccess)), NSStringFromSelector(@selector(cachePolicy)), NSStringFromSelector(@selector(HTTPShouldHandleCookies)), NSStringFromSelector(@selector(HTTPShouldUsePipelining)), NSStringFromSelector(@selector(networkServiceType)), NSStringFromSelector(@selector(timeoutInterval))];
179
+ });
180
+
181
+ return _AFHTTPRequestSerializerObservedKeyPaths;
182
+ }
183
+
184
+ static void *AFHTTPRequestSerializerObserverContext = &AFHTTPRequestSerializerObserverContext;
185
+
186
+ @interface AFHTTPRequestSerializer ()
187
+ @property (readwrite, nonatomic, strong) NSMutableSet *mutableObservedChangedKeyPaths;
188
+ @property (readwrite, nonatomic, strong) NSMutableDictionary *mutableHTTPRequestHeaders;
189
+ @property (readwrite, nonatomic, strong) dispatch_queue_t requestHeaderModificationQueue;
190
+ @property (readwrite, nonatomic, assign) AFHTTPRequestQueryStringSerializationStyle queryStringSerializationStyle;
191
+ @property (readwrite, nonatomic, copy) AFQueryStringSerializationBlock queryStringSerialization;
192
+ @end
193
+
194
+ @implementation AFHTTPRequestSerializer
195
+
196
+ + (instancetype)serializer {
197
+ return [[self alloc] init];
198
+ }
199
+
200
+ - (instancetype)init {
201
+ self = [super init];
202
+ if (!self) {
203
+ return nil;
204
+ }
205
+
206
+ self.stringEncoding = NSUTF8StringEncoding;
207
+
208
+ self.mutableHTTPRequestHeaders = [NSMutableDictionary dictionary];
209
+ self.requestHeaderModificationQueue = dispatch_queue_create("requestHeaderModificationQueue", DISPATCH_QUEUE_CONCURRENT);
210
+
211
+ // Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
212
+ NSMutableArray *acceptLanguagesComponents = [NSMutableArray array];
213
+ [[NSLocale preferredLanguages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
214
+ float q = 1.0f - (idx * 0.1f);
215
+ [acceptLanguagesComponents addObject:[NSString stringWithFormat:@"%@;q=%0.1g", obj, q]];
216
+ *stop = q <= 0.5f;
217
+ }];
218
+ [self setValue:[acceptLanguagesComponents componentsJoinedByString:@", "] forHTTPHeaderField:@"Accept-Language"];
219
+
220
+ // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
221
+ NSString *userAgent = nil;
222
+ #if TARGET_OS_IOS
223
+ userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]];
224
+ #elif TARGET_OS_TV
225
+ userAgent = [NSString stringWithFormat:@"%@/%@ (%@; tvOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]];
226
+ #elif TARGET_OS_WATCH
227
+ userAgent = [NSString stringWithFormat:@"%@/%@ (%@; watchOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[WKInterfaceDevice currentDevice] model], [[WKInterfaceDevice currentDevice] systemVersion], [[WKInterfaceDevice currentDevice] screenScale]];
228
+ #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
229
+ userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]];
230
+ #endif
231
+ if (userAgent) {
232
+ if (![userAgent canBeConvertedToEncoding:NSASCIIStringEncoding]) {
233
+ NSMutableString *mutableUserAgent = [userAgent mutableCopy];
234
+ if (CFStringTransform((__bridge CFMutableStringRef)(mutableUserAgent), NULL, (__bridge CFStringRef)@"Any-Latin; Latin-ASCII; [:^ASCII:] Remove", false)) {
235
+ userAgent = mutableUserAgent;
236
+ }
237
+ }
238
+ [self setValue:userAgent forHTTPHeaderField:@"User-Agent"];
239
+ }
240
+
241
+ // HTTP Method Definitions; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
242
+ self.HTTPMethodsEncodingParametersInURI = [NSSet setWithObjects:@"GET", @"HEAD", @"DELETE", nil];
243
+
244
+ self.mutableObservedChangedKeyPaths = [NSMutableSet set];
245
+ for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) {
246
+ if ([self respondsToSelector:NSSelectorFromString(keyPath)]) {
247
+ [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:AFHTTPRequestSerializerObserverContext];
248
+ }
249
+ }
250
+
251
+ return self;
252
+ }
253
+
254
+ - (void)dealloc {
255
+ for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) {
256
+ if ([self respondsToSelector:NSSelectorFromString(keyPath)]) {
257
+ [self removeObserver:self forKeyPath:keyPath context:AFHTTPRequestSerializerObserverContext];
258
+ }
259
+ }
260
+ }
261
+
262
+ #pragma mark -
263
+
264
+ // Workarounds for crashing behavior using Key-Value Observing with XCTest
265
+ // See https://github.com/AFNetworking/AFNetworking/issues/2523
266
+
267
+ - (void)setAllowsCellularAccess:(BOOL)allowsCellularAccess {
268
+ [self willChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))];
269
+ _allowsCellularAccess = allowsCellularAccess;
270
+ [self didChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))];
271
+ }
272
+
273
+ - (void)setCachePolicy:(NSURLRequestCachePolicy)cachePolicy {
274
+ [self willChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))];
275
+ _cachePolicy = cachePolicy;
276
+ [self didChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))];
277
+ }
278
+
279
+ - (void)setHTTPShouldHandleCookies:(BOOL)HTTPShouldHandleCookies {
280
+ [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))];
281
+ _HTTPShouldHandleCookies = HTTPShouldHandleCookies;
282
+ [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))];
283
+ }
284
+
285
+ - (void)setHTTPShouldUsePipelining:(BOOL)HTTPShouldUsePipelining {
286
+ [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))];
287
+ _HTTPShouldUsePipelining = HTTPShouldUsePipelining;
288
+ [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))];
289
+ }
290
+
291
+ - (void)setNetworkServiceType:(NSURLRequestNetworkServiceType)networkServiceType {
292
+ [self willChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))];
293
+ _networkServiceType = networkServiceType;
294
+ [self didChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))];
295
+ }
296
+
297
+ - (void)setTimeoutInterval:(NSTimeInterval)timeoutInterval {
298
+ [self willChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))];
299
+ _timeoutInterval = timeoutInterval;
300
+ [self didChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))];
301
+ }
302
+
303
+ #pragma mark -
304
+
305
+ - (NSDictionary *)HTTPRequestHeaders {
306
+ NSDictionary __block *value;
307
+ dispatch_sync(self.requestHeaderModificationQueue, ^{
308
+ value = [NSDictionary dictionaryWithDictionary:self.mutableHTTPRequestHeaders];
309
+ });
310
+ return value;
311
+ }
312
+
313
+ - (void)setValue:(NSString *)value
314
+ forHTTPHeaderField:(NSString *)field
315
+ {
316
+ dispatch_barrier_sync(self.requestHeaderModificationQueue, ^{
317
+ [self.mutableHTTPRequestHeaders setValue:value forKey:field];
318
+ });
319
+ }
320
+
321
+ - (NSString *)valueForHTTPHeaderField:(NSString *)field {
322
+ NSString __block *value;
323
+ dispatch_sync(self.requestHeaderModificationQueue, ^{
324
+ value = [self.mutableHTTPRequestHeaders valueForKey:field];
325
+ });
326
+ return value;
327
+ }
328
+
329
+ - (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username
330
+ password:(NSString *)password
331
+ {
332
+ NSData *basicAuthCredentials = [[NSString stringWithFormat:@"%@:%@", username, password] dataUsingEncoding:NSUTF8StringEncoding];
333
+ NSString *base64AuthCredentials = [basicAuthCredentials base64EncodedStringWithOptions:(NSDataBase64EncodingOptions)0];
334
+ [self setValue:[NSString stringWithFormat:@"Basic %@", base64AuthCredentials] forHTTPHeaderField:@"Authorization"];
335
+ }
336
+
337
+ - (void)clearAuthorizationHeader {
338
+ dispatch_barrier_sync(self.requestHeaderModificationQueue, ^{
339
+ [self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"];
340
+ });
341
+ }
342
+
343
+ #pragma mark -
344
+
345
+ - (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style {
346
+ self.queryStringSerializationStyle = style;
347
+ self.queryStringSerialization = nil;
348
+ }
349
+
350
+ - (void)setQueryStringSerializationWithBlock:(NSString *(^)(NSURLRequest *, id, NSError *__autoreleasing *))block {
351
+ self.queryStringSerialization = block;
352
+ }
353
+
354
+ #pragma mark -
355
+
356
+ - (NSMutableURLRequest *)requestWithMethod:(NSString *)method
357
+ URLString:(NSString *)URLString
358
+ parameters:(id)parameters
359
+ error:(NSError *__autoreleasing *)error
360
+ {
361
+ NSParameterAssert(method);
362
+ NSParameterAssert(URLString);
363
+
364
+ NSURL *url = [NSURL URLWithString:URLString];
365
+
366
+ NSParameterAssert(url);
367
+
368
+ NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url];
369
+ mutableRequest.HTTPMethod = method;
370
+
371
+ for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) {
372
+ if ([self.mutableObservedChangedKeyPaths containsObject:keyPath]) {
373
+ [mutableRequest setValue:[self valueForKeyPath:keyPath] forKey:keyPath];
374
+ }
375
+ }
376
+
377
+ mutableRequest = [[self requestBySerializingRequest:mutableRequest withParameters:parameters error:error] mutableCopy];
378
+
379
+ return mutableRequest;
380
+ }
381
+
382
+ - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
383
+ URLString:(NSString *)URLString
384
+ parameters:(NSDictionary *)parameters
385
+ constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
386
+ error:(NSError *__autoreleasing *)error
387
+ {
388
+ NSParameterAssert(method);
389
+ NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]);
390
+
391
+ NSMutableURLRequest *mutableRequest = [self requestWithMethod:method URLString:URLString parameters:nil error:error];
392
+
393
+ __block AFStreamingMultipartFormData *formData = [[AFStreamingMultipartFormData alloc] initWithURLRequest:mutableRequest stringEncoding:NSUTF8StringEncoding];
394
+
395
+ if (parameters) {
396
+ for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) {
397
+ NSData *data = nil;
398
+ if ([pair.value isKindOfClass:[NSData class]]) {
399
+ data = pair.value;
400
+ } else if ([pair.value isEqual:[NSNull null]]) {
401
+ data = [NSData data];
402
+ } else {
403
+ data = [[pair.value description] dataUsingEncoding:self.stringEncoding];
404
+ }
405
+
406
+ if (data) {
407
+ [formData appendPartWithFormData:data name:[pair.field description]];
408
+ }
409
+ }
410
+ }
411
+
412
+ if (block) {
413
+ block(formData);
414
+ }
415
+
416
+ return [formData requestByFinalizingMultipartFormData];
417
+ }
418
+
419
+ - (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request
420
+ writingStreamContentsToFile:(NSURL *)fileURL
421
+ completionHandler:(void (^)(NSError *error))handler
422
+ {
423
+ NSParameterAssert(request.HTTPBodyStream);
424
+ NSParameterAssert([fileURL isFileURL]);
425
+
426
+ NSInputStream *inputStream = request.HTTPBodyStream;
427
+ NSOutputStream *outputStream = [[NSOutputStream alloc] initWithURL:fileURL append:NO];
428
+ __block NSError *error = nil;
429
+
430
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
431
+ [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
432
+ [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
433
+
434
+ [inputStream open];
435
+ [outputStream open];
436
+
437
+ while ([inputStream hasBytesAvailable] && [outputStream hasSpaceAvailable]) {
438
+ uint8_t buffer[1024];
439
+
440
+ NSInteger bytesRead = [inputStream read:buffer maxLength:1024];
441
+ if (inputStream.streamError || bytesRead < 0) {
442
+ error = inputStream.streamError;
443
+ break;
444
+ }
445
+
446
+ NSInteger bytesWritten = [outputStream write:buffer maxLength:(NSUInteger)bytesRead];
447
+ if (outputStream.streamError || bytesWritten < 0) {
448
+ error = outputStream.streamError;
449
+ break;
450
+ }
451
+
452
+ if (bytesRead == 0 && bytesWritten == 0) {
453
+ break;
454
+ }
455
+ }
456
+
457
+ [outputStream close];
458
+ [inputStream close];
459
+
460
+ if (handler) {
461
+ dispatch_async(dispatch_get_main_queue(), ^{
462
+ handler(error);
463
+ });
464
+ }
465
+ });
466
+
467
+ NSMutableURLRequest *mutableRequest = [request mutableCopy];
468
+ mutableRequest.HTTPBodyStream = nil;
469
+
470
+ return mutableRequest;
471
+ }
472
+
473
+ #pragma mark - AFURLRequestSerialization
474
+
475
+ - (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
476
+ withParameters:(id)parameters
477
+ error:(NSError *__autoreleasing *)error
478
+ {
479
+ NSParameterAssert(request);
480
+
481
+ NSMutableURLRequest *mutableRequest = [request mutableCopy];
482
+
483
+ [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) {
484
+ if (![request valueForHTTPHeaderField:field]) {
485
+ [mutableRequest setValue:value forHTTPHeaderField:field];
486
+ }
487
+ }];
488
+
489
+ NSString *query = nil;
490
+ if (parameters) {
491
+ if (self.queryStringSerialization) {
492
+ NSError *serializationError;
493
+ query = self.queryStringSerialization(request, parameters, &serializationError);
494
+
495
+ if (serializationError) {
496
+ if (error) {
497
+ *error = serializationError;
498
+ }
499
+
500
+ return nil;
501
+ }
502
+ } else {
503
+ switch (self.queryStringSerializationStyle) {
504
+ case AFHTTPRequestQueryStringDefaultStyle:
505
+ query = AFQueryStringFromParameters(parameters);
506
+ break;
507
+ }
508
+ }
509
+ }
510
+
511
+ if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) {
512
+ if (query && query.length > 0) {
513
+ mutableRequest.URL = [NSURL URLWithString:[[mutableRequest.URL absoluteString] stringByAppendingFormat:mutableRequest.URL.query ? @"&%@" : @"?%@", query]];
514
+ }
515
+ } else {
516
+ // #2864: an empty string is a valid x-www-form-urlencoded payload
517
+ if (!query) {
518
+ query = @"";
519
+ }
520
+ if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) {
521
+ [mutableRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
522
+ }
523
+ [mutableRequest setHTTPBody:[query dataUsingEncoding:self.stringEncoding]];
524
+ }
525
+
526
+ return mutableRequest;
527
+ }
528
+
529
+ #pragma mark - NSKeyValueObserving
530
+
531
+ + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key {
532
+ if ([AFHTTPRequestSerializerObservedKeyPaths() containsObject:key]) {
533
+ return NO;
534
+ }
535
+
536
+ return [super automaticallyNotifiesObserversForKey:key];
537
+ }
538
+
539
+ - (void)observeValueForKeyPath:(NSString *)keyPath
540
+ ofObject:(__unused id)object
541
+ change:(NSDictionary *)change
542
+ context:(void *)context
543
+ {
544
+ if (context == AFHTTPRequestSerializerObserverContext) {
545
+ if ([change[NSKeyValueChangeNewKey] isEqual:[NSNull null]]) {
546
+ [self.mutableObservedChangedKeyPaths removeObject:keyPath];
547
+ } else {
548
+ [self.mutableObservedChangedKeyPaths addObject:keyPath];
549
+ }
550
+ }
551
+ }
552
+
553
+ #pragma mark - NSSecureCoding
554
+
555
+ + (BOOL)supportsSecureCoding {
556
+ return YES;
557
+ }
558
+
559
+ - (instancetype)initWithCoder:(NSCoder *)decoder {
560
+ self = [self init];
561
+ if (!self) {
562
+ return nil;
563
+ }
564
+
565
+ self.mutableHTTPRequestHeaders = [[decoder decodeObjectOfClass:[NSDictionary class] forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))] mutableCopy];
566
+ self.queryStringSerializationStyle = (AFHTTPRequestQueryStringSerializationStyle)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))] unsignedIntegerValue];
567
+
568
+ return self;
569
+ }
570
+
571
+ - (void)encodeWithCoder:(NSCoder *)coder {
572
+ dispatch_sync(self.requestHeaderModificationQueue, ^{
573
+ [coder encodeObject:self.mutableHTTPRequestHeaders forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))];
574
+ });
575
+ [coder encodeObject:@(self.queryStringSerializationStyle) forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))];
576
+ }
577
+
578
+ #pragma mark - NSCopying
579
+
580
+ - (instancetype)copyWithZone:(NSZone *)zone {
581
+ AFHTTPRequestSerializer *serializer = [[[self class] allocWithZone:zone] init];
582
+ dispatch_sync(self.requestHeaderModificationQueue, ^{
583
+ serializer.mutableHTTPRequestHeaders = [self.mutableHTTPRequestHeaders mutableCopyWithZone:zone];
584
+ });
585
+ serializer.queryStringSerializationStyle = self.queryStringSerializationStyle;
586
+ serializer.queryStringSerialization = self.queryStringSerialization;
587
+
588
+ return serializer;
589
+ }
590
+
591
+ @end
592
+
593
+ #pragma mark -
594
+
595
+ static NSString * AFCreateMultipartFormBoundary() {
596
+ return [NSString stringWithFormat:@"Boundary+%08X%08X", arc4random(), arc4random()];
597
+ }
598
+
599
+ static NSString * const kAFMultipartFormCRLF = @"\r\n";
600
+
601
+ static inline NSString * AFMultipartFormInitialBoundary(NSString *boundary) {
602
+ return [NSString stringWithFormat:@"--%@%@", boundary, kAFMultipartFormCRLF];
603
+ }
604
+
605
+ static inline NSString * AFMultipartFormEncapsulationBoundary(NSString *boundary) {
606
+ return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF];
607
+ }
608
+
609
+ static inline NSString * AFMultipartFormFinalBoundary(NSString *boundary) {
610
+ return [NSString stringWithFormat:@"%@--%@--%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF];
611
+ }
612
+
613
+ static inline NSString * AFContentTypeForPathExtension(NSString *extension) {
614
+ NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL);
615
+ NSString *contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType);
616
+ if (!contentType) {
617
+ return @"application/octet-stream";
618
+ } else {
619
+ return contentType;
620
+ }
621
+ }
622
+
623
+ NSUInteger const kAFUploadStream3GSuggestedPacketSize = 1024 * 16;
624
+ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
625
+
626
+ @interface AFHTTPBodyPart : NSObject
627
+ @property (nonatomic, assign) NSStringEncoding stringEncoding;
628
+ @property (nonatomic, strong) NSDictionary *headers;
629
+ @property (nonatomic, copy) NSString *boundary;
630
+ @property (nonatomic, strong) id body;
631
+ @property (nonatomic, assign) unsigned long long bodyContentLength;
632
+ @property (nonatomic, strong) NSInputStream *inputStream;
633
+
634
+ @property (nonatomic, assign) BOOL hasInitialBoundary;
635
+ @property (nonatomic, assign) BOOL hasFinalBoundary;
636
+
637
+ @property (readonly, nonatomic, assign, getter = hasBytesAvailable) BOOL bytesAvailable;
638
+ @property (readonly, nonatomic, assign) unsigned long long contentLength;
639
+
640
+ - (NSInteger)read:(uint8_t *)buffer
641
+ maxLength:(NSUInteger)length;
642
+ @end
643
+
644
+ @interface AFMultipartBodyStream : NSInputStream <NSStreamDelegate>
645
+ @property (nonatomic, assign) NSUInteger numberOfBytesInPacket;
646
+ @property (nonatomic, assign) NSTimeInterval delay;
647
+ @property (nonatomic, strong) NSInputStream *inputStream;
648
+ @property (readonly, nonatomic, assign) unsigned long long contentLength;
649
+ @property (readonly, nonatomic, assign, getter = isEmpty) BOOL empty;
650
+
651
+ - (instancetype)initWithStringEncoding:(NSStringEncoding)encoding;
652
+ - (void)setInitialAndFinalBoundaries;
653
+ - (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart;
654
+ @end
655
+
656
+ #pragma mark -
657
+
658
+ @interface AFStreamingMultipartFormData ()
659
+ @property (readwrite, nonatomic, copy) NSMutableURLRequest *request;
660
+ @property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding;
661
+ @property (readwrite, nonatomic, copy) NSString *boundary;
662
+ @property (readwrite, nonatomic, strong) AFMultipartBodyStream *bodyStream;
663
+ @end
664
+
665
+ @implementation AFStreamingMultipartFormData
666
+
667
+ - (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest
668
+ stringEncoding:(NSStringEncoding)encoding
669
+ {
670
+ self = [super init];
671
+ if (!self) {
672
+ return nil;
673
+ }
674
+
675
+ self.request = urlRequest;
676
+ self.stringEncoding = encoding;
677
+ self.boundary = AFCreateMultipartFormBoundary();
678
+ self.bodyStream = [[AFMultipartBodyStream alloc] initWithStringEncoding:encoding];
679
+
680
+ return self;
681
+ }
682
+
683
+ - (void)setRequest:(NSMutableURLRequest *)request
684
+ {
685
+ _request = [request mutableCopy];
686
+ }
687
+
688
+ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL
689
+ name:(NSString *)name
690
+ error:(NSError * __autoreleasing *)error
691
+ {
692
+ NSParameterAssert(fileURL);
693
+ NSParameterAssert(name);
694
+
695
+ NSString *fileName = [fileURL lastPathComponent];
696
+ NSString *mimeType = AFContentTypeForPathExtension([fileURL pathExtension]);
697
+
698
+ return [self appendPartWithFileURL:fileURL name:name fileName:fileName mimeType:mimeType error:error];
699
+ }
700
+
701
+ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL
702
+ name:(NSString *)name
703
+ fileName:(NSString *)fileName
704
+ mimeType:(NSString *)mimeType
705
+ error:(NSError * __autoreleasing *)error
706
+ {
707
+ NSParameterAssert(fileURL);
708
+ NSParameterAssert(name);
709
+ NSParameterAssert(fileName);
710
+ NSParameterAssert(mimeType);
711
+
712
+ if (![fileURL isFileURL]) {
713
+ NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil)};
714
+ if (error) {
715
+ *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo];
716
+ }
717
+
718
+ return NO;
719
+ } else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) {
720
+ NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"File URL not reachable.", @"AFNetworking", nil)};
721
+ if (error) {
722
+ *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo];
723
+ }
724
+
725
+ return NO;
726
+ }
727
+
728
+ NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:error];
729
+ if (!fileAttributes) {
730
+ return NO;
731
+ }
732
+
733
+ NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
734
+ [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
735
+ [mutableHeaders setValue:mimeType forKey:@"Content-Type"];
736
+
737
+ AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init];
738
+ bodyPart.stringEncoding = self.stringEncoding;
739
+ bodyPart.headers = mutableHeaders;
740
+ bodyPart.boundary = self.boundary;
741
+ bodyPart.body = fileURL;
742
+ bodyPart.bodyContentLength = [fileAttributes[NSFileSize] unsignedLongLongValue];
743
+ [self.bodyStream appendHTTPBodyPart:bodyPart];
744
+
745
+ return YES;
746
+ }
747
+
748
+ - (void)appendPartWithInputStream:(NSInputStream *)inputStream
749
+ name:(NSString *)name
750
+ fileName:(NSString *)fileName
751
+ length:(int64_t)length
752
+ mimeType:(NSString *)mimeType
753
+ {
754
+ NSParameterAssert(name);
755
+ NSParameterAssert(fileName);
756
+ NSParameterAssert(mimeType);
757
+
758
+ NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
759
+ [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
760
+ [mutableHeaders setValue:mimeType forKey:@"Content-Type"];
761
+
762
+ AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init];
763
+ bodyPart.stringEncoding = self.stringEncoding;
764
+ bodyPart.headers = mutableHeaders;
765
+ bodyPart.boundary = self.boundary;
766
+ bodyPart.body = inputStream;
767
+
768
+ bodyPart.bodyContentLength = (unsigned long long)length;
769
+
770
+ [self.bodyStream appendHTTPBodyPart:bodyPart];
771
+ }
772
+
773
+ - (void)appendPartWithFileData:(NSData *)data
774
+ name:(NSString *)name
775
+ fileName:(NSString *)fileName
776
+ mimeType:(NSString *)mimeType
777
+ {
778
+ NSParameterAssert(name);
779
+ NSParameterAssert(fileName);
780
+ NSParameterAssert(mimeType);
781
+
782
+ NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
783
+ [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
784
+ [mutableHeaders setValue:mimeType forKey:@"Content-Type"];
785
+
786
+ [self appendPartWithHeaders:mutableHeaders body:data];
787
+ }
788
+
789
+ - (void)appendPartWithFormData:(NSData *)data
790
+ name:(NSString *)name
791
+ {
792
+ NSParameterAssert(name);
793
+
794
+ NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
795
+ [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"];
796
+
797
+ [self appendPartWithHeaders:mutableHeaders body:data];
798
+ }
799
+
800
+ - (void)appendPartWithHeaders:(NSDictionary *)headers
801
+ body:(NSData *)body
802
+ {
803
+ NSParameterAssert(body);
804
+
805
+ AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init];
806
+ bodyPart.stringEncoding = self.stringEncoding;
807
+ bodyPart.headers = headers;
808
+ bodyPart.boundary = self.boundary;
809
+ bodyPart.bodyContentLength = [body length];
810
+ bodyPart.body = body;
811
+
812
+ [self.bodyStream appendHTTPBodyPart:bodyPart];
813
+ }
814
+
815
+ - (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
816
+ delay:(NSTimeInterval)delay
817
+ {
818
+ self.bodyStream.numberOfBytesInPacket = numberOfBytes;
819
+ self.bodyStream.delay = delay;
820
+ }
821
+
822
+ - (NSMutableURLRequest *)requestByFinalizingMultipartFormData {
823
+ if ([self.bodyStream isEmpty]) {
824
+ return self.request;
825
+ }
826
+
827
+ // Reset the initial and final boundaries to ensure correct Content-Length
828
+ [self.bodyStream setInitialAndFinalBoundaries];
829
+ [self.request setHTTPBodyStream:self.bodyStream];
830
+
831
+ [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", self.boundary] forHTTPHeaderField:@"Content-Type"];
832
+ [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"];
833
+
834
+ return self.request;
835
+ }
836
+
837
+ @end
838
+
839
+ #pragma mark -
840
+
841
+ @interface NSStream ()
842
+ @property (readwrite) NSStreamStatus streamStatus;
843
+ @property (readwrite, copy) NSError *streamError;
844
+ @end
845
+
846
+ @interface AFMultipartBodyStream () <NSCopying>
847
+ @property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding;
848
+ @property (readwrite, nonatomic, strong) NSMutableArray *HTTPBodyParts;
849
+ @property (readwrite, nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator;
850
+ @property (readwrite, nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart;
851
+ @property (readwrite, nonatomic, strong) NSOutputStream *outputStream;
852
+ @property (readwrite, nonatomic, strong) NSMutableData *buffer;
853
+ @end
854
+
855
+ @implementation AFMultipartBodyStream
856
+ #if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1100)
857
+ @synthesize delegate;
858
+ #endif
859
+ @synthesize streamStatus;
860
+ @synthesize streamError;
861
+
862
+ - (instancetype)initWithStringEncoding:(NSStringEncoding)encoding {
863
+ self = [super init];
864
+ if (!self) {
865
+ return nil;
866
+ }
867
+
868
+ self.stringEncoding = encoding;
869
+ self.HTTPBodyParts = [NSMutableArray array];
870
+ self.numberOfBytesInPacket = NSIntegerMax;
871
+
872
+ return self;
873
+ }
874
+
875
+ - (void)setInitialAndFinalBoundaries {
876
+ if ([self.HTTPBodyParts count] > 0) {
877
+ for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) {
878
+ bodyPart.hasInitialBoundary = NO;
879
+ bodyPart.hasFinalBoundary = NO;
880
+ }
881
+
882
+ [[self.HTTPBodyParts firstObject] setHasInitialBoundary:YES];
883
+ [[self.HTTPBodyParts lastObject] setHasFinalBoundary:YES];
884
+ }
885
+ }
886
+
887
+ - (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart {
888
+ [self.HTTPBodyParts addObject:bodyPart];
889
+ }
890
+
891
+ - (BOOL)isEmpty {
892
+ return [self.HTTPBodyParts count] == 0;
893
+ }
894
+
895
+ #pragma mark - NSInputStream
896
+
897
+ - (NSInteger)read:(uint8_t *)buffer
898
+ maxLength:(NSUInteger)length
899
+ {
900
+ if ([self streamStatus] == NSStreamStatusClosed) {
901
+ return 0;
902
+ }
903
+
904
+ NSInteger totalNumberOfBytesRead = 0;
905
+
906
+ while ((NSUInteger)totalNumberOfBytesRead < MIN(length, self.numberOfBytesInPacket)) {
907
+ if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) {
908
+ if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) {
909
+ break;
910
+ }
911
+ } else {
912
+ NSUInteger maxLength = MIN(length, self.numberOfBytesInPacket) - (NSUInteger)totalNumberOfBytesRead;
913
+ NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:&buffer[totalNumberOfBytesRead] maxLength:maxLength];
914
+ if (numberOfBytesRead == -1) {
915
+ self.streamError = self.currentHTTPBodyPart.inputStream.streamError;
916
+ break;
917
+ } else {
918
+ totalNumberOfBytesRead += numberOfBytesRead;
919
+
920
+ if (self.delay > 0.0f) {
921
+ [NSThread sleepForTimeInterval:self.delay];
922
+ }
923
+ }
924
+ }
925
+ }
926
+
927
+ return totalNumberOfBytesRead;
928
+ }
929
+
930
+ - (BOOL)getBuffer:(__unused uint8_t **)buffer
931
+ length:(__unused NSUInteger *)len
932
+ {
933
+ return NO;
934
+ }
935
+
936
+ - (BOOL)hasBytesAvailable {
937
+ return [self streamStatus] == NSStreamStatusOpen;
938
+ }
939
+
940
+ #pragma mark - NSStream
941
+
942
+ - (void)open {
943
+ if (self.streamStatus == NSStreamStatusOpen) {
944
+ return;
945
+ }
946
+
947
+ self.streamStatus = NSStreamStatusOpen;
948
+
949
+ [self setInitialAndFinalBoundaries];
950
+ self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator];
951
+ }
952
+
953
+ - (void)close {
954
+ self.streamStatus = NSStreamStatusClosed;
955
+ }
956
+
957
+ - (id)propertyForKey:(__unused NSString *)key {
958
+ return nil;
959
+ }
960
+
961
+ - (BOOL)setProperty:(__unused id)property
962
+ forKey:(__unused NSString *)key
963
+ {
964
+ return NO;
965
+ }
966
+
967
+ - (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop
968
+ forMode:(__unused NSString *)mode
969
+ {}
970
+
971
+ - (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop
972
+ forMode:(__unused NSString *)mode
973
+ {}
974
+
975
+ - (unsigned long long)contentLength {
976
+ unsigned long long length = 0;
977
+ for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) {
978
+ length += [bodyPart contentLength];
979
+ }
980
+
981
+ return length;
982
+ }
983
+
984
+ #pragma mark - Undocumented CFReadStream Bridged Methods
985
+
986
+ - (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop
987
+ forMode:(__unused CFStringRef)aMode
988
+ {}
989
+
990
+ - (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop
991
+ forMode:(__unused CFStringRef)aMode
992
+ {}
993
+
994
+ - (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags
995
+ callback:(__unused CFReadStreamClientCallBack)inCallback
996
+ context:(__unused CFStreamClientContext *)inContext {
997
+ return NO;
998
+ }
999
+
1000
+ #pragma mark - NSCopying
1001
+
1002
+ - (instancetype)copyWithZone:(NSZone *)zone {
1003
+ AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding];
1004
+
1005
+ for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) {
1006
+ [bodyStreamCopy appendHTTPBodyPart:[bodyPart copy]];
1007
+ }
1008
+
1009
+ [bodyStreamCopy setInitialAndFinalBoundaries];
1010
+
1011
+ return bodyStreamCopy;
1012
+ }
1013
+
1014
+ @end
1015
+
1016
+ #pragma mark -
1017
+
1018
+ typedef enum {
1019
+ AFEncapsulationBoundaryPhase = 1,
1020
+ AFHeaderPhase = 2,
1021
+ AFBodyPhase = 3,
1022
+ AFFinalBoundaryPhase = 4,
1023
+ } AFHTTPBodyPartReadPhase;
1024
+
1025
+ @interface AFHTTPBodyPart () <NSCopying> {
1026
+ AFHTTPBodyPartReadPhase _phase;
1027
+ NSInputStream *_inputStream;
1028
+ unsigned long long _phaseReadOffset;
1029
+ }
1030
+
1031
+ - (BOOL)transitionToNextPhase;
1032
+ - (NSInteger)readData:(NSData *)data
1033
+ intoBuffer:(uint8_t *)buffer
1034
+ maxLength:(NSUInteger)length;
1035
+ @end
1036
+
1037
+ @implementation AFHTTPBodyPart
1038
+
1039
+ - (instancetype)init {
1040
+ self = [super init];
1041
+ if (!self) {
1042
+ return nil;
1043
+ }
1044
+
1045
+ [self transitionToNextPhase];
1046
+
1047
+ return self;
1048
+ }
1049
+
1050
+ - (void)dealloc {
1051
+ if (_inputStream) {
1052
+ [_inputStream close];
1053
+ _inputStream = nil;
1054
+ }
1055
+ }
1056
+
1057
+ - (NSInputStream *)inputStream {
1058
+ if (!_inputStream) {
1059
+ if ([self.body isKindOfClass:[NSData class]]) {
1060
+ _inputStream = [NSInputStream inputStreamWithData:self.body];
1061
+ } else if ([self.body isKindOfClass:[NSURL class]]) {
1062
+ _inputStream = [NSInputStream inputStreamWithURL:self.body];
1063
+ } else if ([self.body isKindOfClass:[NSInputStream class]]) {
1064
+ _inputStream = self.body;
1065
+ } else {
1066
+ _inputStream = [NSInputStream inputStreamWithData:[NSData data]];
1067
+ }
1068
+ }
1069
+
1070
+ return _inputStream;
1071
+ }
1072
+
1073
+ - (NSString *)stringForHeaders {
1074
+ NSMutableString *headerString = [NSMutableString string];
1075
+ for (NSString *field in [self.headers allKeys]) {
1076
+ [headerString appendString:[NSString stringWithFormat:@"%@: %@%@", field, [self.headers valueForKey:field], kAFMultipartFormCRLF]];
1077
+ }
1078
+ [headerString appendString:kAFMultipartFormCRLF];
1079
+
1080
+ return [NSString stringWithString:headerString];
1081
+ }
1082
+
1083
+ - (unsigned long long)contentLength {
1084
+ unsigned long long length = 0;
1085
+
1086
+ NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding];
1087
+ length += [encapsulationBoundaryData length];
1088
+
1089
+ NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding];
1090
+ length += [headersData length];
1091
+
1092
+ length += _bodyContentLength;
1093
+
1094
+ NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]);
1095
+ length += [closingBoundaryData length];
1096
+
1097
+ return length;
1098
+ }
1099
+
1100
+ - (BOOL)hasBytesAvailable {
1101
+ // Allows `read:maxLength:` to be called again if `AFMultipartFormFinalBoundary` doesn't fit into the available buffer
1102
+ if (_phase == AFFinalBoundaryPhase) {
1103
+ return YES;
1104
+ }
1105
+
1106
+ switch (self.inputStream.streamStatus) {
1107
+ case NSStreamStatusNotOpen:
1108
+ case NSStreamStatusOpening:
1109
+ case NSStreamStatusOpen:
1110
+ case NSStreamStatusReading:
1111
+ case NSStreamStatusWriting:
1112
+ return YES;
1113
+ case NSStreamStatusAtEnd:
1114
+ case NSStreamStatusClosed:
1115
+ case NSStreamStatusError:
1116
+ default:
1117
+ return NO;
1118
+ }
1119
+ }
1120
+
1121
+ - (NSInteger)read:(uint8_t *)buffer
1122
+ maxLength:(NSUInteger)length
1123
+ {
1124
+ NSInteger totalNumberOfBytesRead = 0;
1125
+
1126
+ if (_phase == AFEncapsulationBoundaryPhase) {
1127
+ NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding];
1128
+ totalNumberOfBytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)];
1129
+ }
1130
+
1131
+ if (_phase == AFHeaderPhase) {
1132
+ NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding];
1133
+ totalNumberOfBytesRead += [self readData:headersData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)];
1134
+ }
1135
+
1136
+ if (_phase == AFBodyPhase) {
1137
+ NSInteger numberOfBytesRead = 0;
1138
+
1139
+ numberOfBytesRead = [self.inputStream read:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)];
1140
+ if (numberOfBytesRead == -1) {
1141
+ return -1;
1142
+ } else {
1143
+ totalNumberOfBytesRead += numberOfBytesRead;
1144
+
1145
+ if ([self.inputStream streamStatus] >= NSStreamStatusAtEnd) {
1146
+ [self transitionToNextPhase];
1147
+ }
1148
+ }
1149
+ }
1150
+
1151
+ if (_phase == AFFinalBoundaryPhase) {
1152
+ NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]);
1153
+ totalNumberOfBytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)];
1154
+ }
1155
+
1156
+ return totalNumberOfBytesRead;
1157
+ }
1158
+
1159
+ - (NSInteger)readData:(NSData *)data
1160
+ intoBuffer:(uint8_t *)buffer
1161
+ maxLength:(NSUInteger)length
1162
+ {
1163
+ NSRange range = NSMakeRange((NSUInteger)_phaseReadOffset, MIN([data length] - ((NSUInteger)_phaseReadOffset), length));
1164
+ [data getBytes:buffer range:range];
1165
+
1166
+ _phaseReadOffset += range.length;
1167
+
1168
+ if (((NSUInteger)_phaseReadOffset) >= [data length]) {
1169
+ [self transitionToNextPhase];
1170
+ }
1171
+
1172
+ return (NSInteger)range.length;
1173
+ }
1174
+
1175
+ - (BOOL)transitionToNextPhase {
1176
+ if (![[NSThread currentThread] isMainThread]) {
1177
+ dispatch_sync(dispatch_get_main_queue(), ^{
1178
+ [self transitionToNextPhase];
1179
+ });
1180
+ return YES;
1181
+ }
1182
+
1183
+ switch (_phase) {
1184
+ case AFEncapsulationBoundaryPhase:
1185
+ _phase = AFHeaderPhase;
1186
+ break;
1187
+ case AFHeaderPhase:
1188
+ [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
1189
+ [self.inputStream open];
1190
+ _phase = AFBodyPhase;
1191
+ break;
1192
+ case AFBodyPhase:
1193
+ [self.inputStream close];
1194
+ _phase = AFFinalBoundaryPhase;
1195
+ break;
1196
+ case AFFinalBoundaryPhase:
1197
+ default:
1198
+ _phase = AFEncapsulationBoundaryPhase;
1199
+ break;
1200
+ }
1201
+ _phaseReadOffset = 0;
1202
+
1203
+ return YES;
1204
+ }
1205
+
1206
+ #pragma mark - NSCopying
1207
+
1208
+ - (instancetype)copyWithZone:(NSZone *)zone {
1209
+ AFHTTPBodyPart *bodyPart = [[[self class] allocWithZone:zone] init];
1210
+
1211
+ bodyPart.stringEncoding = self.stringEncoding;
1212
+ bodyPart.headers = self.headers;
1213
+ bodyPart.bodyContentLength = self.bodyContentLength;
1214
+ bodyPart.body = self.body;
1215
+ bodyPart.boundary = self.boundary;
1216
+
1217
+ return bodyPart;
1218
+ }
1219
+
1220
+ @end
1221
+
1222
+ #pragma mark -
1223
+
1224
+ @implementation AFJSONRequestSerializer
1225
+
1226
+ + (instancetype)serializer {
1227
+ return [self serializerWithWritingOptions:(NSJSONWritingOptions)0];
1228
+ }
1229
+
1230
+ + (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions
1231
+ {
1232
+ AFJSONRequestSerializer *serializer = [[self alloc] init];
1233
+ serializer.writingOptions = writingOptions;
1234
+
1235
+ return serializer;
1236
+ }
1237
+
1238
+ #pragma mark - AFURLRequestSerialization
1239
+
1240
+ - (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
1241
+ withParameters:(id)parameters
1242
+ error:(NSError *__autoreleasing *)error
1243
+ {
1244
+ NSParameterAssert(request);
1245
+
1246
+ if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) {
1247
+ return [super requestBySerializingRequest:request withParameters:parameters error:error];
1248
+ }
1249
+
1250
+ NSMutableURLRequest *mutableRequest = [request mutableCopy];
1251
+
1252
+ [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) {
1253
+ if (![request valueForHTTPHeaderField:field]) {
1254
+ [mutableRequest setValue:value forHTTPHeaderField:field];
1255
+ }
1256
+ }];
1257
+
1258
+ if (parameters) {
1259
+ if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) {
1260
+ [mutableRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
1261
+ }
1262
+
1263
+ if (![NSJSONSerialization isValidJSONObject:parameters]) {
1264
+ if (error) {
1265
+ NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"The `parameters` argument is not valid JSON.", @"AFNetworking", nil)};
1266
+ *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo];
1267
+ }
1268
+ return nil;
1269
+ }
1270
+
1271
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:self.writingOptions error:error];
1272
+
1273
+ if (!jsonData) {
1274
+ return nil;
1275
+ }
1276
+
1277
+ [mutableRequest setHTTPBody:jsonData];
1278
+ }
1279
+
1280
+ return mutableRequest;
1281
+ }
1282
+
1283
+ #pragma mark - NSSecureCoding
1284
+
1285
+ - (instancetype)initWithCoder:(NSCoder *)decoder {
1286
+ self = [super initWithCoder:decoder];
1287
+ if (!self) {
1288
+ return nil;
1289
+ }
1290
+
1291
+ self.writingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writingOptions))] unsignedIntegerValue];
1292
+
1293
+ return self;
1294
+ }
1295
+
1296
+ - (void)encodeWithCoder:(NSCoder *)coder {
1297
+ [super encodeWithCoder:coder];
1298
+
1299
+ [coder encodeObject:@(self.writingOptions) forKey:NSStringFromSelector(@selector(writingOptions))];
1300
+ }
1301
+
1302
+ #pragma mark - NSCopying
1303
+
1304
+ - (instancetype)copyWithZone:(NSZone *)zone {
1305
+ AFJSONRequestSerializer *serializer = [super copyWithZone:zone];
1306
+ serializer.writingOptions = self.writingOptions;
1307
+
1308
+ return serializer;
1309
+ }
1310
+
1311
+ @end
1312
+
1313
+ #pragma mark -
1314
+
1315
+ @implementation AFPropertyListRequestSerializer
1316
+
1317
+ + (instancetype)serializer {
1318
+ return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 writeOptions:0];
1319
+ }
1320
+
1321
+ + (instancetype)serializerWithFormat:(NSPropertyListFormat)format
1322
+ writeOptions:(NSPropertyListWriteOptions)writeOptions
1323
+ {
1324
+ AFPropertyListRequestSerializer *serializer = [[self alloc] init];
1325
+ serializer.format = format;
1326
+ serializer.writeOptions = writeOptions;
1327
+
1328
+ return serializer;
1329
+ }
1330
+
1331
+ #pragma mark - AFURLRequestSerializer
1332
+
1333
+ - (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
1334
+ withParameters:(id)parameters
1335
+ error:(NSError *__autoreleasing *)error
1336
+ {
1337
+ NSParameterAssert(request);
1338
+
1339
+ if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) {
1340
+ return [super requestBySerializingRequest:request withParameters:parameters error:error];
1341
+ }
1342
+
1343
+ NSMutableURLRequest *mutableRequest = [request mutableCopy];
1344
+
1345
+ [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) {
1346
+ if (![request valueForHTTPHeaderField:field]) {
1347
+ [mutableRequest setValue:value forHTTPHeaderField:field];
1348
+ }
1349
+ }];
1350
+
1351
+ if (parameters) {
1352
+ if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) {
1353
+ [mutableRequest setValue:@"application/x-plist" forHTTPHeaderField:@"Content-Type"];
1354
+ }
1355
+
1356
+ NSData *plistData = [NSPropertyListSerialization dataWithPropertyList:parameters format:self.format options:self.writeOptions error:error];
1357
+
1358
+ if (!plistData) {
1359
+ return nil;
1360
+ }
1361
+
1362
+ [mutableRequest setHTTPBody:plistData];
1363
+ }
1364
+
1365
+ return mutableRequest;
1366
+ }
1367
+
1368
+ #pragma mark - NSSecureCoding
1369
+
1370
+ - (instancetype)initWithCoder:(NSCoder *)decoder {
1371
+ self = [super initWithCoder:decoder];
1372
+ if (!self) {
1373
+ return nil;
1374
+ }
1375
+
1376
+ self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue];
1377
+ self.writeOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writeOptions))] unsignedIntegerValue];
1378
+
1379
+ return self;
1380
+ }
1381
+
1382
+ - (void)encodeWithCoder:(NSCoder *)coder {
1383
+ [super encodeWithCoder:coder];
1384
+
1385
+ [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))];
1386
+ [coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))];
1387
+ }
1388
+
1389
+ #pragma mark - NSCopying
1390
+
1391
+ - (instancetype)copyWithZone:(NSZone *)zone {
1392
+ AFPropertyListRequestSerializer *serializer = [super copyWithZone:zone];
1393
+ serializer.format = self.format;
1394
+ serializer.writeOptions = self.writeOptions;
1395
+
1396
+ return serializer;
1397
+ }
1398
+
1399
+ @end
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h ADDED
@@ -0,0 +1,313 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFURLResponseSerialization.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 <Foundation/Foundation.h>
23
+ #import <CoreGraphics/CoreGraphics.h>
24
+
25
+ NS_ASSUME_NONNULL_BEGIN
26
+
27
+ /**
28
+ Recursively removes `NSNull` values from a JSON object.
29
+ */
30
+ FOUNDATION_EXPORT id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions);
31
+
32
+ /**
33
+ The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data.
34
+
35
+ For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object.
36
+ */
37
+ @protocol AFURLResponseSerialization <NSObject, NSSecureCoding, NSCopying>
38
+
39
+ /**
40
+ The response object decoded from the data associated with a specified response.
41
+
42
+ @param response The response to be processed.
43
+ @param data The response data to be decoded.
44
+ @param error The error that occurred while attempting to decode the response data.
45
+
46
+ @return The object decoded from the specified response data.
47
+ */
48
+ - (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response
49
+ data:(nullable NSData *)data
50
+ error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW;
51
+
52
+ @end
53
+
54
+ #pragma mark -
55
+
56
+ /**
57
+ `AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
58
+
59
+ Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior.
60
+ */
61
+ @interface AFHTTPResponseSerializer : NSObject <AFURLResponseSerialization>
62
+
63
+ - (instancetype)init;
64
+
65
+ /**
66
+ Creates and returns a serializer with default configuration.
67
+ */
68
+ + (instancetype)serializer;
69
+
70
+ ///-----------------------------------------
71
+ /// @name Configuring Response Serialization
72
+ ///-----------------------------------------
73
+
74
+ /**
75
+ The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation.
76
+
77
+ See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
78
+ */
79
+ @property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes;
80
+
81
+ /**
82
+ The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation.
83
+ */
84
+ @property (nonatomic, copy, nullable) NSSet <NSString *> *acceptableContentTypes;
85
+
86
+ /**
87
+ Validates the specified response and data.
88
+
89
+ In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks.
90
+
91
+ @param response The response to be validated.
92
+ @param data The data associated with the response.
93
+ @param error The error that occurred while attempting to validate the response.
94
+
95
+ @return `YES` if the response is valid, otherwise `NO`.
96
+ */
97
+ - (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response
98
+ data:(nullable NSData *)data
99
+ error:(NSError * _Nullable __autoreleasing *)error;
100
+
101
+ @end
102
+
103
+ #pragma mark -
104
+
105
+
106
+ /**
107
+ `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses.
108
+
109
+ By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types:
110
+
111
+ - `application/json`
112
+ - `text/json`
113
+ - `text/javascript`
114
+
115
+ In RFC 7159 - Section 8.1, it states that JSON text is required to be encoded in UTF-8, UTF-16, or UTF-32, and the default encoding is UTF-8. NSJSONSerialization provides support for all the encodings listed in the specification, and recommends UTF-8 for efficiency. Using an unsupported encoding will result in serialization error. See the `NSJSONSerialization` documentation for more details.
116
+ */
117
+ @interface AFJSONResponseSerializer : AFHTTPResponseSerializer
118
+
119
+ - (instancetype)init;
120
+
121
+ /**
122
+ Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default.
123
+ */
124
+ @property (nonatomic, assign) NSJSONReadingOptions readingOptions;
125
+
126
+ /**
127
+ Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`.
128
+ */
129
+ @property (nonatomic, assign) BOOL removesKeysWithNullValues;
130
+
131
+ /**
132
+ Creates and returns a JSON serializer with specified reading and writing options.
133
+
134
+ @param readingOptions The specified JSON reading options.
135
+ */
136
+ + (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions;
137
+
138
+ @end
139
+
140
+ #pragma mark -
141
+
142
+ /**
143
+ `AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects.
144
+
145
+ By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types:
146
+
147
+ - `application/xml`
148
+ - `text/xml`
149
+ */
150
+ @interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer
151
+
152
+ @end
153
+
154
+ #pragma mark -
155
+
156
+ #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
157
+
158
+ /**
159
+ `AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects.
160
+
161
+ By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types:
162
+
163
+ - `application/xml`
164
+ - `text/xml`
165
+ */
166
+ @interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer
167
+
168
+ - (instancetype)init;
169
+
170
+ /**
171
+ Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSXMLDocument` documentation section "Input and Output Options". `0` by default.
172
+ */
173
+ @property (nonatomic, assign) NSUInteger options;
174
+
175
+ /**
176
+ Creates and returns an XML document serializer with the specified options.
177
+
178
+ @param mask The XML document options.
179
+ */
180
+ + (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask;
181
+
182
+ @end
183
+
184
+ #endif
185
+
186
+ #pragma mark -
187
+
188
+ /**
189
+ `AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects.
190
+
191
+ By default, `AFPropertyListResponseSerializer` accepts the following MIME types:
192
+
193
+ - `application/x-plist`
194
+ */
195
+ @interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer
196
+
197
+ - (instancetype)init;
198
+
199
+ /**
200
+ The property list format. Possible values are described in "NSPropertyListFormat".
201
+ */
202
+ @property (nonatomic, assign) NSPropertyListFormat format;
203
+
204
+ /**
205
+ The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions."
206
+ */
207
+ @property (nonatomic, assign) NSPropertyListReadOptions readOptions;
208
+
209
+ /**
210
+ Creates and returns a property list serializer with a specified format, read options, and write options.
211
+
212
+ @param format The property list format.
213
+ @param readOptions The property list reading options.
214
+ */
215
+ + (instancetype)serializerWithFormat:(NSPropertyListFormat)format
216
+ readOptions:(NSPropertyListReadOptions)readOptions;
217
+
218
+ @end
219
+
220
+ #pragma mark -
221
+
222
+ /**
223
+ `AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses.
224
+
225
+ By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage:
226
+
227
+ - `image/tiff`
228
+ - `image/jpeg`
229
+ - `image/gif`
230
+ - `image/png`
231
+ - `image/ico`
232
+ - `image/x-icon`
233
+ - `image/bmp`
234
+ - `image/x-bmp`
235
+ - `image/x-xbitmap`
236
+ - `image/x-win-bitmap`
237
+ */
238
+ @interface AFImageResponseSerializer : AFHTTPResponseSerializer
239
+
240
+ #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
241
+ /**
242
+ The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance.
243
+ */
244
+ @property (nonatomic, assign) CGFloat imageScale;
245
+
246
+ /**
247
+ Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default.
248
+ */
249
+ @property (nonatomic, assign) BOOL automaticallyInflatesResponseImage;
250
+ #endif
251
+
252
+ @end
253
+
254
+ #pragma mark -
255
+
256
+ /**
257
+ `AFCompoundSerializer` is a subclass of `AFHTTPResponseSerializer` that delegates the response serialization to the first `AFHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `AFHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer.
258
+ */
259
+ @interface AFCompoundResponseSerializer : AFHTTPResponseSerializer
260
+
261
+ /**
262
+ The component response serializers.
263
+ */
264
+ @property (readonly, nonatomic, copy) NSArray <id<AFURLResponseSerialization>> *responseSerializers;
265
+
266
+ /**
267
+ Creates and returns a compound serializer comprised of the specified response serializers.
268
+
269
+ @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`.
270
+ */
271
+ + (instancetype)compoundSerializerWithResponseSerializers:(NSArray <id<AFURLResponseSerialization>> *)responseSerializers;
272
+
273
+ @end
274
+
275
+ ///----------------
276
+ /// @name Constants
277
+ ///----------------
278
+
279
+ /**
280
+ ## Error Domains
281
+
282
+ The following error domain is predefined.
283
+
284
+ - `NSString * const AFURLResponseSerializationErrorDomain`
285
+
286
+ ### Constants
287
+
288
+ `AFURLResponseSerializationErrorDomain`
289
+ AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
290
+ */
291
+ FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain;
292
+
293
+ /**
294
+ ## User info dictionary keys
295
+
296
+ These keys may exist in the user info dictionary, in addition to those defined for NSError.
297
+
298
+ - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey`
299
+ - `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey`
300
+
301
+ ### Constants
302
+
303
+ `AFNetworkingOperationFailingURLResponseErrorKey`
304
+ The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`.
305
+
306
+ `AFNetworkingOperationFailingURLResponseDataErrorKey`
307
+ The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`.
308
+ */
309
+ FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey;
310
+
311
+ FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey;
312
+
313
+ NS_ASSUME_NONNULL_END
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m ADDED
@@ -0,0 +1,836 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFURLResponseSerialization.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 "AFURLResponseSerialization.h"
23
+
24
+ #import <TargetConditionals.h>
25
+
26
+ #if TARGET_OS_IOS
27
+ #import <UIKit/UIKit.h>
28
+ #elif TARGET_OS_WATCH
29
+ #import <WatchKit/WatchKit.h>
30
+ #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
31
+ #import <Cocoa/Cocoa.h>
32
+ #endif
33
+
34
+ NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response";
35
+ NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response";
36
+ NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data";
37
+
38
+ static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) {
39
+ if (!error) {
40
+ return underlyingError;
41
+ }
42
+
43
+ if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) {
44
+ return error;
45
+ }
46
+
47
+ NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy];
48
+ mutableUserInfo[NSUnderlyingErrorKey] = underlyingError;
49
+
50
+ return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo];
51
+ }
52
+
53
+ static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) {
54
+ if ([error.domain isEqualToString:domain] && error.code == code) {
55
+ return YES;
56
+ } else if (error.userInfo[NSUnderlyingErrorKey]) {
57
+ return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain);
58
+ }
59
+
60
+ return NO;
61
+ }
62
+
63
+ id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) {
64
+ if ([JSONObject isKindOfClass:[NSArray class]]) {
65
+ NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]];
66
+ for (id value in (NSArray *)JSONObject) {
67
+ if (![value isEqual:[NSNull null]]) {
68
+ [mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)];
69
+ }
70
+ }
71
+
72
+ return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray];
73
+ } else if ([JSONObject isKindOfClass:[NSDictionary class]]) {
74
+ NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONObject];
75
+ for (id <NSCopying> key in [(NSDictionary *)JSONObject allKeys]) {
76
+ id value = (NSDictionary *)JSONObject[key];
77
+ if (!value || [value isEqual:[NSNull null]]) {
78
+ [mutableDictionary removeObjectForKey:key];
79
+ } else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) {
80
+ mutableDictionary[key] = AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions);
81
+ }
82
+ }
83
+
84
+ return (readingOptions & NSJSONReadingMutableContainers) ? mutableDictionary : [NSDictionary dictionaryWithDictionary:mutableDictionary];
85
+ }
86
+
87
+ return JSONObject;
88
+ }
89
+
90
+ @implementation AFHTTPResponseSerializer
91
+
92
+ + (instancetype)serializer {
93
+ return [[self alloc] init];
94
+ }
95
+
96
+ - (instancetype)init {
97
+ self = [super init];
98
+ if (!self) {
99
+ return nil;
100
+ }
101
+
102
+ self.acceptableStatusCodes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)];
103
+ self.acceptableContentTypes = nil;
104
+
105
+ return self;
106
+ }
107
+
108
+ #pragma mark -
109
+
110
+ - (BOOL)validateResponse:(NSHTTPURLResponse *)response
111
+ data:(NSData *)data
112
+ error:(NSError * __autoreleasing *)error
113
+ {
114
+ BOOL responseIsValid = YES;
115
+ NSError *validationError = nil;
116
+
117
+ if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
118
+ if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]] &&
119
+ !([response MIMEType] == nil && [data length] == 0)) {
120
+
121
+ if ([data length] > 0 && [response URL]) {
122
+ NSMutableDictionary *mutableUserInfo = [@{
123
+ NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]],
124
+ NSURLErrorFailingURLErrorKey:[response URL],
125
+ AFNetworkingOperationFailingURLResponseErrorKey: response,
126
+ } mutableCopy];
127
+ if (data) {
128
+ mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
129
+ }
130
+
131
+ validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError);
132
+ }
133
+
134
+ responseIsValid = NO;
135
+ }
136
+
137
+ if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
138
+ NSMutableDictionary *mutableUserInfo = [@{
139
+ NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
140
+ NSURLErrorFailingURLErrorKey:[response URL],
141
+ AFNetworkingOperationFailingURLResponseErrorKey: response,
142
+ } mutableCopy];
143
+
144
+ if (data) {
145
+ mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
146
+ }
147
+
148
+ validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError);
149
+
150
+ responseIsValid = NO;
151
+ }
152
+ }
153
+
154
+ if (error && !responseIsValid) {
155
+ *error = validationError;
156
+ }
157
+
158
+ return responseIsValid;
159
+ }
160
+
161
+ #pragma mark - AFURLResponseSerialization
162
+
163
+ - (id)responseObjectForResponse:(NSURLResponse *)response
164
+ data:(NSData *)data
165
+ error:(NSError *__autoreleasing *)error
166
+ {
167
+ [self validateResponse:(NSHTTPURLResponse *)response data:data error:error];
168
+
169
+ return data;
170
+ }
171
+
172
+ #pragma mark - NSSecureCoding
173
+
174
+ + (BOOL)supportsSecureCoding {
175
+ return YES;
176
+ }
177
+
178
+ - (instancetype)initWithCoder:(NSCoder *)decoder {
179
+ self = [self init];
180
+ if (!self) {
181
+ return nil;
182
+ }
183
+
184
+ self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))];
185
+ self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))];
186
+
187
+ return self;
188
+ }
189
+
190
+ - (void)encodeWithCoder:(NSCoder *)coder {
191
+ [coder encodeObject:self.acceptableStatusCodes forKey:NSStringFromSelector(@selector(acceptableStatusCodes))];
192
+ [coder encodeObject:self.acceptableContentTypes forKey:NSStringFromSelector(@selector(acceptableContentTypes))];
193
+ }
194
+
195
+ #pragma mark - NSCopying
196
+
197
+ - (instancetype)copyWithZone:(NSZone *)zone {
198
+ AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
199
+ serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone];
200
+ serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone];
201
+
202
+ return serializer;
203
+ }
204
+
205
+ @end
206
+
207
+ #pragma mark -
208
+
209
+ @implementation AFJSONResponseSerializer
210
+
211
+ + (instancetype)serializer {
212
+ return [self serializerWithReadingOptions:(NSJSONReadingOptions)0];
213
+ }
214
+
215
+ + (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions {
216
+ AFJSONResponseSerializer *serializer = [[self alloc] init];
217
+ serializer.readingOptions = readingOptions;
218
+
219
+ return serializer;
220
+ }
221
+
222
+ - (instancetype)init {
223
+ self = [super init];
224
+ if (!self) {
225
+ return nil;
226
+ }
227
+
228
+ self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
229
+
230
+ return self;
231
+ }
232
+
233
+ #pragma mark - AFURLResponseSerialization
234
+
235
+ - (id)responseObjectForResponse:(NSURLResponse *)response
236
+ data:(NSData *)data
237
+ error:(NSError *__autoreleasing *)error
238
+ {
239
+ if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
240
+ if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
241
+ return nil;
242
+ }
243
+ }
244
+
245
+ // Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization.
246
+ // See https://github.com/rails/rails/issues/1742
247
+ BOOL isSpace = [data isEqualToData:[NSData dataWithBytes:" " length:1]];
248
+
249
+ if (data.length == 0 || isSpace) {
250
+ return nil;
251
+ }
252
+
253
+ NSError *serializationError = nil;
254
+
255
+ id responseObject = [NSJSONSerialization JSONObjectWithData:data options:self.readingOptions error:&serializationError];
256
+
257
+ if (!responseObject)
258
+ {
259
+ if (error) {
260
+ *error = AFErrorWithUnderlyingError(serializationError, *error);
261
+ }
262
+ return nil;
263
+ }
264
+
265
+ if (self.removesKeysWithNullValues) {
266
+ return AFJSONObjectByRemovingKeysWithNullValues(responseObject, self.readingOptions);
267
+ }
268
+
269
+ return responseObject;
270
+ }
271
+
272
+ #pragma mark - NSSecureCoding
273
+
274
+ + (BOOL)supportsSecureCoding {
275
+ return YES;
276
+ }
277
+
278
+ - (instancetype)initWithCoder:(NSCoder *)decoder {
279
+ self = [super initWithCoder:decoder];
280
+ if (!self) {
281
+ return nil;
282
+ }
283
+
284
+ self.readingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readingOptions))] unsignedIntegerValue];
285
+ self.removesKeysWithNullValues = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))] boolValue];
286
+
287
+ return self;
288
+ }
289
+
290
+ - (void)encodeWithCoder:(NSCoder *)coder {
291
+ [super encodeWithCoder:coder];
292
+
293
+ [coder encodeObject:@(self.readingOptions) forKey:NSStringFromSelector(@selector(readingOptions))];
294
+ [coder encodeObject:@(self.removesKeysWithNullValues) forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))];
295
+ }
296
+
297
+ #pragma mark - NSCopying
298
+
299
+ - (instancetype)copyWithZone:(NSZone *)zone {
300
+ AFJSONResponseSerializer *serializer = [super copyWithZone:zone];
301
+ serializer.readingOptions = self.readingOptions;
302
+ serializer.removesKeysWithNullValues = self.removesKeysWithNullValues;
303
+
304
+ return serializer;
305
+ }
306
+
307
+ @end
308
+
309
+ #pragma mark -
310
+
311
+ @implementation AFXMLParserResponseSerializer
312
+
313
+ + (instancetype)serializer {
314
+ AFXMLParserResponseSerializer *serializer = [[self alloc] init];
315
+
316
+ return serializer;
317
+ }
318
+
319
+ - (instancetype)init {
320
+ self = [super init];
321
+ if (!self) {
322
+ return nil;
323
+ }
324
+
325
+ self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil];
326
+
327
+ return self;
328
+ }
329
+
330
+ #pragma mark - AFURLResponseSerialization
331
+
332
+ - (id)responseObjectForResponse:(NSHTTPURLResponse *)response
333
+ data:(NSData *)data
334
+ error:(NSError *__autoreleasing *)error
335
+ {
336
+ if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
337
+ if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
338
+ return nil;
339
+ }
340
+ }
341
+
342
+ return [[NSXMLParser alloc] initWithData:data];
343
+ }
344
+
345
+ @end
346
+
347
+ #pragma mark -
348
+
349
+ #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
350
+
351
+ @implementation AFXMLDocumentResponseSerializer
352
+
353
+ + (instancetype)serializer {
354
+ return [self serializerWithXMLDocumentOptions:0];
355
+ }
356
+
357
+ + (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask {
358
+ AFXMLDocumentResponseSerializer *serializer = [[self alloc] init];
359
+ serializer.options = mask;
360
+
361
+ return serializer;
362
+ }
363
+
364
+ - (instancetype)init {
365
+ self = [super init];
366
+ if (!self) {
367
+ return nil;
368
+ }
369
+
370
+ self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil];
371
+
372
+ return self;
373
+ }
374
+
375
+ #pragma mark - AFURLResponseSerialization
376
+
377
+ - (id)responseObjectForResponse:(NSURLResponse *)response
378
+ data:(NSData *)data
379
+ error:(NSError *__autoreleasing *)error
380
+ {
381
+ if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
382
+ if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
383
+ return nil;
384
+ }
385
+ }
386
+
387
+ NSError *serializationError = nil;
388
+ NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data options:self.options error:&serializationError];
389
+
390
+ if (!document)
391
+ {
392
+ if (error) {
393
+ *error = AFErrorWithUnderlyingError(serializationError, *error);
394
+ }
395
+ return nil;
396
+ }
397
+
398
+ return document;
399
+ }
400
+
401
+ #pragma mark - NSSecureCoding
402
+
403
+ - (instancetype)initWithCoder:(NSCoder *)decoder {
404
+ self = [super initWithCoder:decoder];
405
+ if (!self) {
406
+ return nil;
407
+ }
408
+
409
+ self.options = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(options))] unsignedIntegerValue];
410
+
411
+ return self;
412
+ }
413
+
414
+ - (void)encodeWithCoder:(NSCoder *)coder {
415
+ [super encodeWithCoder:coder];
416
+
417
+ [coder encodeObject:@(self.options) forKey:NSStringFromSelector(@selector(options))];
418
+ }
419
+
420
+ #pragma mark - NSCopying
421
+
422
+ - (instancetype)copyWithZone:(NSZone *)zone {
423
+ AFXMLDocumentResponseSerializer *serializer = [super copyWithZone:zone];
424
+ serializer.options = self.options;
425
+
426
+ return serializer;
427
+ }
428
+
429
+ @end
430
+
431
+ #endif
432
+
433
+ #pragma mark -
434
+
435
+ @implementation AFPropertyListResponseSerializer
436
+
437
+ + (instancetype)serializer {
438
+ return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 readOptions:0];
439
+ }
440
+
441
+ + (instancetype)serializerWithFormat:(NSPropertyListFormat)format
442
+ readOptions:(NSPropertyListReadOptions)readOptions
443
+ {
444
+ AFPropertyListResponseSerializer *serializer = [[self alloc] init];
445
+ serializer.format = format;
446
+ serializer.readOptions = readOptions;
447
+
448
+ return serializer;
449
+ }
450
+
451
+ - (instancetype)init {
452
+ self = [super init];
453
+ if (!self) {
454
+ return nil;
455
+ }
456
+
457
+ self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/x-plist", nil];
458
+
459
+ return self;
460
+ }
461
+
462
+ #pragma mark - AFURLResponseSerialization
463
+
464
+ - (id)responseObjectForResponse:(NSURLResponse *)response
465
+ data:(NSData *)data
466
+ error:(NSError *__autoreleasing *)error
467
+ {
468
+ if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
469
+ if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
470
+ return nil;
471
+ }
472
+ }
473
+
474
+ if (!data) {
475
+ return nil;
476
+ }
477
+
478
+ NSError *serializationError = nil;
479
+
480
+ id responseObject = [NSPropertyListSerialization propertyListWithData:data options:self.readOptions format:NULL error:&serializationError];
481
+
482
+ if (!responseObject)
483
+ {
484
+ if (error) {
485
+ *error = AFErrorWithUnderlyingError(serializationError, *error);
486
+ }
487
+ return nil;
488
+ }
489
+
490
+ return responseObject;
491
+ }
492
+
493
+ #pragma mark - NSSecureCoding
494
+
495
+ + (BOOL)supportsSecureCoding {
496
+ return YES;
497
+ }
498
+
499
+ - (instancetype)initWithCoder:(NSCoder *)decoder {
500
+ self = [super initWithCoder:decoder];
501
+ if (!self) {
502
+ return nil;
503
+ }
504
+
505
+ self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue];
506
+ self.readOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readOptions))] unsignedIntegerValue];
507
+
508
+ return self;
509
+ }
510
+
511
+ - (void)encodeWithCoder:(NSCoder *)coder {
512
+ [super encodeWithCoder:coder];
513
+
514
+ [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))];
515
+ [coder encodeObject:@(self.readOptions) forKey:NSStringFromSelector(@selector(readOptions))];
516
+ }
517
+
518
+ #pragma mark - NSCopying
519
+
520
+ - (instancetype)copyWithZone:(NSZone *)zone {
521
+ AFPropertyListResponseSerializer *serializer = [super copyWithZone:zone];
522
+ serializer.format = self.format;
523
+ serializer.readOptions = self.readOptions;
524
+
525
+ return serializer;
526
+ }
527
+
528
+ @end
529
+
530
+ #pragma mark -
531
+
532
+ #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
533
+ #import <CoreGraphics/CoreGraphics.h>
534
+ #import <UIKit/UIKit.h>
535
+
536
+ @interface UIImage (AFNetworkingSafeImageLoading)
537
+ + (UIImage *)af_safeImageWithData:(NSData *)data;
538
+ @end
539
+
540
+ static NSLock* imageLock = nil;
541
+
542
+ @implementation UIImage (AFNetworkingSafeImageLoading)
543
+
544
+ + (UIImage *)af_safeImageWithData:(NSData *)data {
545
+ UIImage* image = nil;
546
+ static dispatch_once_t onceToken;
547
+ dispatch_once(&onceToken, ^{
548
+ imageLock = [[NSLock alloc] init];
549
+ });
550
+
551
+ [imageLock lock];
552
+ image = [UIImage imageWithData:data];
553
+ [imageLock unlock];
554
+ return image;
555
+ }
556
+
557
+ @end
558
+
559
+ static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) {
560
+ UIImage *image = [UIImage af_safeImageWithData:data];
561
+ if (image.images) {
562
+ return image;
563
+ }
564
+
565
+ return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation];
566
+ }
567
+
568
+ static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) {
569
+ if (!data || [data length] == 0) {
570
+ return nil;
571
+ }
572
+
573
+ CGImageRef imageRef = NULL;
574
+ CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data);
575
+
576
+ if ([response.MIMEType isEqualToString:@"image/png"]) {
577
+ imageRef = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault);
578
+ } else if ([response.MIMEType isEqualToString:@"image/jpeg"]) {
579
+ imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault);
580
+
581
+ if (imageRef) {
582
+ CGColorSpaceRef imageColorSpace = CGImageGetColorSpace(imageRef);
583
+ CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(imageColorSpace);
584
+
585
+ // CGImageCreateWithJPEGDataProvider does not properly handle CMKY, so fall back to AFImageWithDataAtScale
586
+ if (imageColorSpaceModel == kCGColorSpaceModelCMYK) {
587
+ CGImageRelease(imageRef);
588
+ imageRef = NULL;
589
+ }
590
+ }
591
+ }
592
+
593
+ CGDataProviderRelease(dataProvider);
594
+
595
+ UIImage *image = AFImageWithDataAtScale(data, scale);
596
+ if (!imageRef) {
597
+ if (image.images || !image) {
598
+ return image;
599
+ }
600
+
601
+ imageRef = CGImageCreateCopy([image CGImage]);
602
+ if (!imageRef) {
603
+ return nil;
604
+ }
605
+ }
606
+
607
+ size_t width = CGImageGetWidth(imageRef);
608
+ size_t height = CGImageGetHeight(imageRef);
609
+ size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef);
610
+
611
+ if (width * height > 1024 * 1024 || bitsPerComponent > 8) {
612
+ CGImageRelease(imageRef);
613
+
614
+ return image;
615
+ }
616
+
617
+ // CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate
618
+ size_t bytesPerRow = 0;
619
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
620
+ CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace);
621
+ CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
622
+
623
+ if (colorSpaceModel == kCGColorSpaceModelRGB) {
624
+ uint32_t alpha = (bitmapInfo & kCGBitmapAlphaInfoMask);
625
+ #pragma clang diagnostic push
626
+ #pragma clang diagnostic ignored "-Wassign-enum"
627
+ if (alpha == kCGImageAlphaNone) {
628
+ bitmapInfo &= ~kCGBitmapAlphaInfoMask;
629
+ bitmapInfo |= kCGImageAlphaNoneSkipFirst;
630
+ } else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) {
631
+ bitmapInfo &= ~kCGBitmapAlphaInfoMask;
632
+ bitmapInfo |= kCGImageAlphaPremultipliedFirst;
633
+ }
634
+ #pragma clang diagnostic pop
635
+ }
636
+
637
+ CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo);
638
+
639
+ CGColorSpaceRelease(colorSpace);
640
+
641
+ if (!context) {
642
+ CGImageRelease(imageRef);
643
+
644
+ return image;
645
+ }
646
+
647
+ CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), imageRef);
648
+ CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context);
649
+
650
+ CGContextRelease(context);
651
+
652
+ UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:image.imageOrientation];
653
+
654
+ CGImageRelease(inflatedImageRef);
655
+ CGImageRelease(imageRef);
656
+
657
+ return inflatedImage;
658
+ }
659
+ #endif
660
+
661
+
662
+ @implementation AFImageResponseSerializer
663
+
664
+ - (instancetype)init {
665
+ self = [super init];
666
+ if (!self) {
667
+ return nil;
668
+ }
669
+
670
+ self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon", @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap", nil];
671
+
672
+ #if TARGET_OS_IOS || TARGET_OS_TV
673
+ self.imageScale = [[UIScreen mainScreen] scale];
674
+ self.automaticallyInflatesResponseImage = YES;
675
+ #elif TARGET_OS_WATCH
676
+ self.imageScale = [[WKInterfaceDevice currentDevice] screenScale];
677
+ self.automaticallyInflatesResponseImage = YES;
678
+ #endif
679
+
680
+ return self;
681
+ }
682
+
683
+ #pragma mark - AFURLResponseSerializer
684
+
685
+ - (id)responseObjectForResponse:(NSURLResponse *)response
686
+ data:(NSData *)data
687
+ error:(NSError *__autoreleasing *)error
688
+ {
689
+ if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
690
+ if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
691
+ return nil;
692
+ }
693
+ }
694
+
695
+ #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
696
+ if (self.automaticallyInflatesResponseImage) {
697
+ return AFInflatedImageFromResponseWithDataAtScale((NSHTTPURLResponse *)response, data, self.imageScale);
698
+ } else {
699
+ return AFImageWithDataAtScale(data, self.imageScale);
700
+ }
701
+ #else
702
+ // Ensure that the image is set to it's correct pixel width and height
703
+ NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:data];
704
+ NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])];
705
+ [image addRepresentation:bitimage];
706
+
707
+ return image;
708
+ #endif
709
+
710
+ return nil;
711
+ }
712
+
713
+ #pragma mark - NSSecureCoding
714
+
715
+ + (BOOL)supportsSecureCoding {
716
+ return YES;
717
+ }
718
+
719
+ - (instancetype)initWithCoder:(NSCoder *)decoder {
720
+ self = [super initWithCoder:decoder];
721
+ if (!self) {
722
+ return nil;
723
+ }
724
+
725
+ #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
726
+ NSNumber *imageScale = [decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(imageScale))];
727
+ #if CGFLOAT_IS_DOUBLE
728
+ self.imageScale = [imageScale doubleValue];
729
+ #else
730
+ self.imageScale = [imageScale floatValue];
731
+ #endif
732
+
733
+ self.automaticallyInflatesResponseImage = [decoder decodeBoolForKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))];
734
+ #endif
735
+
736
+ return self;
737
+ }
738
+
739
+ - (void)encodeWithCoder:(NSCoder *)coder {
740
+ [super encodeWithCoder:coder];
741
+
742
+ #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
743
+ [coder encodeObject:@(self.imageScale) forKey:NSStringFromSelector(@selector(imageScale))];
744
+ [coder encodeBool:self.automaticallyInflatesResponseImage forKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))];
745
+ #endif
746
+ }
747
+
748
+ #pragma mark - NSCopying
749
+
750
+ - (instancetype)copyWithZone:(NSZone *)zone {
751
+ AFImageResponseSerializer *serializer = [super copyWithZone:zone];
752
+
753
+ #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
754
+ serializer.imageScale = self.imageScale;
755
+ serializer.automaticallyInflatesResponseImage = self.automaticallyInflatesResponseImage;
756
+ #endif
757
+
758
+ return serializer;
759
+ }
760
+
761
+ @end
762
+
763
+ #pragma mark -
764
+
765
+ @interface AFCompoundResponseSerializer ()
766
+ @property (readwrite, nonatomic, copy) NSArray *responseSerializers;
767
+ @end
768
+
769
+ @implementation AFCompoundResponseSerializer
770
+
771
+ + (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers {
772
+ AFCompoundResponseSerializer *serializer = [[self alloc] init];
773
+ serializer.responseSerializers = responseSerializers;
774
+
775
+ return serializer;
776
+ }
777
+
778
+ #pragma mark - AFURLResponseSerialization
779
+
780
+ - (id)responseObjectForResponse:(NSURLResponse *)response
781
+ data:(NSData *)data
782
+ error:(NSError *__autoreleasing *)error
783
+ {
784
+ for (id <AFURLResponseSerialization> serializer in self.responseSerializers) {
785
+ if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) {
786
+ continue;
787
+ }
788
+
789
+ NSError *serializerError = nil;
790
+ id responseObject = [serializer responseObjectForResponse:response data:data error:&serializerError];
791
+ if (responseObject) {
792
+ if (error) {
793
+ *error = AFErrorWithUnderlyingError(serializerError, *error);
794
+ }
795
+
796
+ return responseObject;
797
+ }
798
+ }
799
+
800
+ return [super responseObjectForResponse:response data:data error:error];
801
+ }
802
+
803
+ #pragma mark - NSSecureCoding
804
+
805
+ + (BOOL)supportsSecureCoding {
806
+ return YES;
807
+ }
808
+
809
+ - (instancetype)initWithCoder:(NSCoder *)decoder {
810
+ self = [super initWithCoder:decoder];
811
+ if (!self) {
812
+ return nil;
813
+ }
814
+
815
+ NSSet *classes = [NSSet setWithArray:@[[NSArray class], [AFHTTPResponseSerializer <AFURLResponseSerialization> class]]];
816
+ self.responseSerializers = [decoder decodeObjectOfClasses:classes forKey:NSStringFromSelector(@selector(responseSerializers))];
817
+
818
+ return self;
819
+ }
820
+
821
+ - (void)encodeWithCoder:(NSCoder *)coder {
822
+ [super encodeWithCoder:coder];
823
+
824
+ [coder encodeObject:self.responseSerializers forKey:NSStringFromSelector(@selector(responseSerializers))];
825
+ }
826
+
827
+ #pragma mark - NSCopying
828
+
829
+ - (instancetype)copyWithZone:(NSZone *)zone {
830
+ AFCompoundResponseSerializer *serializer = [super copyWithZone:zone];
831
+ serializer.responseSerializers = self.responseSerializers;
832
+
833
+ return serializer;
834
+ }
835
+
836
+ @end
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h ADDED
@@ -0,0 +1,516 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFURLSessionManager.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
+
23
+ #import <Foundation/Foundation.h>
24
+
25
+ #import "AFURLResponseSerialization.h"
26
+ #import "AFURLRequestSerialization.h"
27
+ #import "AFSecurityPolicy.h"
28
+ #import "AFCompatibilityMacros.h"
29
+ #if !TARGET_OS_WATCH
30
+ #import "AFNetworkReachabilityManager.h"
31
+ #endif
32
+
33
+ /**
34
+ `AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to `<NSURLSessionTaskDelegate>`, `<NSURLSessionDataDelegate>`, `<NSURLSessionDownloadDelegate>`, and `<NSURLSessionDelegate>`.
35
+
36
+ ## Subclassing Notes
37
+
38
+ This is the base class for `AFHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `AFURLSessionManager` specifically for HTTP, consider subclassing `AFHTTPSessionManager` instead.
39
+
40
+ ## NSURLSession & NSURLSessionTask Delegate Methods
41
+
42
+ `AFURLSessionManager` implements the following delegate methods:
43
+
44
+ ### `NSURLSessionDelegate`
45
+
46
+ - `URLSession:didBecomeInvalidWithError:`
47
+ - `URLSession:didReceiveChallenge:completionHandler:`
48
+ - `URLSessionDidFinishEventsForBackgroundURLSession:`
49
+
50
+ ### `NSURLSessionTaskDelegate`
51
+
52
+ - `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`
53
+ - `URLSession:task:didReceiveChallenge:completionHandler:`
54
+ - `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`
55
+ - `URLSession:task:needNewBodyStream:`
56
+ - `URLSession:task:didCompleteWithError:`
57
+
58
+ ### `NSURLSessionDataDelegate`
59
+
60
+ - `URLSession:dataTask:didReceiveResponse:completionHandler:`
61
+ - `URLSession:dataTask:didBecomeDownloadTask:`
62
+ - `URLSession:dataTask:didReceiveData:`
63
+ - `URLSession:dataTask:willCacheResponse:completionHandler:`
64
+
65
+ ### `NSURLSessionDownloadDelegate`
66
+
67
+ - `URLSession:downloadTask:didFinishDownloadingToURL:`
68
+ - `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:`
69
+ - `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`
70
+
71
+ If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first.
72
+
73
+ ## Network Reachability Monitoring
74
+
75
+ Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details.
76
+
77
+ ## NSCoding Caveats
78
+
79
+ - Encoded managers do not include any block properties. Be sure to set delegate callback blocks when using `-initWithCoder:` or `NSKeyedUnarchiver`.
80
+
81
+ ## NSCopying Caveats
82
+
83
+ - `-copy` and `-copyWithZone:` return a new manager with a new `NSURLSession` created from the configuration of the original.
84
+ - Operation copies do not include any delegate callback blocks, as they often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ session manager when copied.
85
+
86
+ @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance.
87
+ */
88
+
89
+ NS_ASSUME_NONNULL_BEGIN
90
+
91
+ @interface AFURLSessionManager : NSObject <NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate, NSSecureCoding, NSCopying>
92
+
93
+ /**
94
+ The managed session.
95
+ */
96
+ @property (readonly, nonatomic, strong) NSURLSession *session;
97
+
98
+ /**
99
+ The operation queue on which delegate callbacks are run.
100
+ */
101
+ @property (readonly, nonatomic, strong) NSOperationQueue *operationQueue;
102
+
103
+ /**
104
+ Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`.
105
+
106
+ @warning `responseSerializer` must not be `nil`.
107
+ */
108
+ @property (nonatomic, strong) id <AFURLResponseSerialization> responseSerializer;
109
+
110
+ ///-------------------------------
111
+ /// @name Managing Security Policy
112
+ ///-------------------------------
113
+
114
+ /**
115
+ The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified.
116
+ */
117
+ @property (nonatomic, strong) AFSecurityPolicy *securityPolicy;
118
+
119
+ #if !TARGET_OS_WATCH
120
+ ///--------------------------------------
121
+ /// @name Monitoring Network Reachability
122
+ ///--------------------------------------
123
+
124
+ /**
125
+ The network reachability manager. `AFURLSessionManager` uses the `sharedManager` by default.
126
+ */
127
+ @property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager;
128
+ #endif
129
+
130
+ ///----------------------------
131
+ /// @name Getting Session Tasks
132
+ ///----------------------------
133
+
134
+ /**
135
+ The data, upload, and download tasks currently run by the managed session.
136
+ */
137
+ @property (readonly, nonatomic, strong) NSArray <NSURLSessionTask *> *tasks;
138
+
139
+ /**
140
+ The data tasks currently run by the managed session.
141
+ */
142
+ @property (readonly, nonatomic, strong) NSArray <NSURLSessionDataTask *> *dataTasks;
143
+
144
+ /**
145
+ The upload tasks currently run by the managed session.
146
+ */
147
+ @property (readonly, nonatomic, strong) NSArray <NSURLSessionUploadTask *> *uploadTasks;
148
+
149
+ /**
150
+ The download tasks currently run by the managed session.
151
+ */
152
+ @property (readonly, nonatomic, strong) NSArray <NSURLSessionDownloadTask *> *downloadTasks;
153
+
154
+ ///-------------------------------
155
+ /// @name Managing Callback Queues
156
+ ///-------------------------------
157
+
158
+ /**
159
+ The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used.
160
+ */
161
+ @property (nonatomic, strong, nullable) dispatch_queue_t completionQueue;
162
+
163
+ /**
164
+ The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used.
165
+ */
166
+ @property (nonatomic, strong, nullable) dispatch_group_t completionGroup;
167
+
168
+ ///---------------------
169
+ /// @name Initialization
170
+ ///---------------------
171
+
172
+ /**
173
+ Creates and returns a manager for a session created with the specified configuration. This is the designated initializer.
174
+
175
+ @param configuration The configuration used to create the managed session.
176
+
177
+ @return A manager for a newly-created session.
178
+ */
179
+ - (instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
180
+
181
+ /**
182
+ Invalidates the managed session, optionally canceling pending tasks and optionally resets given session.
183
+
184
+ @param cancelPendingTasks Whether or not to cancel pending tasks.
185
+ @param resetSession Whether or not to reset the session of the manager.
186
+ */
187
+ - (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks resetSession:(BOOL)resetSession;
188
+
189
+ ///-------------------------
190
+ /// @name Running Data Tasks
191
+ ///-------------------------
192
+
193
+ /**
194
+ Creates an `NSURLSessionDataTask` with the specified request.
195
+
196
+ @param request The HTTP request for the request.
197
+ @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
198
+ @param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
199
+ @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
200
+ */
201
+ - (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
202
+ uploadProgress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
203
+ downloadProgress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
204
+ completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
205
+
206
+ ///---------------------------
207
+ /// @name Running Upload Tasks
208
+ ///---------------------------
209
+
210
+ /**
211
+ Creates an `NSURLSessionUploadTask` with the specified request for a local file.
212
+
213
+ @param request The HTTP request for the request.
214
+ @param fileURL A URL to the local file to be uploaded.
215
+ @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
216
+ @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
217
+
218
+ @see `attemptsToRecreateUploadTasksForBackgroundSessions`
219
+ */
220
+ - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
221
+ fromFile:(NSURL *)fileURL
222
+ progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
223
+ completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
224
+
225
+ /**
226
+ Creates an `NSURLSessionUploadTask` with the specified request for an HTTP body.
227
+
228
+ @param request The HTTP request for the request.
229
+ @param bodyData A data object containing the HTTP body to be uploaded.
230
+ @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
231
+ @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
232
+ */
233
+ - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
234
+ fromData:(nullable NSData *)bodyData
235
+ progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
236
+ completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
237
+
238
+ /**
239
+ Creates an `NSURLSessionUploadTask` with the specified streaming request.
240
+
241
+ @param request The HTTP request for the request.
242
+ @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
243
+ @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
244
+ */
245
+ - (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request
246
+ progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
247
+ completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
248
+
249
+ ///-----------------------------
250
+ /// @name Running Download Tasks
251
+ ///-----------------------------
252
+
253
+ /**
254
+ Creates an `NSURLSessionDownloadTask` with the specified request.
255
+
256
+ @param request The HTTP request for the request.
257
+ @param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
258
+ @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL.
259
+ @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any.
260
+
261
+ @warning If using a background `NSURLSessionConfiguration` on iOS, these blocks will be lost when the app is terminated. Background sessions may prefer to use `-setDownloadTaskDidFinishDownloadingBlock:` to specify the URL for saving the downloaded file, rather than the destination block of this method.
262
+ */
263
+ - (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request
264
+ progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
265
+ destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
266
+ completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler;
267
+
268
+ /**
269
+ Creates an `NSURLSessionDownloadTask` with the specified resume data.
270
+
271
+ @param resumeData The data used to resume downloading.
272
+ @param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
273
+ @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL.
274
+ @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any.
275
+ */
276
+ - (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData
277
+ progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
278
+ destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
279
+ completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler;
280
+
281
+ ///---------------------------------
282
+ /// @name Getting Progress for Tasks
283
+ ///---------------------------------
284
+
285
+ /**
286
+ Returns the upload progress of the specified task.
287
+
288
+ @param task The session task. Must not be `nil`.
289
+
290
+ @return An `NSProgress` object reporting the upload progress of a task, or `nil` if the progress is unavailable.
291
+ */
292
+ - (nullable NSProgress *)uploadProgressForTask:(NSURLSessionTask *)task;
293
+
294
+ /**
295
+ Returns the download progress of the specified task.
296
+
297
+ @param task The session task. Must not be `nil`.
298
+
299
+ @return An `NSProgress` object reporting the download progress of a task, or `nil` if the progress is unavailable.
300
+ */
301
+ - (nullable NSProgress *)downloadProgressForTask:(NSURLSessionTask *)task;
302
+
303
+ ///-----------------------------------------
304
+ /// @name Setting Session Delegate Callbacks
305
+ ///-----------------------------------------
306
+
307
+ /**
308
+ Sets a block to be executed when the managed session becomes invalid, as handled by the `NSURLSessionDelegate` method `URLSession:didBecomeInvalidWithError:`.
309
+
310
+ @param block A block object to be executed when the managed session becomes invalid. The block has no return value, and takes two arguments: the session, and the error related to the cause of invalidation.
311
+ */
312
+ - (void)setSessionDidBecomeInvalidBlock:(nullable void (^)(NSURLSession *session, NSError *error))block;
313
+
314
+ /**
315
+ Sets a block to be executed when a connection level authentication challenge has occurred, as handled by the `NSURLSessionDelegate` method `URLSession:didReceiveChallenge:completionHandler:`.
316
+
317
+ @param block A block object to be executed when a connection level authentication challenge has occurred. The block returns the disposition of the authentication challenge, and takes three arguments: the session, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge.
318
+
319
+ @warning Implementing a session authentication challenge handler yourself totally bypasses AFNetworking's security policy defined in `AFSecurityPolicy`. Make sure you fully understand the implications before implementing a custom session authentication challenge handler. If you do not want to bypass AFNetworking's security policy, use `setTaskDidReceiveAuthenticationChallengeBlock:` instead.
320
+
321
+ @see -securityPolicy
322
+ @see -setTaskDidReceiveAuthenticationChallengeBlock:
323
+ */
324
+ - (void)setSessionDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block;
325
+
326
+ ///--------------------------------------
327
+ /// @name Setting Task Delegate Callbacks
328
+ ///--------------------------------------
329
+
330
+ /**
331
+ Sets a block to be executed when a task requires a new request body stream to send to the remote server, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:needNewBodyStream:`.
332
+
333
+ @param block A block object to be executed when a task requires a new request body stream.
334
+ */
335
+ - (void)setTaskNeedNewBodyStreamBlock:(nullable NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block;
336
+
337
+ /**
338
+ Sets a block to be executed when an HTTP request is attempting to perform a redirection to a different URL, as handled by the `NSURLSessionTaskDelegate` method `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`.
339
+
340
+ @param block A block object to be executed when an HTTP request is attempting to perform a redirection to a different URL. The block returns the request to be made for the redirection, and takes four arguments: the session, the task, the redirection response, and the request corresponding to the redirection response.
341
+ */
342
+ - (void)setTaskWillPerformHTTPRedirectionBlock:(nullable NSURLRequest * _Nullable (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block;
343
+
344
+ /**
345
+ Sets a block to be executed when a session task has received a request specific authentication challenge, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didReceiveChallenge:completionHandler:`.
346
+
347
+ @param authenticationChallengeHandler A block object to be executed when a session task has received a request specific authentication challenge.
348
+
349
+ When implementing an authentication challenge handler, you should check the authentication method first (`challenge.protectionSpace.authenticationMethod `) to decide if you want to handle the authentication challenge yourself or if you want AFNetworking to handle it. If you want AFNetworking to handle the authentication challenge, just return `@(NSURLSessionAuthChallengePerformDefaultHandling)`. For example, you certainly want AFNetworking to handle certificate validation (i.e. authentication method == `NSURLAuthenticationMethodServerTrust`) as defined by the security policy. If you want to handle the challenge yourself, you have four options:
350
+
351
+ 1. Return `nil` from the authentication challenge handler. You **MUST** call the completion handler with a disposition and credentials yourself. Use this if you need to present a user interface to let the user enter their credentials.
352
+ 2. Return an `NSError` object from the authentication challenge handler. You **MUST NOT** call the completion handler when returning an `NSError `. The returned error will be reported in the completion handler of the task. Use this if you need to abort an authentication challenge with a specific error.
353
+ 3. Return an `NSURLCredential` object from the authentication challenge handler. You **MUST NOT** call the completion handler when returning an `NSURLCredential`. The returned credentials will be used to fulfil the challenge. Use this when you can get credentials without presenting a user interface.
354
+ 4. Return an `NSNumber` object wrapping an `NSURLSessionAuthChallengeDisposition`. Supported values are `@(NSURLSessionAuthChallengePerformDefaultHandling)`, `@(NSURLSessionAuthChallengeCancelAuthenticationChallenge)` and `@(NSURLSessionAuthChallengeRejectProtectionSpace)`. You **MUST NOT** call the completion handler when returning an `NSNumber`.
355
+
356
+ If you return anything else from the authentication challenge handler, an exception will be thrown.
357
+
358
+ For more information about how URL sessions handle the different types of authentication challenges, see [NSURLSession](https://developer.apple.com/reference/foundation/nsurlsession?language=objc) and [URL Session Programming Guide](https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html).
359
+
360
+ @see -securityPolicy
361
+ */
362
+ - (void)setAuthenticationChallengeHandler:(id (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, void (^completionHandler)(NSURLSessionAuthChallengeDisposition , NSURLCredential * _Nullable)))authenticationChallengeHandler;
363
+
364
+ /**
365
+ Sets a block to be executed periodically to track upload progress, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`.
366
+
367
+ @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes five arguments: the session, the task, the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread.
368
+ */
369
+ - (void)setTaskDidSendBodyDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block;
370
+
371
+ /**
372
+ Sets a block to be executed as the last message related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didCompleteWithError:`.
373
+
374
+ @param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any error that occurred in the process of executing the task.
375
+ */
376
+ - (void)setTaskDidCompleteBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSError * _Nullable error))block;
377
+
378
+ /**
379
+ Sets a block to be executed when metrics are finalized related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didFinishCollectingMetrics:`.
380
+
381
+ @param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any metrics that were collected in the process of executing the task.
382
+ */
383
+ #if AF_CAN_INCLUDE_SESSION_TASK_METRICS
384
+ - (void)setTaskDidFinishCollectingMetricsBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSURLSessionTaskMetrics * _Nullable metrics))block AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10));
385
+ #endif
386
+ ///-------------------------------------------
387
+ /// @name Setting Data Task Delegate Callbacks
388
+ ///-------------------------------------------
389
+
390
+ /**
391
+ Sets a block to be executed when a data task has received a response, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveResponse:completionHandler:`.
392
+
393
+ @param block A block object to be executed when a data task has received a response. The block returns the disposition of the session response, and takes three arguments: the session, the data task, and the received response.
394
+ */
395
+ - (void)setDataTaskDidReceiveResponseBlock:(nullable NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block;
396
+
397
+ /**
398
+ Sets a block to be executed when a data task has become a download task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didBecomeDownloadTask:`.
399
+
400
+ @param block A block object to be executed when a data task has become a download task. The block has no return value, and takes three arguments: the session, the data task, and the download task it has become.
401
+ */
402
+ - (void)setDataTaskDidBecomeDownloadTaskBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block;
403
+
404
+ /**
405
+ Sets a block to be executed when a data task receives data, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveData:`.
406
+
407
+ @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the session, the data task, and the data received. This block may be called multiple times, and will execute on the session manager operation queue.
408
+ */
409
+ - (void)setDataTaskDidReceiveDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block;
410
+
411
+ /**
412
+ Sets a block to be executed to determine the caching behavior of a data task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:willCacheResponse:completionHandler:`.
413
+
414
+ @param block A block object to be executed to determine the caching behavior of a data task. The block returns the response to cache, and takes three arguments: the session, the data task, and the proposed cached URL response.
415
+ */
416
+ - (void)setDataTaskWillCacheResponseBlock:(nullable NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block;
417
+
418
+ /**
419
+ Sets a block to be executed once all messages enqueued for a session have been delivered, as handled by the `NSURLSessionDataDelegate` method `URLSessionDidFinishEventsForBackgroundURLSession:`.
420
+
421
+ @param block A block object to be executed once all messages enqueued for a session have been delivered. The block has no return value and takes a single argument: the session.
422
+ */
423
+ - (void)setDidFinishEventsForBackgroundURLSessionBlock:(nullable void (^)(NSURLSession *session))block AF_API_UNAVAILABLE(macos);
424
+
425
+ ///-----------------------------------------------
426
+ /// @name Setting Download Task Delegate Callbacks
427
+ ///-----------------------------------------------
428
+
429
+ /**
430
+ Sets a block to be executed when a download task has completed a download, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didFinishDownloadingToURL:`.
431
+
432
+ @param block A block object to be executed when a download task has completed. The block returns the URL the download should be moved to, and takes three arguments: the session, the download task, and the temporary location of the downloaded file. If the file manager encounters an error while attempting to move the temporary file to the destination, an `AFURLSessionDownloadTaskDidFailToMoveFileNotification` will be posted, with the download task as its object, and the user info of the error.
433
+ */
434
+ - (void)setDownloadTaskDidFinishDownloadingBlock:(nullable NSURL * _Nullable (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block;
435
+
436
+ /**
437
+ Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:`.
438
+
439
+ @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes five arguments: the session, the download task, the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the session manager operation queue.
440
+ */
441
+ - (void)setDownloadTaskDidWriteDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block;
442
+
443
+ /**
444
+ Sets a block to be executed when a download task has been resumed, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`.
445
+
446
+ @param block A block object to be executed when a download task has been resumed. The block has no return value and takes four arguments: the session, the download task, the file offset of the resumed download, and the total number of bytes expected to be downloaded.
447
+ */
448
+ - (void)setDownloadTaskDidResumeBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block;
449
+
450
+ @end
451
+
452
+ ///--------------------
453
+ /// @name Notifications
454
+ ///--------------------
455
+
456
+ /**
457
+ Posted when a task resumes.
458
+ */
459
+ FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidResumeNotification;
460
+
461
+ /**
462
+ Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task.
463
+ */
464
+ FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteNotification;
465
+
466
+ /**
467
+ Posted when a task suspends its execution.
468
+ */
469
+ FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidSuspendNotification;
470
+
471
+ /**
472
+ Posted when a session is invalidated.
473
+ */
474
+ FOUNDATION_EXPORT NSString * const AFURLSessionDidInvalidateNotification;
475
+
476
+ /**
477
+ Posted when a session download task finished moving the temporary download file to a specified destination successfully.
478
+ */
479
+ FOUNDATION_EXPORT NSString * const AFURLSessionDownloadTaskDidMoveFileSuccessfullyNotification;
480
+
481
+ /**
482
+ Posted when a session download task encountered an error when moving the temporary download file to a specified destination.
483
+ */
484
+ FOUNDATION_EXPORT NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification;
485
+
486
+ /**
487
+ The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if response data exists for the task.
488
+ */
489
+ FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseDataKey;
490
+
491
+ /**
492
+ The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the response was serialized.
493
+ */
494
+ FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey;
495
+
496
+ /**
497
+ The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the task has an associated response serializer.
498
+ */
499
+ FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey;
500
+
501
+ /**
502
+ The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an the response data has been stored directly to disk.
503
+ */
504
+ FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteAssetPathKey;
505
+
506
+ /**
507
+ Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an error exists.
508
+ */
509
+ FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteErrorKey;
510
+
511
+ /**
512
+ The session task metrics taken from the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteSessionTaskMetrics`
513
+ */
514
+ FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteSessionTaskMetrics;
515
+
516
+ NS_ASSUME_NONNULL_END
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m ADDED
@@ -0,0 +1,1274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFURLSessionManager.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 "AFURLSessionManager.h"
23
+ #import <objc/runtime.h>
24
+
25
+ static dispatch_queue_t url_session_manager_processing_queue() {
26
+ static dispatch_queue_t af_url_session_manager_processing_queue;
27
+ static dispatch_once_t onceToken;
28
+ dispatch_once(&onceToken, ^{
29
+ af_url_session_manager_processing_queue = dispatch_queue_create("com.alamofire.networking.session.manager.processing", DISPATCH_QUEUE_CONCURRENT);
30
+ });
31
+
32
+ return af_url_session_manager_processing_queue;
33
+ }
34
+
35
+ static dispatch_group_t url_session_manager_completion_group() {
36
+ static dispatch_group_t af_url_session_manager_completion_group;
37
+ static dispatch_once_t onceToken;
38
+ dispatch_once(&onceToken, ^{
39
+ af_url_session_manager_completion_group = dispatch_group_create();
40
+ });
41
+
42
+ return af_url_session_manager_completion_group;
43
+ }
44
+
45
+ NSString * const AFNetworkingTaskDidResumeNotification = @"com.alamofire.networking.task.resume";
46
+ NSString * const AFNetworkingTaskDidCompleteNotification = @"com.alamofire.networking.task.complete";
47
+ NSString * const AFNetworkingTaskDidSuspendNotification = @"com.alamofire.networking.task.suspend";
48
+ NSString * const AFURLSessionDidInvalidateNotification = @"com.alamofire.networking.session.invalidate";
49
+ NSString * const AFURLSessionDownloadTaskDidMoveFileSuccessfullyNotification = @"com.alamofire.networking.session.download.file-manager-succeed";
50
+ NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification = @"com.alamofire.networking.session.download.file-manager-error";
51
+
52
+ NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse";
53
+ NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer";
54
+ NSString * const AFNetworkingTaskDidCompleteResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata";
55
+ NSString * const AFNetworkingTaskDidCompleteErrorKey = @"com.alamofire.networking.task.complete.error";
56
+ NSString * const AFNetworkingTaskDidCompleteAssetPathKey = @"com.alamofire.networking.task.complete.assetpath";
57
+ NSString * const AFNetworkingTaskDidCompleteSessionTaskMetrics = @"com.alamofire.networking.complete.sessiontaskmetrics";
58
+
59
+ static NSString * const AFURLSessionManagerLockName = @"com.alamofire.networking.session.manager.lock";
60
+
61
+ typedef void (^AFURLSessionDidBecomeInvalidBlock)(NSURLSession *session, NSError *error);
62
+ typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential);
63
+
64
+ typedef NSURLRequest * (^AFURLSessionTaskWillPerformHTTPRedirectionBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request);
65
+ typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionTaskDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential);
66
+ typedef id (^AFURLSessionTaskAuthenticationChallengeBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, void (^completionHandler)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential));
67
+ typedef void (^AFURLSessionDidFinishEventsForBackgroundURLSessionBlock)(NSURLSession *session);
68
+
69
+ typedef NSInputStream * (^AFURLSessionTaskNeedNewBodyStreamBlock)(NSURLSession *session, NSURLSessionTask *task);
70
+ typedef void (^AFURLSessionTaskDidSendBodyDataBlock)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend);
71
+ typedef void (^AFURLSessionTaskDidCompleteBlock)(NSURLSession *session, NSURLSessionTask *task, NSError *error);
72
+ #if AF_CAN_INCLUDE_SESSION_TASK_METRICS
73
+ typedef void (^AFURLSessionTaskDidFinishCollectingMetricsBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLSessionTaskMetrics * metrics) AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10));
74
+ #endif
75
+
76
+ typedef NSURLSessionResponseDisposition (^AFURLSessionDataTaskDidReceiveResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response);
77
+ typedef void (^AFURLSessionDataTaskDidBecomeDownloadTaskBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask);
78
+ typedef void (^AFURLSessionDataTaskDidReceiveDataBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data);
79
+ typedef NSCachedURLResponse * (^AFURLSessionDataTaskWillCacheResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse);
80
+
81
+ typedef NSURL * (^AFURLSessionDownloadTaskDidFinishDownloadingBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location);
82
+ typedef void (^AFURLSessionDownloadTaskDidWriteDataBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite);
83
+ typedef void (^AFURLSessionDownloadTaskDidResumeBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes);
84
+ typedef void (^AFURLSessionTaskProgressBlock)(NSProgress *);
85
+
86
+ typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id responseObject, NSError *error);
87
+
88
+ #pragma mark -
89
+
90
+ @interface AFURLSessionManagerTaskDelegate : NSObject <NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate>
91
+ - (instancetype)initWithTask:(NSURLSessionTask *)task;
92
+ @property (nonatomic, weak) AFURLSessionManager *manager;
93
+ @property (nonatomic, strong) NSMutableData *mutableData;
94
+ @property (nonatomic, strong) NSProgress *uploadProgress;
95
+ @property (nonatomic, strong) NSProgress *downloadProgress;
96
+ @property (nonatomic, copy) NSURL *downloadFileURL;
97
+ #if AF_CAN_INCLUDE_SESSION_TASK_METRICS
98
+ @property (nonatomic, strong) NSURLSessionTaskMetrics *sessionTaskMetrics AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10));
99
+ #endif
100
+ @property (nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading;
101
+ @property (nonatomic, copy) AFURLSessionTaskProgressBlock uploadProgressBlock;
102
+ @property (nonatomic, copy) AFURLSessionTaskProgressBlock downloadProgressBlock;
103
+ @property (nonatomic, copy) AFURLSessionTaskCompletionHandler completionHandler;
104
+ @end
105
+
106
+ @implementation AFURLSessionManagerTaskDelegate
107
+
108
+ - (instancetype)initWithTask:(NSURLSessionTask *)task {
109
+ self = [super init];
110
+ if (!self) {
111
+ return nil;
112
+ }
113
+
114
+ _mutableData = [NSMutableData data];
115
+ _uploadProgress = [[NSProgress alloc] initWithParent:nil userInfo:nil];
116
+ _downloadProgress = [[NSProgress alloc] initWithParent:nil userInfo:nil];
117
+
118
+ __weak __typeof__(task) weakTask = task;
119
+ for (NSProgress *progress in @[ _uploadProgress, _downloadProgress ])
120
+ {
121
+ progress.totalUnitCount = NSURLSessionTransferSizeUnknown;
122
+ progress.cancellable = YES;
123
+ progress.cancellationHandler = ^{
124
+ [weakTask cancel];
125
+ };
126
+ progress.pausable = YES;
127
+ progress.pausingHandler = ^{
128
+ [weakTask suspend];
129
+ };
130
+ #if AF_CAN_USE_AT_AVAILABLE
131
+ if (@available(macOS 10.11, *))
132
+ #else
133
+ if ([progress respondsToSelector:@selector(setResumingHandler:)])
134
+ #endif
135
+ {
136
+ progress.resumingHandler = ^{
137
+ [weakTask resume];
138
+ };
139
+ }
140
+
141
+ [progress addObserver:self
142
+ forKeyPath:NSStringFromSelector(@selector(fractionCompleted))
143
+ options:NSKeyValueObservingOptionNew
144
+ context:NULL];
145
+ }
146
+ return self;
147
+ }
148
+
149
+ - (void)dealloc {
150
+ [self.downloadProgress removeObserver:self forKeyPath:NSStringFromSelector(@selector(fractionCompleted))];
151
+ [self.uploadProgress removeObserver:self forKeyPath:NSStringFromSelector(@selector(fractionCompleted))];
152
+ }
153
+
154
+ #pragma mark - NSProgress Tracking
155
+
156
+ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context {
157
+ if ([object isEqual:self.downloadProgress]) {
158
+ if (self.downloadProgressBlock) {
159
+ self.downloadProgressBlock(object);
160
+ }
161
+ }
162
+ else if ([object isEqual:self.uploadProgress]) {
163
+ if (self.uploadProgressBlock) {
164
+ self.uploadProgressBlock(object);
165
+ }
166
+ }
167
+ }
168
+
169
+ static const void * const AuthenticationChallengeErrorKey = &AuthenticationChallengeErrorKey;
170
+
171
+ #pragma mark - NSURLSessionTaskDelegate
172
+
173
+ - (void)URLSession:(__unused NSURLSession *)session
174
+ task:(NSURLSessionTask *)task
175
+ didCompleteWithError:(NSError *)error
176
+ {
177
+ error = objc_getAssociatedObject(task, AuthenticationChallengeErrorKey) ?: error;
178
+ __strong AFURLSessionManager *manager = self.manager;
179
+
180
+ __block id responseObject = nil;
181
+
182
+ NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
183
+ userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer;
184
+
185
+ //Performance Improvement from #2672
186
+ NSData *data = nil;
187
+ if (self.mutableData) {
188
+ data = [self.mutableData copy];
189
+ //We no longer need the reference, so nil it out to gain back some memory.
190
+ self.mutableData = nil;
191
+ }
192
+
193
+ #if AF_CAN_USE_AT_AVAILABLE && AF_CAN_INCLUDE_SESSION_TASK_METRICS
194
+ if (@available(iOS 10, macOS 10.12, watchOS 3, tvOS 10, *)) {
195
+ if (self.sessionTaskMetrics) {
196
+ userInfo[AFNetworkingTaskDidCompleteSessionTaskMetrics] = self.sessionTaskMetrics;
197
+ }
198
+ }
199
+ #endif
200
+
201
+ if (self.downloadFileURL) {
202
+ userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL;
203
+ } else if (data) {
204
+ userInfo[AFNetworkingTaskDidCompleteResponseDataKey] = data;
205
+ }
206
+
207
+ if (error) {
208
+ userInfo[AFNetworkingTaskDidCompleteErrorKey] = error;
209
+
210
+ dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{
211
+ if (self.completionHandler) {
212
+ self.completionHandler(task.response, responseObject, error);
213
+ }
214
+
215
+ dispatch_async(dispatch_get_main_queue(), ^{
216
+ [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo];
217
+ });
218
+ });
219
+ } else {
220
+ dispatch_async(url_session_manager_processing_queue(), ^{
221
+ NSError *serializationError = nil;
222
+ responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:data error:&serializationError];
223
+
224
+ if (self.downloadFileURL) {
225
+ responseObject = self.downloadFileURL;
226
+ }
227
+
228
+ if (responseObject) {
229
+ userInfo[AFNetworkingTaskDidCompleteSerializedResponseKey] = responseObject;
230
+ }
231
+
232
+ if (serializationError) {
233
+ userInfo[AFNetworkingTaskDidCompleteErrorKey] = serializationError;
234
+ }
235
+
236
+ dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{
237
+ if (self.completionHandler) {
238
+ self.completionHandler(task.response, responseObject, serializationError);
239
+ }
240
+
241
+ dispatch_async(dispatch_get_main_queue(), ^{
242
+ [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo];
243
+ });
244
+ });
245
+ });
246
+ }
247
+ }
248
+
249
+ #if AF_CAN_INCLUDE_SESSION_TASK_METRICS
250
+ - (void)URLSession:(NSURLSession *)session
251
+ task:(NSURLSessionTask *)task
252
+ didFinishCollectingMetrics:(NSURLSessionTaskMetrics *)metrics AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10)) {
253
+ self.sessionTaskMetrics = metrics;
254
+ }
255
+ #endif
256
+
257
+ #pragma mark - NSURLSessionDataDelegate
258
+
259
+ - (void)URLSession:(__unused NSURLSession *)session
260
+ dataTask:(__unused NSURLSessionDataTask *)dataTask
261
+ didReceiveData:(NSData *)data
262
+ {
263
+ self.downloadProgress.totalUnitCount = dataTask.countOfBytesExpectedToReceive;
264
+ self.downloadProgress.completedUnitCount = dataTask.countOfBytesReceived;
265
+
266
+ [self.mutableData appendData:data];
267
+ }
268
+
269
+ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task
270
+ didSendBodyData:(int64_t)bytesSent
271
+ totalBytesSent:(int64_t)totalBytesSent
272
+ totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend{
273
+
274
+ self.uploadProgress.totalUnitCount = task.countOfBytesExpectedToSend;
275
+ self.uploadProgress.completedUnitCount = task.countOfBytesSent;
276
+ }
277
+
278
+ #pragma mark - NSURLSessionDownloadDelegate
279
+
280
+ - (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask
281
+ didWriteData:(int64_t)bytesWritten
282
+ totalBytesWritten:(int64_t)totalBytesWritten
283
+ totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite{
284
+
285
+ self.downloadProgress.totalUnitCount = totalBytesExpectedToWrite;
286
+ self.downloadProgress.completedUnitCount = totalBytesWritten;
287
+ }
288
+
289
+ - (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask
290
+ didResumeAtOffset:(int64_t)fileOffset
291
+ expectedTotalBytes:(int64_t)expectedTotalBytes{
292
+
293
+ self.downloadProgress.totalUnitCount = expectedTotalBytes;
294
+ self.downloadProgress.completedUnitCount = fileOffset;
295
+ }
296
+
297
+ - (void)URLSession:(NSURLSession *)session
298
+ downloadTask:(NSURLSessionDownloadTask *)downloadTask
299
+ didFinishDownloadingToURL:(NSURL *)location
300
+ {
301
+ self.downloadFileURL = nil;
302
+
303
+ if (self.downloadTaskDidFinishDownloading) {
304
+ self.downloadFileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location);
305
+ if (self.downloadFileURL) {
306
+ NSError *fileManagerError = nil;
307
+
308
+ if (![[NSFileManager defaultManager] moveItemAtURL:location toURL:self.downloadFileURL error:&fileManagerError]) {
309
+ [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:fileManagerError.userInfo];
310
+ } else {
311
+ [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidMoveFileSuccessfullyNotification object:downloadTask userInfo:nil];
312
+ }
313
+ }
314
+ }
315
+ }
316
+
317
+ @end
318
+
319
+ #pragma mark -
320
+
321
+ /**
322
+ * A workaround for issues related to key-value observing the `state` of an `NSURLSessionTask`.
323
+ *
324
+ * See:
325
+ * - https://github.com/AFNetworking/AFNetworking/issues/1477
326
+ * - https://github.com/AFNetworking/AFNetworking/issues/2638
327
+ * - https://github.com/AFNetworking/AFNetworking/pull/2702
328
+ */
329
+
330
+ static inline void af_swizzleSelector(Class theClass, SEL originalSelector, SEL swizzledSelector) {
331
+ Method originalMethod = class_getInstanceMethod(theClass, originalSelector);
332
+ Method swizzledMethod = class_getInstanceMethod(theClass, swizzledSelector);
333
+ method_exchangeImplementations(originalMethod, swizzledMethod);
334
+ }
335
+
336
+ static inline BOOL af_addMethod(Class theClass, SEL selector, Method method) {
337
+ return class_addMethod(theClass, selector, method_getImplementation(method), method_getTypeEncoding(method));
338
+ }
339
+
340
+ static NSString * const AFNSURLSessionTaskDidResumeNotification = @"com.alamofire.networking.nsurlsessiontask.resume";
341
+ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofire.networking.nsurlsessiontask.suspend";
342
+
343
+ @interface _AFURLSessionTaskSwizzling : NSObject
344
+
345
+ @end
346
+
347
+ @implementation _AFURLSessionTaskSwizzling
348
+
349
+ + (void)load {
350
+ /**
351
+ WARNING: Trouble Ahead
352
+ https://github.com/AFNetworking/AFNetworking/pull/2702
353
+ */
354
+
355
+ if (NSClassFromString(@"NSURLSessionTask")) {
356
+ /**
357
+ iOS 7 and iOS 8 differ in NSURLSessionTask implementation, which makes the next bit of code a bit tricky.
358
+ Many Unit Tests have been built to validate as much of this behavior has possible.
359
+ Here is what we know:
360
+ - NSURLSessionTasks are implemented with class clusters, meaning the class you request from the API isn't actually the type of class you will get back.
361
+ - Simply referencing `[NSURLSessionTask class]` will not work. You need to ask an `NSURLSession` to actually create an object, and grab the class from there.
362
+ - On iOS 7, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `__NSCFURLSessionTask`.
363
+ - On iOS 8, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `NSURLSessionTask`.
364
+ - On iOS 7, `__NSCFLocalSessionTask` and `__NSCFURLSessionTask` are the only two classes that have their own implementations of `resume` and `suspend`, and `__NSCFLocalSessionTask` DOES NOT CALL SUPER. This means both classes need to be swizzled.
365
+ - On iOS 8, `NSURLSessionTask` is the only class that implements `resume` and `suspend`. This means this is the only class that needs to be swizzled.
366
+ - Because `NSURLSessionTask` is not involved in the class hierarchy for every version of iOS, its easier to add the swizzled methods to a dummy class and manage them there.
367
+
368
+ Some Assumptions:
369
+ - No implementations of `resume` or `suspend` call super. If this were to change in a future version of iOS, we'd need to handle it.
370
+ - No background task classes override `resume` or `suspend`
371
+
372
+ The current solution:
373
+ 1) Grab an instance of `__NSCFLocalDataTask` by asking an instance of `NSURLSession` for a data task.
374
+ 2) Grab a pointer to the original implementation of `af_resume`
375
+ 3) Check to see if the current class has an implementation of resume. If so, continue to step 4.
376
+ 4) Grab the super class of the current class.
377
+ 5) Grab a pointer for the current class to the current implementation of `resume`.
378
+ 6) Grab a pointer for the super class to the current implementation of `resume`.
379
+ 7) If the current class implementation of `resume` is not equal to the super class implementation of `resume` AND the current implementation of `resume` is not equal to the original implementation of `af_resume`, THEN swizzle the methods
380
+ 8) Set the current class to the super class, and repeat steps 3-8
381
+ */
382
+ NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration];
383
+ NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
384
+ #pragma GCC diagnostic push
385
+ #pragma GCC diagnostic ignored "-Wnonnull"
386
+ NSURLSessionDataTask *localDataTask = [session dataTaskWithURL:nil];
387
+ #pragma clang diagnostic pop
388
+ IMP originalAFResumeIMP = method_getImplementation(class_getInstanceMethod([self class], @selector(af_resume)));
389
+ Class currentClass = [localDataTask class];
390
+
391
+ while (class_getInstanceMethod(currentClass, @selector(resume))) {
392
+ Class superClass = [currentClass superclass];
393
+ IMP classResumeIMP = method_getImplementation(class_getInstanceMethod(currentClass, @selector(resume)));
394
+ IMP superclassResumeIMP = method_getImplementation(class_getInstanceMethod(superClass, @selector(resume)));
395
+ if (classResumeIMP != superclassResumeIMP &&
396
+ originalAFResumeIMP != classResumeIMP) {
397
+ [self swizzleResumeAndSuspendMethodForClass:currentClass];
398
+ }
399
+ currentClass = [currentClass superclass];
400
+ }
401
+
402
+ [localDataTask cancel];
403
+ [session finishTasksAndInvalidate];
404
+ }
405
+ }
406
+
407
+ + (void)swizzleResumeAndSuspendMethodForClass:(Class)theClass {
408
+ Method afResumeMethod = class_getInstanceMethod(self, @selector(af_resume));
409
+ Method afSuspendMethod = class_getInstanceMethod(self, @selector(af_suspend));
410
+
411
+ if (af_addMethod(theClass, @selector(af_resume), afResumeMethod)) {
412
+ af_swizzleSelector(theClass, @selector(resume), @selector(af_resume));
413
+ }
414
+
415
+ if (af_addMethod(theClass, @selector(af_suspend), afSuspendMethod)) {
416
+ af_swizzleSelector(theClass, @selector(suspend), @selector(af_suspend));
417
+ }
418
+ }
419
+
420
+ - (NSURLSessionTaskState)state {
421
+ NSAssert(NO, @"State method should never be called in the actual dummy class");
422
+ return NSURLSessionTaskStateCanceling;
423
+ }
424
+
425
+ - (void)af_resume {
426
+ NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state");
427
+ NSURLSessionTaskState state = [self state];
428
+ [self af_resume];
429
+
430
+ if (state != NSURLSessionTaskStateRunning) {
431
+ [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidResumeNotification object:self];
432
+ }
433
+ }
434
+
435
+ - (void)af_suspend {
436
+ NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state");
437
+ NSURLSessionTaskState state = [self state];
438
+ [self af_suspend];
439
+
440
+ if (state != NSURLSessionTaskStateSuspended) {
441
+ [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidSuspendNotification object:self];
442
+ }
443
+ }
444
+ @end
445
+
446
+ #pragma mark -
447
+
448
+ @interface AFURLSessionManager ()
449
+ @property (readwrite, nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration;
450
+ @property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue;
451
+ @property (readwrite, nonatomic, strong) NSURLSession *session;
452
+ @property (readwrite, nonatomic, strong) NSMutableDictionary *mutableTaskDelegatesKeyedByTaskIdentifier;
453
+ @property (readonly, nonatomic, copy) NSString *taskDescriptionForSessionTasks;
454
+ @property (readwrite, nonatomic, strong) NSLock *lock;
455
+ @property (readwrite, nonatomic, copy) AFURLSessionDidBecomeInvalidBlock sessionDidBecomeInvalid;
456
+ @property (readwrite, nonatomic, copy) AFURLSessionDidReceiveAuthenticationChallengeBlock sessionDidReceiveAuthenticationChallenge;
457
+ @property (readwrite, nonatomic, copy) AFURLSessionDidFinishEventsForBackgroundURLSessionBlock didFinishEventsForBackgroundURLSession AF_API_UNAVAILABLE(macos);
458
+ @property (readwrite, nonatomic, copy) AFURLSessionTaskWillPerformHTTPRedirectionBlock taskWillPerformHTTPRedirection;
459
+ @property (readwrite, nonatomic, copy) AFURLSessionTaskAuthenticationChallengeBlock authenticationChallengeHandler;
460
+ @property (readwrite, nonatomic, copy) AFURLSessionTaskNeedNewBodyStreamBlock taskNeedNewBodyStream;
461
+ @property (readwrite, nonatomic, copy) AFURLSessionTaskDidSendBodyDataBlock taskDidSendBodyData;
462
+ @property (readwrite, nonatomic, copy) AFURLSessionTaskDidCompleteBlock taskDidComplete;
463
+ #if AF_CAN_INCLUDE_SESSION_TASK_METRICS
464
+ @property (readwrite, nonatomic, copy) AFURLSessionTaskDidFinishCollectingMetricsBlock taskDidFinishCollectingMetrics AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10));
465
+ #endif
466
+ @property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveResponseBlock dataTaskDidReceiveResponse;
467
+ @property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidBecomeDownloadTaskBlock dataTaskDidBecomeDownloadTask;
468
+ @property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveDataBlock dataTaskDidReceiveData;
469
+ @property (readwrite, nonatomic, copy) AFURLSessionDataTaskWillCacheResponseBlock dataTaskWillCacheResponse;
470
+ @property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading;
471
+ @property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidWriteDataBlock downloadTaskDidWriteData;
472
+ @property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidResumeBlock downloadTaskDidResume;
473
+ @end
474
+
475
+ @implementation AFURLSessionManager
476
+
477
+ - (instancetype)init {
478
+ return [self initWithSessionConfiguration:nil];
479
+ }
480
+
481
+ - (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration {
482
+ self = [super init];
483
+ if (!self) {
484
+ return nil;
485
+ }
486
+
487
+ if (!configuration) {
488
+ configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
489
+ }
490
+
491
+ self.sessionConfiguration = configuration;
492
+
493
+ self.operationQueue = [[NSOperationQueue alloc] init];
494
+ self.operationQueue.maxConcurrentOperationCount = 1;
495
+
496
+ self.responseSerializer = [AFJSONResponseSerializer serializer];
497
+
498
+ self.securityPolicy = [AFSecurityPolicy defaultPolicy];
499
+
500
+ #if !TARGET_OS_WATCH
501
+ self.reachabilityManager = [AFNetworkReachabilityManager sharedManager];
502
+ #endif
503
+
504
+ self.mutableTaskDelegatesKeyedByTaskIdentifier = [[NSMutableDictionary alloc] init];
505
+
506
+ self.lock = [[NSLock alloc] init];
507
+ self.lock.name = AFURLSessionManagerLockName;
508
+
509
+ [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) {
510
+ for (NSURLSessionDataTask *task in dataTasks) {
511
+ [self addDelegateForDataTask:task uploadProgress:nil downloadProgress:nil completionHandler:nil];
512
+ }
513
+
514
+ for (NSURLSessionUploadTask *uploadTask in uploadTasks) {
515
+ [self addDelegateForUploadTask:uploadTask progress:nil completionHandler:nil];
516
+ }
517
+
518
+ for (NSURLSessionDownloadTask *downloadTask in downloadTasks) {
519
+ [self addDelegateForDownloadTask:downloadTask progress:nil destination:nil completionHandler:nil];
520
+ }
521
+ }];
522
+
523
+ return self;
524
+ }
525
+
526
+ - (void)dealloc {
527
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
528
+ }
529
+
530
+ #pragma mark -
531
+
532
+ - (NSURLSession *)session {
533
+
534
+ @synchronized (self) {
535
+ if (!_session) {
536
+ _session = [NSURLSession sessionWithConfiguration:self.sessionConfiguration delegate:self delegateQueue:self.operationQueue];
537
+ }
538
+ }
539
+ return _session;
540
+ }
541
+
542
+ #pragma mark -
543
+
544
+
545
+ - (NSString *)taskDescriptionForSessionTasks {
546
+ return [NSString stringWithFormat:@"%p", self];
547
+ }
548
+
549
+ - (void)taskDidResume:(NSNotification *)notification {
550
+ NSURLSessionTask *task = notification.object;
551
+ if ([task respondsToSelector:@selector(taskDescription)]) {
552
+ if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) {
553
+ dispatch_async(dispatch_get_main_queue(), ^{
554
+ [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidResumeNotification object:task];
555
+ });
556
+ }
557
+ }
558
+ }
559
+
560
+ - (void)taskDidSuspend:(NSNotification *)notification {
561
+ NSURLSessionTask *task = notification.object;
562
+ if ([task respondsToSelector:@selector(taskDescription)]) {
563
+ if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) {
564
+ dispatch_async(dispatch_get_main_queue(), ^{
565
+ [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidSuspendNotification object:task];
566
+ });
567
+ }
568
+ }
569
+ }
570
+
571
+ #pragma mark -
572
+
573
+ - (AFURLSessionManagerTaskDelegate *)delegateForTask:(NSURLSessionTask *)task {
574
+ NSParameterAssert(task);
575
+
576
+ AFURLSessionManagerTaskDelegate *delegate = nil;
577
+ [self.lock lock];
578
+ delegate = self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)];
579
+ [self.lock unlock];
580
+
581
+ return delegate;
582
+ }
583
+
584
+ - (void)setDelegate:(AFURLSessionManagerTaskDelegate *)delegate
585
+ forTask:(NSURLSessionTask *)task
586
+ {
587
+ NSParameterAssert(task);
588
+ NSParameterAssert(delegate);
589
+
590
+ [self.lock lock];
591
+ self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)] = delegate;
592
+ [self addNotificationObserverForTask:task];
593
+ [self.lock unlock];
594
+ }
595
+
596
+ - (void)addDelegateForDataTask:(NSURLSessionDataTask *)dataTask
597
+ uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock
598
+ downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock
599
+ completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
600
+ {
601
+ AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] initWithTask:dataTask];
602
+ delegate.manager = self;
603
+ delegate.completionHandler = completionHandler;
604
+
605
+ dataTask.taskDescription = self.taskDescriptionForSessionTasks;
606
+ [self setDelegate:delegate forTask:dataTask];
607
+
608
+ delegate.uploadProgressBlock = uploadProgressBlock;
609
+ delegate.downloadProgressBlock = downloadProgressBlock;
610
+ }
611
+
612
+ - (void)addDelegateForUploadTask:(NSURLSessionUploadTask *)uploadTask
613
+ progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock
614
+ completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
615
+ {
616
+ AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] initWithTask:uploadTask];
617
+ delegate.manager = self;
618
+ delegate.completionHandler = completionHandler;
619
+
620
+ uploadTask.taskDescription = self.taskDescriptionForSessionTasks;
621
+
622
+ [self setDelegate:delegate forTask:uploadTask];
623
+
624
+ delegate.uploadProgressBlock = uploadProgressBlock;
625
+ }
626
+
627
+ - (void)addDelegateForDownloadTask:(NSURLSessionDownloadTask *)downloadTask
628
+ progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock
629
+ destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
630
+ completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler
631
+ {
632
+ AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] initWithTask:downloadTask];
633
+ delegate.manager = self;
634
+ delegate.completionHandler = completionHandler;
635
+
636
+ if (destination) {
637
+ delegate.downloadTaskDidFinishDownloading = ^NSURL * (NSURLSession * __unused session, NSURLSessionDownloadTask *task, NSURL *location) {
638
+ return destination(location, task.response);
639
+ };
640
+ }
641
+
642
+ downloadTask.taskDescription = self.taskDescriptionForSessionTasks;
643
+
644
+ [self setDelegate:delegate forTask:downloadTask];
645
+
646
+ delegate.downloadProgressBlock = downloadProgressBlock;
647
+ }
648
+
649
+ - (void)removeDelegateForTask:(NSURLSessionTask *)task {
650
+ NSParameterAssert(task);
651
+
652
+ [self.lock lock];
653
+ [self removeNotificationObserverForTask:task];
654
+ [self.mutableTaskDelegatesKeyedByTaskIdentifier removeObjectForKey:@(task.taskIdentifier)];
655
+ [self.lock unlock];
656
+ }
657
+
658
+ #pragma mark -
659
+
660
+ - (NSArray *)tasksForKeyPath:(NSString *)keyPath {
661
+ __block NSArray *tasks = nil;
662
+ dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
663
+ [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) {
664
+ if ([keyPath isEqualToString:NSStringFromSelector(@selector(dataTasks))]) {
665
+ tasks = dataTasks;
666
+ } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(uploadTasks))]) {
667
+ tasks = uploadTasks;
668
+ } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(downloadTasks))]) {
669
+ tasks = downloadTasks;
670
+ } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(tasks))]) {
671
+ tasks = [@[dataTasks, uploadTasks, downloadTasks] valueForKeyPath:@"@unionOfArrays.self"];
672
+ }
673
+
674
+ dispatch_semaphore_signal(semaphore);
675
+ }];
676
+
677
+ dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
678
+
679
+ return tasks;
680
+ }
681
+
682
+ - (NSArray *)tasks {
683
+ return [self tasksForKeyPath:NSStringFromSelector(_cmd)];
684
+ }
685
+
686
+ - (NSArray *)dataTasks {
687
+ return [self tasksForKeyPath:NSStringFromSelector(_cmd)];
688
+ }
689
+
690
+ - (NSArray *)uploadTasks {
691
+ return [self tasksForKeyPath:NSStringFromSelector(_cmd)];
692
+ }
693
+
694
+ - (NSArray *)downloadTasks {
695
+ return [self tasksForKeyPath:NSStringFromSelector(_cmd)];
696
+ }
697
+
698
+ #pragma mark -
699
+
700
+ - (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks resetSession:(BOOL)resetSession {
701
+ if (cancelPendingTasks) {
702
+ [self.session invalidateAndCancel];
703
+ } else {
704
+ [self.session finishTasksAndInvalidate];
705
+ }
706
+ if (resetSession) {
707
+ self.session = nil;
708
+ }
709
+ }
710
+
711
+ #pragma mark -
712
+
713
+ - (void)setResponseSerializer:(id <AFURLResponseSerialization>)responseSerializer {
714
+ NSParameterAssert(responseSerializer);
715
+
716
+ _responseSerializer = responseSerializer;
717
+ }
718
+
719
+ #pragma mark -
720
+ - (void)addNotificationObserverForTask:(NSURLSessionTask *)task {
721
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidResume:) name:AFNSURLSessionTaskDidResumeNotification object:task];
722
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidSuspend:) name:AFNSURLSessionTaskDidSuspendNotification object:task];
723
+ }
724
+
725
+ - (void)removeNotificationObserverForTask:(NSURLSessionTask *)task {
726
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:AFNSURLSessionTaskDidSuspendNotification object:task];
727
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:AFNSURLSessionTaskDidResumeNotification object:task];
728
+ }
729
+
730
+ #pragma mark -
731
+
732
+ - (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
733
+ uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock
734
+ downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock
735
+ completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler {
736
+
737
+ NSURLSessionDataTask *dataTask = [self.session dataTaskWithRequest:request];
738
+
739
+ [self addDelegateForDataTask:dataTask uploadProgress:uploadProgressBlock downloadProgress:downloadProgressBlock completionHandler:completionHandler];
740
+
741
+ return dataTask;
742
+ }
743
+
744
+ #pragma mark -
745
+
746
+ - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
747
+ fromFile:(NSURL *)fileURL
748
+ progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock
749
+ completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
750
+ {
751
+ NSURLSessionUploadTask *uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL];
752
+
753
+ if (uploadTask) {
754
+ [self addDelegateForUploadTask:uploadTask
755
+ progress:uploadProgressBlock
756
+ completionHandler:completionHandler];
757
+ }
758
+
759
+ return uploadTask;
760
+ }
761
+
762
+ - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
763
+ fromData:(NSData *)bodyData
764
+ progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock
765
+ completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
766
+ {
767
+ NSURLSessionUploadTask *uploadTask = [self.session uploadTaskWithRequest:request fromData:bodyData];
768
+
769
+ [self addDelegateForUploadTask:uploadTask progress:uploadProgressBlock completionHandler:completionHandler];
770
+
771
+ return uploadTask;
772
+ }
773
+
774
+ - (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request
775
+ progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock
776
+ completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
777
+ {
778
+ NSURLSessionUploadTask *uploadTask = [self.session uploadTaskWithStreamedRequest:request];
779
+
780
+ [self addDelegateForUploadTask:uploadTask progress:uploadProgressBlock completionHandler:completionHandler];
781
+
782
+ return uploadTask;
783
+ }
784
+
785
+ #pragma mark -
786
+
787
+ - (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request
788
+ progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock
789
+ destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
790
+ completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler
791
+ {
792
+ NSURLSessionDownloadTask *downloadTask = [self.session downloadTaskWithRequest:request];
793
+
794
+ [self addDelegateForDownloadTask:downloadTask progress:downloadProgressBlock destination:destination completionHandler:completionHandler];
795
+
796
+ return downloadTask;
797
+ }
798
+
799
+ - (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData
800
+ progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock
801
+ destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
802
+ completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler
803
+ {
804
+ NSURLSessionDownloadTask *downloadTask = [self.session downloadTaskWithResumeData:resumeData];
805
+
806
+ [self addDelegateForDownloadTask:downloadTask progress:downloadProgressBlock destination:destination completionHandler:completionHandler];
807
+
808
+ return downloadTask;
809
+ }
810
+
811
+ #pragma mark -
812
+ - (NSProgress *)uploadProgressForTask:(NSURLSessionTask *)task {
813
+ return [[self delegateForTask:task] uploadProgress];
814
+ }
815
+
816
+ - (NSProgress *)downloadProgressForTask:(NSURLSessionTask *)task {
817
+ return [[self delegateForTask:task] downloadProgress];
818
+ }
819
+
820
+ #pragma mark -
821
+
822
+ - (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block {
823
+ self.sessionDidBecomeInvalid = block;
824
+ }
825
+
826
+ - (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block {
827
+ self.sessionDidReceiveAuthenticationChallenge = block;
828
+ }
829
+
830
+ #if !TARGET_OS_OSX
831
+ - (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block {
832
+ self.didFinishEventsForBackgroundURLSession = block;
833
+ }
834
+ #endif
835
+
836
+ #pragma mark -
837
+
838
+ - (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block {
839
+ self.taskNeedNewBodyStream = block;
840
+ }
841
+
842
+ - (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block {
843
+ self.taskWillPerformHTTPRedirection = block;
844
+ }
845
+
846
+ - (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block {
847
+ self.taskDidSendBodyData = block;
848
+ }
849
+
850
+ - (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block {
851
+ self.taskDidComplete = block;
852
+ }
853
+
854
+ #if AF_CAN_INCLUDE_SESSION_TASK_METRICS
855
+ - (void)setTaskDidFinishCollectingMetricsBlock:(void (^)(NSURLSession * _Nonnull, NSURLSessionTask * _Nonnull, NSURLSessionTaskMetrics * _Nullable))block AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10)) {
856
+ self.taskDidFinishCollectingMetrics = block;
857
+ }
858
+ #endif
859
+
860
+ #pragma mark -
861
+
862
+ - (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block {
863
+ self.dataTaskDidReceiveResponse = block;
864
+ }
865
+
866
+ - (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block {
867
+ self.dataTaskDidBecomeDownloadTask = block;
868
+ }
869
+
870
+ - (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block {
871
+ self.dataTaskDidReceiveData = block;
872
+ }
873
+
874
+ - (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block {
875
+ self.dataTaskWillCacheResponse = block;
876
+ }
877
+
878
+ #pragma mark -
879
+
880
+ - (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block {
881
+ self.downloadTaskDidFinishDownloading = block;
882
+ }
883
+
884
+ - (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block {
885
+ self.downloadTaskDidWriteData = block;
886
+ }
887
+
888
+ - (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block {
889
+ self.downloadTaskDidResume = block;
890
+ }
891
+
892
+ #pragma mark - NSObject
893
+
894
+ - (NSString *)description {
895
+ return [NSString stringWithFormat:@"<%@: %p, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, self.session, self.operationQueue];
896
+ }
897
+
898
+ - (BOOL)respondsToSelector:(SEL)selector {
899
+ if (selector == @selector(URLSession:didReceiveChallenge:completionHandler:)) {
900
+ return self.sessionDidReceiveAuthenticationChallenge != nil;
901
+ } else if (selector == @selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)) {
902
+ return self.taskWillPerformHTTPRedirection != nil;
903
+ } else if (selector == @selector(URLSession:dataTask:didReceiveResponse:completionHandler:)) {
904
+ return self.dataTaskDidReceiveResponse != nil;
905
+ } else if (selector == @selector(URLSession:dataTask:willCacheResponse:completionHandler:)) {
906
+ return self.dataTaskWillCacheResponse != nil;
907
+ }
908
+ #if !TARGET_OS_OSX
909
+ else if (selector == @selector(URLSessionDidFinishEventsForBackgroundURLSession:)) {
910
+ return self.didFinishEventsForBackgroundURLSession != nil;
911
+ }
912
+ #endif
913
+
914
+ return [[self class] instancesRespondToSelector:selector];
915
+ }
916
+
917
+ #pragma mark - NSURLSessionDelegate
918
+
919
+ - (void)URLSession:(NSURLSession *)session
920
+ didBecomeInvalidWithError:(NSError *)error
921
+ {
922
+ if (self.sessionDidBecomeInvalid) {
923
+ self.sessionDidBecomeInvalid(session, error);
924
+ }
925
+
926
+ [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDidInvalidateNotification object:session];
927
+ }
928
+
929
+ - (void)URLSession:(NSURLSession *)session
930
+ didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
931
+ completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
932
+ {
933
+ NSAssert(self.sessionDidReceiveAuthenticationChallenge != nil, @"`respondsToSelector:` implementation forces `URLSession:didReceiveChallenge:completionHandler:` to be called only if `self.sessionDidReceiveAuthenticationChallenge` is not nil");
934
+
935
+ NSURLCredential *credential = nil;
936
+ NSURLSessionAuthChallengeDisposition disposition = self.sessionDidReceiveAuthenticationChallenge(session, challenge, &credential);
937
+
938
+ if (completionHandler) {
939
+ completionHandler(disposition, credential);
940
+ }
941
+ }
942
+
943
+ #pragma mark - NSURLSessionTaskDelegate
944
+
945
+ - (void)URLSession:(NSURLSession *)session
946
+ task:(NSURLSessionTask *)task
947
+ willPerformHTTPRedirection:(NSHTTPURLResponse *)response
948
+ newRequest:(NSURLRequest *)request
949
+ completionHandler:(void (^)(NSURLRequest *))completionHandler
950
+ {
951
+ NSURLRequest *redirectRequest = request;
952
+
953
+ if (self.taskWillPerformHTTPRedirection) {
954
+ redirectRequest = self.taskWillPerformHTTPRedirection(session, task, response, request);
955
+ }
956
+
957
+ if (completionHandler) {
958
+ completionHandler(redirectRequest);
959
+ }
960
+ }
961
+
962
+ - (void)URLSession:(NSURLSession *)session
963
+ task:(NSURLSessionTask *)task
964
+ didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
965
+ completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
966
+ {
967
+ BOOL evaluateServerTrust = NO;
968
+ NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling;
969
+ NSURLCredential *credential = nil;
970
+
971
+ if (self.authenticationChallengeHandler) {
972
+ id result = self.authenticationChallengeHandler(session, task, challenge, completionHandler);
973
+ if (result == nil) {
974
+ return;
975
+ } else if ([result isKindOfClass:NSError.class]) {
976
+ objc_setAssociatedObject(task, AuthenticationChallengeErrorKey, result, OBJC_ASSOCIATION_RETAIN);
977
+ disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge;
978
+ } else if ([result isKindOfClass:NSURLCredential.class]) {
979
+ credential = result;
980
+ disposition = NSURLSessionAuthChallengeUseCredential;
981
+ } else if ([result isKindOfClass:NSNumber.class]) {
982
+ disposition = [result integerValue];
983
+ NSAssert(disposition == NSURLSessionAuthChallengePerformDefaultHandling || disposition == NSURLSessionAuthChallengeCancelAuthenticationChallenge || disposition == NSURLSessionAuthChallengeRejectProtectionSpace, @"");
984
+ evaluateServerTrust = disposition == NSURLSessionAuthChallengePerformDefaultHandling && [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
985
+ } else {
986
+ @throw [NSException exceptionWithName:@"Invalid Return Value" reason:@"The return value from the authentication challenge handler must be nil, an NSError, an NSURLCredential or an NSNumber." userInfo:nil];
987
+ }
988
+ } else {
989
+ evaluateServerTrust = [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
990
+ }
991
+
992
+ if (evaluateServerTrust) {
993
+ if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) {
994
+ disposition = NSURLSessionAuthChallengeUseCredential;
995
+ credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
996
+ } else {
997
+ objc_setAssociatedObject(task, AuthenticationChallengeErrorKey,
998
+ [self serverTrustErrorForServerTrust:challenge.protectionSpace.serverTrust url:task.currentRequest.URL],
999
+ OBJC_ASSOCIATION_RETAIN);
1000
+ disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge;
1001
+ }
1002
+ }
1003
+
1004
+ if (completionHandler) {
1005
+ completionHandler(disposition, credential);
1006
+ }
1007
+ }
1008
+
1009
+ - (nonnull NSError *)serverTrustErrorForServerTrust:(nullable SecTrustRef)serverTrust url:(nullable NSURL *)url
1010
+ {
1011
+ NSBundle *CFNetworkBundle = [NSBundle bundleWithIdentifier:@"com.apple.CFNetwork"];
1012
+ NSString *defaultValue = @"The certificate for this server is invalid. You might be connecting to a server that is pretending to be “%@” which could put your confidential information at risk.";
1013
+ NSString *descriptionFormat = NSLocalizedStringWithDefaultValue(@"Err-1202.w", nil, CFNetworkBundle, defaultValue, @"") ?: defaultValue;
1014
+ NSString *localizedDescription = [descriptionFormat componentsSeparatedByString:@"%@"].count <= 2 ? [NSString localizedStringWithFormat:descriptionFormat, url.host] : descriptionFormat;
1015
+ NSMutableDictionary *userInfo = [@{
1016
+ NSLocalizedDescriptionKey: localizedDescription
1017
+ } mutableCopy];
1018
+
1019
+ if (serverTrust) {
1020
+ userInfo[NSURLErrorFailingURLPeerTrustErrorKey] = (__bridge id)serverTrust;
1021
+ }
1022
+
1023
+ if (url) {
1024
+ userInfo[NSURLErrorFailingURLErrorKey] = url;
1025
+
1026
+ if (url.absoluteString) {
1027
+ userInfo[NSURLErrorFailingURLStringErrorKey] = url.absoluteString;
1028
+ }
1029
+ }
1030
+
1031
+ return [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorServerCertificateUntrusted userInfo:userInfo];
1032
+ }
1033
+
1034
+ - (void)URLSession:(NSURLSession *)session
1035
+ task:(NSURLSessionTask *)task
1036
+ needNewBodyStream:(void (^)(NSInputStream *bodyStream))completionHandler
1037
+ {
1038
+ NSInputStream *inputStream = nil;
1039
+
1040
+ if (self.taskNeedNewBodyStream) {
1041
+ inputStream = self.taskNeedNewBodyStream(session, task);
1042
+ } else if (task.originalRequest.HTTPBodyStream && [task.originalRequest.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) {
1043
+ inputStream = [task.originalRequest.HTTPBodyStream copy];
1044
+ }
1045
+
1046
+ if (completionHandler) {
1047
+ completionHandler(inputStream);
1048
+ }
1049
+ }
1050
+
1051
+ - (void)URLSession:(NSURLSession *)session
1052
+ task:(NSURLSessionTask *)task
1053
+ didSendBodyData:(int64_t)bytesSent
1054
+ totalBytesSent:(int64_t)totalBytesSent
1055
+ totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend
1056
+ {
1057
+
1058
+ int64_t totalUnitCount = totalBytesExpectedToSend;
1059
+ if (totalUnitCount == NSURLSessionTransferSizeUnknown) {
1060
+ NSString *contentLength = [task.originalRequest valueForHTTPHeaderField:@"Content-Length"];
1061
+ if (contentLength) {
1062
+ totalUnitCount = (int64_t) [contentLength longLongValue];
1063
+ }
1064
+ }
1065
+
1066
+ AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task];
1067
+
1068
+ if (delegate) {
1069
+ [delegate URLSession:session task:task didSendBodyData:bytesSent totalBytesSent:totalBytesSent totalBytesExpectedToSend:totalBytesExpectedToSend];
1070
+ }
1071
+
1072
+ if (self.taskDidSendBodyData) {
1073
+ self.taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalUnitCount);
1074
+ }
1075
+ }
1076
+
1077
+ - (void)URLSession:(NSURLSession *)session
1078
+ task:(NSURLSessionTask *)task
1079
+ didCompleteWithError:(NSError *)error
1080
+ {
1081
+ AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task];
1082
+
1083
+ // delegate may be nil when completing a task in the background
1084
+ if (delegate) {
1085
+ [delegate URLSession:session task:task didCompleteWithError:error];
1086
+
1087
+ [self removeDelegateForTask:task];
1088
+ }
1089
+
1090
+ if (self.taskDidComplete) {
1091
+ self.taskDidComplete(session, task, error);
1092
+ }
1093
+ }
1094
+
1095
+ #if AF_CAN_INCLUDE_SESSION_TASK_METRICS
1096
+ - (void)URLSession:(NSURLSession *)session
1097
+ task:(NSURLSessionTask *)task
1098
+ didFinishCollectingMetrics:(NSURLSessionTaskMetrics *)metrics AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10))
1099
+ {
1100
+ AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task];
1101
+ // Metrics may fire after URLSession:task:didCompleteWithError: is called, delegate may be nil
1102
+ if (delegate) {
1103
+ [delegate URLSession:session task:task didFinishCollectingMetrics:metrics];
1104
+ }
1105
+
1106
+ if (self.taskDidFinishCollectingMetrics) {
1107
+ self.taskDidFinishCollectingMetrics(session, task, metrics);
1108
+ }
1109
+ }
1110
+ #endif
1111
+
1112
+ #pragma mark - NSURLSessionDataDelegate
1113
+
1114
+ - (void)URLSession:(NSURLSession *)session
1115
+ dataTask:(NSURLSessionDataTask *)dataTask
1116
+ didReceiveResponse:(NSURLResponse *)response
1117
+ completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler
1118
+ {
1119
+ NSURLSessionResponseDisposition disposition = NSURLSessionResponseAllow;
1120
+
1121
+ if (self.dataTaskDidReceiveResponse) {
1122
+ disposition = self.dataTaskDidReceiveResponse(session, dataTask, response);
1123
+ }
1124
+
1125
+ if (completionHandler) {
1126
+ completionHandler(disposition);
1127
+ }
1128
+ }
1129
+
1130
+ - (void)URLSession:(NSURLSession *)session
1131
+ dataTask:(NSURLSessionDataTask *)dataTask
1132
+ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask
1133
+ {
1134
+ AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask];
1135
+ if (delegate) {
1136
+ [self removeDelegateForTask:dataTask];
1137
+ [self setDelegate:delegate forTask:downloadTask];
1138
+ }
1139
+
1140
+ if (self.dataTaskDidBecomeDownloadTask) {
1141
+ self.dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask);
1142
+ }
1143
+ }
1144
+
1145
+ - (void)URLSession:(NSURLSession *)session
1146
+ dataTask:(NSURLSessionDataTask *)dataTask
1147
+ didReceiveData:(NSData *)data
1148
+ {
1149
+
1150
+ AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask];
1151
+ [delegate URLSession:session dataTask:dataTask didReceiveData:data];
1152
+
1153
+ if (self.dataTaskDidReceiveData) {
1154
+ self.dataTaskDidReceiveData(session, dataTask, data);
1155
+ }
1156
+ }
1157
+
1158
+ - (void)URLSession:(NSURLSession *)session
1159
+ dataTask:(NSURLSessionDataTask *)dataTask
1160
+ willCacheResponse:(NSCachedURLResponse *)proposedResponse
1161
+ completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler
1162
+ {
1163
+ NSCachedURLResponse *cachedResponse = proposedResponse;
1164
+
1165
+ if (self.dataTaskWillCacheResponse) {
1166
+ cachedResponse = self.dataTaskWillCacheResponse(session, dataTask, proposedResponse);
1167
+ }
1168
+
1169
+ if (completionHandler) {
1170
+ completionHandler(cachedResponse);
1171
+ }
1172
+ }
1173
+
1174
+ #if !TARGET_OS_OSX
1175
+ - (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session {
1176
+ if (self.didFinishEventsForBackgroundURLSession) {
1177
+ dispatch_async(dispatch_get_main_queue(), ^{
1178
+ self.didFinishEventsForBackgroundURLSession(session);
1179
+ });
1180
+ }
1181
+ }
1182
+ #endif
1183
+
1184
+ #pragma mark - NSURLSessionDownloadDelegate
1185
+
1186
+ - (void)URLSession:(NSURLSession *)session
1187
+ downloadTask:(NSURLSessionDownloadTask *)downloadTask
1188
+ didFinishDownloadingToURL:(NSURL *)location
1189
+ {
1190
+ AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask];
1191
+ if (self.downloadTaskDidFinishDownloading) {
1192
+ NSURL *fileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location);
1193
+ if (fileURL) {
1194
+ delegate.downloadFileURL = fileURL;
1195
+ NSError *error = nil;
1196
+
1197
+ if (![[NSFileManager defaultManager] moveItemAtURL:location toURL:fileURL error:&error]) {
1198
+ [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:error.userInfo];
1199
+ } else {
1200
+ [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidMoveFileSuccessfullyNotification object:downloadTask userInfo:nil];
1201
+ }
1202
+
1203
+ return;
1204
+ }
1205
+ }
1206
+
1207
+ if (delegate) {
1208
+ [delegate URLSession:session downloadTask:downloadTask didFinishDownloadingToURL:location];
1209
+ }
1210
+ }
1211
+
1212
+ - (void)URLSession:(NSURLSession *)session
1213
+ downloadTask:(NSURLSessionDownloadTask *)downloadTask
1214
+ didWriteData:(int64_t)bytesWritten
1215
+ totalBytesWritten:(int64_t)totalBytesWritten
1216
+ totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
1217
+ {
1218
+
1219
+ AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask];
1220
+
1221
+ if (delegate) {
1222
+ [delegate URLSession:session downloadTask:downloadTask didWriteData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite];
1223
+ }
1224
+
1225
+ if (self.downloadTaskDidWriteData) {
1226
+ self.downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
1227
+ }
1228
+ }
1229
+
1230
+ - (void)URLSession:(NSURLSession *)session
1231
+ downloadTask:(NSURLSessionDownloadTask *)downloadTask
1232
+ didResumeAtOffset:(int64_t)fileOffset
1233
+ expectedTotalBytes:(int64_t)expectedTotalBytes
1234
+ {
1235
+
1236
+ AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask];
1237
+
1238
+ if (delegate) {
1239
+ [delegate URLSession:session downloadTask:downloadTask didResumeAtOffset:fileOffset expectedTotalBytes:expectedTotalBytes];
1240
+ }
1241
+
1242
+ if (self.downloadTaskDidResume) {
1243
+ self.downloadTaskDidResume(session, downloadTask, fileOffset, expectedTotalBytes);
1244
+ }
1245
+ }
1246
+
1247
+ #pragma mark - NSSecureCoding
1248
+
1249
+ + (BOOL)supportsSecureCoding {
1250
+ return YES;
1251
+ }
1252
+
1253
+ - (instancetype)initWithCoder:(NSCoder *)decoder {
1254
+ NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"];
1255
+
1256
+ self = [self initWithSessionConfiguration:configuration];
1257
+ if (!self) {
1258
+ return nil;
1259
+ }
1260
+
1261
+ return self;
1262
+ }
1263
+
1264
+ - (void)encodeWithCoder:(NSCoder *)coder {
1265
+ [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"];
1266
+ }
1267
+
1268
+ #pragma mark - NSCopying
1269
+
1270
+ - (instancetype)copyWithZone:(NSZone *)zone {
1271
+ return [[[self class] allocWithZone:zone] initWithSessionConfiguration:self.session.configuration];
1272
+ }
1273
+
1274
+ @end
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2011-2020 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.
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/README.md ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center" >
2
+ <img src="https://raw.github.com/AFNetworking/AFNetworking/assets/afnetworking-logo.png" alt="AFNetworking" title="AFNetworking">
3
+ </p>
4
+
5
+ [![Build Status](https://github.com/AFNetworking/AFNetworking/workflows/AFNetworking%20CI/badge.svg?branch=master)](https://github.com/AFNetworking/AFNetworking/actions)
6
+ [![CocoaPods Compatible](https://img.shields.io/cocoapods/v/AFNetworking.svg)](https://img.shields.io/cocoapods/v/AFNetworking.svg)
7
+ [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
8
+ [![Platform](https://img.shields.io/cocoapods/p/AFNetworking.svg?style=flat)](http://cocoadocs.org/docsets/AFNetworking)
9
+ [![Twitter](https://img.shields.io/badge/[email protected]?style=flat)](http://twitter.com/AFNetworking)
10
+
11
+ AFNetworking is a delightful networking library for iOS, macOS, watchOS, and tvOS. It's built on top of the [Foundation URL Loading System](https://developer.apple.com/documentation/foundation/url_loading_system), extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use.
12
+
13
+ Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac.
14
+
15
+ ## How To Get Started
16
+
17
+ - [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/archive/master.zip) and try out the included Mac and iPhone example apps
18
+ - Read the ["Getting Started" guide](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking), [FAQ](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ), or [other articles on the Wiki](https://github.com/AFNetworking/AFNetworking/wiki)
19
+
20
+ ## Communication
21
+
22
+ - If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). (Tag 'afnetworking')
23
+ - If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking).
24
+ - If you **found a bug**, _and can provide steps to reliably reproduce it_, open an issue.
25
+ - If you **have a feature request**, open an issue.
26
+ - If you **want to contribute**, submit a pull request.
27
+
28
+ ## Installation
29
+ AFNetworking supports multiple methods for installing the library in a project.
30
+
31
+ ## Installation with CocoaPods
32
+
33
+ To integrate AFNetworking into your Xcode project using CocoaPods, specify it in your `Podfile`:
34
+
35
+ ```ruby
36
+ pod 'AFNetworking', '~> 4.0'
37
+ ```
38
+
39
+ ### Installation with Swift Package Manager
40
+
41
+ Once you have your Swift package set up, adding AFNetworking as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.
42
+
43
+ ```swift
44
+ dependencies: [
45
+ .package(url: "https://github.com/AFNetworking/AFNetworking.git", .upToNextMajor(from: "4.0.0"))
46
+ ]
47
+ ```
48
+
49
+ > Note: AFNetworking's Swift package does not include it's UIKit extensions.
50
+
51
+ ### Installation with Carthage
52
+
53
+ [Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate AFNetworking, add the following to your `Cartfile`.
54
+
55
+ ```ogdl
56
+ github "AFNetworking/AFNetworking" ~> 4.0
57
+ ```
58
+
59
+ ## Requirements
60
+
61
+ | AFNetworking Version | Minimum iOS Target | Minimum macOS Target | Minimum watchOS Target | Minimum tvOS Target | Notes |
62
+ |:--------------------:|:---------------------------:|:----------------------------:|:----------------------------:|:----------------------------:|:-------------------------------------------------------------------------:|
63
+ | 4.x | iOS 9 | macOS 10.10 | watchOS 2.0 | tvOS 9.0 | Xcode 11+ is required. |
64
+ | 3.x | iOS 7 | OS X 10.9 | watchOS 2.0 | tvOS 9.0 | Xcode 7+ is required. `NSURLConnectionOperation` support has been removed. |
65
+ | 2.6 -> 2.6.3 | iOS 7 | OS X 10.9 | watchOS 2.0 | n/a | Xcode 7+ is required. |
66
+ | 2.0 -> 2.5.4 | iOS 6 | OS X 10.8 | n/a | n/a | Xcode 5+ is required. `NSURLSession` subspec requires iOS 7 or OS X 10.9. |
67
+ | 1.x | iOS 5 | Mac OS X 10.7 | n/a | n/a |
68
+ | 0.10.x | iOS 4 | Mac OS X 10.6 | n/a | n/a |
69
+
70
+ (macOS projects must support [64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)).
71
+
72
+ > Programming in Swift? Try [Alamofire](https://github.com/Alamofire/Alamofire) for a more conventional set of APIs.
73
+
74
+ ## Architecture
75
+
76
+ ### NSURLSession
77
+
78
+ - `AFURLSessionManager`
79
+ - `AFHTTPSessionManager`
80
+
81
+ ### Serialization
82
+
83
+ * `<AFURLRequestSerialization>`
84
+ - `AFHTTPRequestSerializer`
85
+ - `AFJSONRequestSerializer`
86
+ - `AFPropertyListRequestSerializer`
87
+ * `<AFURLResponseSerialization>`
88
+ - `AFHTTPResponseSerializer`
89
+ - `AFJSONResponseSerializer`
90
+ - `AFXMLParserResponseSerializer`
91
+ - `AFXMLDocumentResponseSerializer` _(macOS)_
92
+ - `AFPropertyListResponseSerializer`
93
+ - `AFImageResponseSerializer`
94
+ - `AFCompoundResponseSerializer`
95
+
96
+ ### Additional Functionality
97
+
98
+ - `AFSecurityPolicy`
99
+ - `AFNetworkReachabilityManager`
100
+
101
+ ## Usage
102
+
103
+ ### AFURLSessionManager
104
+
105
+ `AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to `<NSURLSessionTaskDelegate>`, `<NSURLSessionDataDelegate>`, `<NSURLSessionDownloadDelegate>`, and `<NSURLSessionDelegate>`.
106
+
107
+ #### Creating a Download Task
108
+
109
+ ```objective-c
110
+ NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
111
+ AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
112
+
113
+ NSURL *URL = [NSURL URLWithString:@"http://example.com/download.zip"];
114
+ NSURLRequest *request = [NSURLRequest requestWithURL:URL];
115
+
116
+ NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
117
+ NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
118
+ return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];
119
+ } completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
120
+ NSLog(@"File downloaded to: %@", filePath);
121
+ }];
122
+ [downloadTask resume];
123
+ ```
124
+
125
+ #### Creating an Upload Task
126
+
127
+ ```objective-c
128
+ NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
129
+ AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
130
+
131
+ NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"];
132
+ NSURLRequest *request = [NSURLRequest requestWithURL:URL];
133
+
134
+ NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"];
135
+ NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithRequest:request fromFile:filePath progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
136
+ if (error) {
137
+ NSLog(@"Error: %@", error);
138
+ } else {
139
+ NSLog(@"Success: %@ %@", response, responseObject);
140
+ }
141
+ }];
142
+ [uploadTask resume];
143
+ ```
144
+
145
+ #### Creating an Upload Task for a Multi-Part Request, with Progress
146
+
147
+ ```objective-c
148
+ NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
149
+ [formData appendPartWithFileURL:[NSURL fileURLWithPath:@"file://path/to/image.jpg"] name:@"file" fileName:@"filename.jpg" mimeType:@"image/jpeg" error:nil];
150
+ } error:nil];
151
+
152
+ AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
153
+
154
+ NSURLSessionUploadTask *uploadTask;
155
+ uploadTask = [manager
156
+ uploadTaskWithStreamedRequest:request
157
+ progress:^(NSProgress * _Nonnull uploadProgress) {
158
+ // This is not called back on the main queue.
159
+ // You are responsible for dispatching to the main queue for UI updates
160
+ dispatch_async(dispatch_get_main_queue(), ^{
161
+ //Update the progress view
162
+ [progressView setProgress:uploadProgress.fractionCompleted];
163
+ });
164
+ }
165
+ completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
166
+ if (error) {
167
+ NSLog(@"Error: %@", error);
168
+ } else {
169
+ NSLog(@"%@ %@", response, responseObject);
170
+ }
171
+ }];
172
+
173
+ [uploadTask resume];
174
+ ```
175
+
176
+ #### Creating a Data Task
177
+
178
+ ```objective-c
179
+ NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
180
+ AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
181
+
182
+ NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/get"];
183
+ NSURLRequest *request = [NSURLRequest requestWithURL:URL];
184
+
185
+ NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
186
+ if (error) {
187
+ NSLog(@"Error: %@", error);
188
+ } else {
189
+ NSLog(@"%@ %@", response, responseObject);
190
+ }
191
+ }];
192
+ [dataTask resume];
193
+ ```
194
+
195
+ ---
196
+
197
+ ### Request Serialization
198
+
199
+ Request serializers create requests from URL strings, encoding parameters as either a query string or HTTP body.
200
+
201
+ ```objective-c
202
+ NSString *URLString = @"http://example.com";
203
+ NSDictionary *parameters = @{@"foo": @"bar", @"baz": @[@1, @2, @3]};
204
+ ```
205
+
206
+ #### Query String Parameter Encoding
207
+
208
+ ```objective-c
209
+ [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:URLString parameters:parameters error:nil];
210
+ ```
211
+
212
+ GET http://example.com?foo=bar&baz[]=1&baz[]=2&baz[]=3
213
+
214
+ #### URL Form Parameter Encoding
215
+
216
+ ```objective-c
217
+ [[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters error:nil];
218
+ ```
219
+
220
+ POST http://example.com/
221
+ Content-Type: application/x-www-form-urlencoded
222
+
223
+ foo=bar&baz[]=1&baz[]=2&baz[]=3
224
+
225
+ #### JSON Parameter Encoding
226
+
227
+ ```objective-c
228
+ [[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters error:nil];
229
+ ```
230
+
231
+ POST http://example.com/
232
+ Content-Type: application/json
233
+
234
+ {"foo": "bar", "baz": [1,2,3]}
235
+
236
+ ---
237
+
238
+ ### Network Reachability Manager
239
+
240
+ `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
241
+
242
+ * Do not use Reachability to determine if the original request should be sent.
243
+ * You should try to send it.
244
+ * You can use Reachability to determine when a request should be automatically retried.
245
+ * Although it may still fail, a Reachability notification that the connectivity is available is a good time to retry something.
246
+ * Network reachability is a useful tool for determining why a request might have failed.
247
+ * After a network request has failed, telling the user they're offline is better than giving them a more technical but accurate error, such as "request timed out."
248
+
249
+ See also [WWDC 2012 session 706, "Networking Best Practices."](https://developer.apple.com/videos/play/wwdc2012-706/).
250
+
251
+ #### Shared Network Reachability
252
+
253
+ ```objective-c
254
+ [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
255
+ NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status));
256
+ }];
257
+
258
+ [[AFNetworkReachabilityManager sharedManager] startMonitoring];
259
+ ```
260
+
261
+ ---
262
+
263
+ ### Security Policy
264
+
265
+ `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections.
266
+
267
+ Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled.
268
+
269
+ #### Allowing Invalid SSL Certificates
270
+
271
+ ```objective-c
272
+ AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
273
+ manager.securityPolicy.allowInvalidCertificates = YES; // not recommended for production
274
+ ```
275
+
276
+ ---
277
+
278
+ ## Unit Tests
279
+
280
+ AFNetworking includes a suite of unit tests within the Tests subdirectory. These tests can be run simply be executed the test action on the platform framework you would like to test.
281
+
282
+ ## Credits
283
+
284
+ AFNetworking is owned and maintained by the [Alamofire Software Foundation](http://alamofire.org).
285
+
286
+ AFNetworking was originally created by [Scott Raymond](https://github.com/sco/) and [Mattt Thompson](https://github.com/mattt/) in the development of [Gowalla for iPhone](http://en.wikipedia.org/wiki/Gowalla).
287
+
288
+ AFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/).
289
+
290
+ And most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/contributors).
291
+
292
+ ### Security Disclosure
293
+
294
+ If you believe you have identified a security vulnerability with AFNetworking, you should report it as soon as possible via email to [email protected]. Please do not post it to a public issue tracker.
295
+
296
+ ## License
297
+
298
+ AFNetworking is released under the MIT license. See [LICENSE](https://github.com/AFNetworking/AFNetworking/blob/master/LICENSE) for details.
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFAutoPurgingImageCache.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 <TargetConditionals.h>
23
+ #import <Foundation/Foundation.h>
24
+
25
+ #if TARGET_OS_IOS || TARGET_OS_TV
26
+ #import <UIKit/UIKit.h>
27
+
28
+ NS_ASSUME_NONNULL_BEGIN
29
+
30
+ /**
31
+ The `AFImageCache` protocol defines a set of APIs for adding, removing and fetching images from a cache synchronously.
32
+ */
33
+ @protocol AFImageCache <NSObject>
34
+
35
+ /**
36
+ Adds the image to the cache with the given identifier.
37
+
38
+ @param image The image to cache.
39
+ @param identifier The unique identifier for the image in the cache.
40
+ */
41
+ - (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier;
42
+
43
+ /**
44
+ Removes the image from the cache matching the given identifier.
45
+
46
+ @param identifier The unique identifier for the image in the cache.
47
+
48
+ @return A BOOL indicating whether or not the image was removed from the cache.
49
+ */
50
+ - (BOOL)removeImageWithIdentifier:(NSString *)identifier;
51
+
52
+ /**
53
+ Removes all images from the cache.
54
+
55
+ @return A BOOL indicating whether or not all images were removed from the cache.
56
+ */
57
+ - (BOOL)removeAllImages;
58
+
59
+ /**
60
+ Returns the image in the cache associated with the given identifier.
61
+
62
+ @param identifier The unique identifier for the image in the cache.
63
+
64
+ @return An image for the matching identifier, or nil.
65
+ */
66
+ - (nullable UIImage *)imageWithIdentifier:(NSString *)identifier;
67
+ @end
68
+
69
+
70
+ /**
71
+ The `ImageRequestCache` protocol extends the `ImageCache` protocol by adding methods for adding, removing and fetching images from a cache given an `NSURLRequest` and additional identifier.
72
+ */
73
+ @protocol AFImageRequestCache <AFImageCache>
74
+
75
+ /**
76
+ Asks if the image should be cached using an identifier created from the request and additional identifier.
77
+
78
+ @param image The image to be cached.
79
+ @param request The unique URL request identifing the image asset.
80
+ @param identifier The additional identifier to apply to the URL request to identify the image.
81
+
82
+ @return A BOOL indicating whether or not the image should be added to the cache. YES will cache, NO will prevent caching.
83
+ */
84
+ - (BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
85
+
86
+ /**
87
+ Adds the image to the cache using an identifier created from the request and additional identifier.
88
+
89
+ @param image The image to cache.
90
+ @param request The unique URL request identifing the image asset.
91
+ @param identifier The additional identifier to apply to the URL request to identify the image.
92
+ */
93
+ - (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
94
+
95
+ /**
96
+ Removes the image from the cache using an identifier created from the request and additional identifier.
97
+
98
+ @param request The unique URL request identifing the image asset.
99
+ @param identifier The additional identifier to apply to the URL request to identify the image.
100
+
101
+ @return A BOOL indicating whether or not all images were removed from the cache.
102
+ */
103
+ - (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
104
+
105
+ /**
106
+ Returns the image from the cache associated with an identifier created from the request and additional identifier.
107
+
108
+ @param request The unique URL request identifing the image asset.
109
+ @param identifier The additional identifier to apply to the URL request to identify the image.
110
+
111
+ @return An image for the matching request and identifier, or nil.
112
+ */
113
+ - (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
114
+
115
+ @end
116
+
117
+ /**
118
+ The `AutoPurgingImageCache` in an in-memory image cache used to store images up to a given memory capacity. When the memory capacity is reached, the image cache is sorted by last access date, then the oldest image is continuously purged until the preferred memory usage after purge is met. Each time an image is accessed through the cache, the internal access date of the image is updated.
119
+ */
120
+ @interface AFAutoPurgingImageCache : NSObject <AFImageRequestCache>
121
+
122
+ /**
123
+ The total memory capacity of the cache in bytes.
124
+ */
125
+ @property (nonatomic, assign) UInt64 memoryCapacity;
126
+
127
+ /**
128
+ The preferred memory usage after purge in bytes. During a purge, images will be purged until the memory capacity drops below this limit.
129
+ */
130
+ @property (nonatomic, assign) UInt64 preferredMemoryUsageAfterPurge;
131
+
132
+ /**
133
+ The current total memory usage in bytes of all images stored within the cache.
134
+ */
135
+ @property (nonatomic, assign, readonly) UInt64 memoryUsage;
136
+
137
+ /**
138
+ Initialies the `AutoPurgingImageCache` instance with default values for memory capacity and preferred memory usage after purge limit. `memoryCapcity` defaults to `100 MB`. `preferredMemoryUsageAfterPurge` defaults to `60 MB`.
139
+
140
+ @return The new `AutoPurgingImageCache` instance.
141
+ */
142
+ - (instancetype)init;
143
+
144
+ /**
145
+ Initialies the `AutoPurgingImageCache` instance with the given memory capacity and preferred memory usage
146
+ after purge limit.
147
+
148
+ @param memoryCapacity The total memory capacity of the cache in bytes.
149
+ @param preferredMemoryCapacity The preferred memory usage after purge in bytes.
150
+
151
+ @return The new `AutoPurgingImageCache` instance.
152
+ */
153
+ - (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity;
154
+
155
+ @end
156
+
157
+ NS_ASSUME_NONNULL_END
158
+
159
+ #endif
160
+
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFAutoPurgingImageCache.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 <TargetConditionals.h>
23
+
24
+ #if TARGET_OS_IOS || TARGET_OS_TV
25
+
26
+ #import "AFAutoPurgingImageCache.h"
27
+
28
+ @interface AFCachedImage : NSObject
29
+
30
+ @property (nonatomic, strong) UIImage *image;
31
+ @property (nonatomic, copy) NSString *identifier;
32
+ @property (nonatomic, assign) UInt64 totalBytes;
33
+ @property (nonatomic, strong) NSDate *lastAccessDate;
34
+ @property (nonatomic, assign) UInt64 currentMemoryUsage;
35
+
36
+ @end
37
+
38
+ @implementation AFCachedImage
39
+
40
+ - (instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier {
41
+ if (self = [self init]) {
42
+ self.image = image;
43
+ self.identifier = identifier;
44
+
45
+ CGSize imageSize = CGSizeMake(image.size.width * image.scale, image.size.height * image.scale);
46
+ CGFloat bytesPerPixel = 4.0;
47
+ CGFloat bytesPerSize = imageSize.width * imageSize.height;
48
+ self.totalBytes = (UInt64)bytesPerPixel * (UInt64)bytesPerSize;
49
+ self.lastAccessDate = [NSDate date];
50
+ }
51
+ return self;
52
+ }
53
+
54
+ - (UIImage *)accessImage {
55
+ self.lastAccessDate = [NSDate date];
56
+ return self.image;
57
+ }
58
+
59
+ - (NSString *)description {
60
+ NSString *descriptionString = [NSString stringWithFormat:@"Idenfitier: %@ lastAccessDate: %@ ", self.identifier, self.lastAccessDate];
61
+ return descriptionString;
62
+
63
+ }
64
+
65
+ @end
66
+
67
+ @interface AFAutoPurgingImageCache ()
68
+ @property (nonatomic, strong) NSMutableDictionary <NSString* , AFCachedImage*> *cachedImages;
69
+ @property (nonatomic, assign) UInt64 currentMemoryUsage;
70
+ @property (nonatomic, strong) dispatch_queue_t synchronizationQueue;
71
+ @end
72
+
73
+ @implementation AFAutoPurgingImageCache
74
+
75
+ - (instancetype)init {
76
+ return [self initWithMemoryCapacity:100 * 1024 * 1024 preferredMemoryCapacity:60 * 1024 * 1024];
77
+ }
78
+
79
+ - (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity {
80
+ if (self = [super init]) {
81
+ self.memoryCapacity = memoryCapacity;
82
+ self.preferredMemoryUsageAfterPurge = preferredMemoryCapacity;
83
+ self.cachedImages = [[NSMutableDictionary alloc] init];
84
+
85
+ NSString *queueName = [NSString stringWithFormat:@"com.alamofire.autopurgingimagecache-%@", [[NSUUID UUID] UUIDString]];
86
+ self.synchronizationQueue = dispatch_queue_create([queueName cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT);
87
+
88
+ [[NSNotificationCenter defaultCenter]
89
+ addObserver:self
90
+ selector:@selector(removeAllImages)
91
+ name:UIApplicationDidReceiveMemoryWarningNotification
92
+ object:nil];
93
+
94
+ }
95
+ return self;
96
+ }
97
+
98
+ - (void)dealloc {
99
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
100
+ }
101
+
102
+ - (UInt64)memoryUsage {
103
+ __block UInt64 result = 0;
104
+ dispatch_sync(self.synchronizationQueue, ^{
105
+ result = self.currentMemoryUsage;
106
+ });
107
+ return result;
108
+ }
109
+
110
+ - (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier {
111
+ dispatch_barrier_async(self.synchronizationQueue, ^{
112
+ AFCachedImage *cacheImage = [[AFCachedImage alloc] initWithImage:image identifier:identifier];
113
+
114
+ AFCachedImage *previousCachedImage = self.cachedImages[identifier];
115
+ if (previousCachedImage != nil) {
116
+ self.currentMemoryUsage -= previousCachedImage.totalBytes;
117
+ }
118
+
119
+ self.cachedImages[identifier] = cacheImage;
120
+ self.currentMemoryUsage += cacheImage.totalBytes;
121
+ });
122
+
123
+ dispatch_barrier_async(self.synchronizationQueue, ^{
124
+ if (self.currentMemoryUsage > self.memoryCapacity) {
125
+ UInt64 bytesToPurge = self.currentMemoryUsage - self.preferredMemoryUsageAfterPurge;
126
+ NSMutableArray <AFCachedImage*> *sortedImages = [NSMutableArray arrayWithArray:self.cachedImages.allValues];
127
+ NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lastAccessDate"
128
+ ascending:YES];
129
+ [sortedImages sortUsingDescriptors:@[sortDescriptor]];
130
+
131
+ UInt64 bytesPurged = 0;
132
+
133
+ for (AFCachedImage *cachedImage in sortedImages) {
134
+ [self.cachedImages removeObjectForKey:cachedImage.identifier];
135
+ bytesPurged += cachedImage.totalBytes;
136
+ if (bytesPurged >= bytesToPurge) {
137
+ break;
138
+ }
139
+ }
140
+ self.currentMemoryUsage -= bytesPurged;
141
+ }
142
+ });
143
+ }
144
+
145
+ - (BOOL)removeImageWithIdentifier:(NSString *)identifier {
146
+ __block BOOL removed = NO;
147
+ dispatch_barrier_sync(self.synchronizationQueue, ^{
148
+ AFCachedImage *cachedImage = self.cachedImages[identifier];
149
+ if (cachedImage != nil) {
150
+ [self.cachedImages removeObjectForKey:identifier];
151
+ self.currentMemoryUsage -= cachedImage.totalBytes;
152
+ removed = YES;
153
+ }
154
+ });
155
+ return removed;
156
+ }
157
+
158
+ - (BOOL)removeAllImages {
159
+ __block BOOL removed = NO;
160
+ dispatch_barrier_sync(self.synchronizationQueue, ^{
161
+ if (self.cachedImages.count > 0) {
162
+ [self.cachedImages removeAllObjects];
163
+ self.currentMemoryUsage = 0;
164
+ removed = YES;
165
+ }
166
+ });
167
+ return removed;
168
+ }
169
+
170
+ - (nullable UIImage *)imageWithIdentifier:(NSString *)identifier {
171
+ __block UIImage *image = nil;
172
+ dispatch_sync(self.synchronizationQueue, ^{
173
+ AFCachedImage *cachedImage = self.cachedImages[identifier];
174
+ image = [cachedImage accessImage];
175
+ });
176
+ return image;
177
+ }
178
+
179
+ - (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
180
+ [self addImage:image withIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]];
181
+ }
182
+
183
+ - (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
184
+ return [self removeImageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]];
185
+ }
186
+
187
+ - (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
188
+ return [self imageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]];
189
+ }
190
+
191
+ - (NSString *)imageCacheKeyFromURLRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)additionalIdentifier {
192
+ NSString *key = request.URL.absoluteString;
193
+ if (additionalIdentifier != nil) {
194
+ key = [key stringByAppendingString:additionalIdentifier];
195
+ }
196
+ return key;
197
+ }
198
+
199
+ - (BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier {
200
+ return YES;
201
+ }
202
+
203
+ @end
204
+
205
+ #endif
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFImageDownloader.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 <TargetConditionals.h>
23
+
24
+ #if TARGET_OS_IOS || TARGET_OS_TV
25
+
26
+ #import <Foundation/Foundation.h>
27
+ #import "AFAutoPurgingImageCache.h"
28
+ #import "AFHTTPSessionManager.h"
29
+
30
+ NS_ASSUME_NONNULL_BEGIN
31
+
32
+ typedef NS_ENUM(NSInteger, AFImageDownloadPrioritization) {
33
+ AFImageDownloadPrioritizationFIFO,
34
+ AFImageDownloadPrioritizationLIFO
35
+ };
36
+
37
+ /**
38
+ The `AFImageDownloadReceipt` is an object vended by the `AFImageDownloader` when starting a data task. It can be used to cancel active tasks running on the `AFImageDownloader` session. As a general rule, image data tasks should be cancelled using the `AFImageDownloadReceipt` instead of calling `cancel` directly on the `task` itself. The `AFImageDownloader` is optimized to handle duplicate task scenarios as well as pending versus active downloads.
39
+ */
40
+ @interface AFImageDownloadReceipt : NSObject
41
+
42
+ /**
43
+ The data task created by the `AFImageDownloader`.
44
+ */
45
+ @property (nonatomic, strong) NSURLSessionDataTask *task;
46
+
47
+ /**
48
+ The unique identifier for the success and failure blocks when duplicate requests are made.
49
+ */
50
+ @property (nonatomic, strong) NSUUID *receiptID;
51
+ @end
52
+
53
+ /** The `AFImageDownloader` class is responsible for downloading images in parallel on a prioritized queue. Incoming downloads are added to the front or back of the queue depending on the download prioritization. Each downloaded image is cached in the underlying `NSURLCache` as well as the in-memory image cache. By default, any download request with a cached image equivalent in the image cache will automatically be served the cached image representation.
54
+ */
55
+ @interface AFImageDownloader : NSObject
56
+
57
+ /**
58
+ The image cache used to store all downloaded images in. `AFAutoPurgingImageCache` by default.
59
+ */
60
+ @property (nonatomic, strong, nullable) id <AFImageRequestCache> imageCache;
61
+
62
+ /**
63
+ The `AFHTTPSessionManager` used to download images. By default, this is configured with an `AFImageResponseSerializer`, and a shared `NSURLCache` for all image downloads.
64
+ */
65
+ @property (nonatomic, strong) AFHTTPSessionManager *sessionManager;
66
+
67
+ /**
68
+ Defines the order prioritization of incoming download requests being inserted into the queue. `AFImageDownloadPrioritizationFIFO` by default.
69
+ */
70
+ @property (nonatomic, assign) AFImageDownloadPrioritization downloadPrioritization;
71
+
72
+ /**
73
+ The shared default instance of `AFImageDownloader` initialized with default values.
74
+ */
75
+ + (instancetype)defaultInstance;
76
+
77
+ /**
78
+ Creates a default `NSURLCache` with common usage parameter values.
79
+
80
+ @returns The default `NSURLCache` instance.
81
+ */
82
+ + (NSURLCache *)defaultURLCache;
83
+
84
+ /**
85
+ The default `NSURLSessionConfiguration` with common usage parameter values.
86
+ */
87
+ + (NSURLSessionConfiguration *)defaultURLSessionConfiguration;
88
+
89
+ /**
90
+ Default initializer
91
+
92
+ @return An instance of `AFImageDownloader` initialized with default values.
93
+ */
94
+ - (instancetype)init;
95
+
96
+ /**
97
+ Initializer with specific `URLSessionConfiguration`
98
+
99
+ @param configuration The `NSURLSessionConfiguration` to be be used
100
+
101
+ @return An instance of `AFImageDownloader` initialized with default values and custom `NSURLSessionConfiguration`
102
+ */
103
+ - (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration;
104
+
105
+ /**
106
+ Initializes the `AFImageDownloader` instance with the given session manager, download prioritization, maximum active download count and image cache.
107
+
108
+ @param sessionManager The session manager to use to download images.
109
+ @param downloadPrioritization The download prioritization of the download queue.
110
+ @param maximumActiveDownloads The maximum number of active downloads allowed at any given time. Recommend `4`.
111
+ @param imageCache The image cache used to store all downloaded images in.
112
+
113
+ @return The new `AFImageDownloader` instance.
114
+ */
115
+ - (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager
116
+ downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization
117
+ maximumActiveDownloads:(NSInteger)maximumActiveDownloads
118
+ imageCache:(nullable id <AFImageRequestCache>)imageCache;
119
+
120
+ /**
121
+ Creates a data task using the `sessionManager` instance for the specified URL request.
122
+
123
+ If the same data task is already in the queue or currently being downloaded, the success and failure blocks are
124
+ appended to the already existing task. Once the task completes, all success or failure blocks attached to the
125
+ task are executed in the order they were added.
126
+
127
+ @param request The URL request.
128
+ @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
129
+ @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
130
+
131
+ @return The image download receipt for the data task if available. `nil` if the image is stored in the cache.
132
+ cache and the URL request cache policy allows the cache to be used.
133
+ */
134
+ - (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
135
+ success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
136
+ failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
137
+
138
+ /**
139
+ Creates a data task using the `sessionManager` instance for the specified URL request.
140
+
141
+ If the same data task is already in the queue or currently being downloaded, the success and failure blocks are
142
+ appended to the already existing task. Once the task completes, all success or failure blocks attached to the
143
+ task are executed in the order they were added.
144
+
145
+ @param request The URL request.
146
+ @param receiptID The identifier to use for the download receipt that will be created for this request. This must be a unique identifier that does not represent any other request.
147
+ @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
148
+ @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
149
+
150
+ @return The image download receipt for the data task if available. `nil` if the image is stored in the cache.
151
+ cache and the URL request cache policy allows the cache to be used.
152
+ */
153
+ - (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
154
+ withReceiptID:(NSUUID *)receiptID
155
+ success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
156
+ failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
157
+
158
+ /**
159
+ Cancels the data task in the receipt by removing the corresponding success and failure blocks and cancelling the data task if necessary.
160
+
161
+ If the data task is pending in the queue, it will be cancelled if no other success and failure blocks are registered with the data task. If the data task is currently executing or is already completed, the success and failure blocks are removed and will not be called when the task finishes.
162
+
163
+ @param imageDownloadReceipt The image download receipt to cancel.
164
+ */
165
+ - (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt;
166
+
167
+ @end
168
+
169
+ #endif
170
+
171
+ NS_ASSUME_NONNULL_END
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m ADDED
@@ -0,0 +1,421 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFImageDownloader.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 <TargetConditionals.h>
23
+
24
+ #if TARGET_OS_IOS || TARGET_OS_TV
25
+
26
+ #import "AFImageDownloader.h"
27
+ #import "AFHTTPSessionManager.h"
28
+
29
+ @interface AFImageDownloaderResponseHandler : NSObject
30
+ @property (nonatomic, strong) NSUUID *uuid;
31
+ @property (nonatomic, copy) void (^successBlock)(NSURLRequest *, NSHTTPURLResponse *, UIImage *);
32
+ @property (nonatomic, copy) void (^failureBlock)(NSURLRequest *, NSHTTPURLResponse *, NSError *);
33
+ @end
34
+
35
+ @implementation AFImageDownloaderResponseHandler
36
+
37
+ - (instancetype)initWithUUID:(NSUUID *)uuid
38
+ success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
39
+ failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure {
40
+ if (self = [self init]) {
41
+ self.uuid = uuid;
42
+ self.successBlock = success;
43
+ self.failureBlock = failure;
44
+ }
45
+ return self;
46
+ }
47
+
48
+ - (NSString *)description {
49
+ return [NSString stringWithFormat: @"<AFImageDownloaderResponseHandler>UUID: %@", [self.uuid UUIDString]];
50
+ }
51
+
52
+ @end
53
+
54
+ @interface AFImageDownloaderMergedTask : NSObject
55
+ @property (nonatomic, strong) NSString *URLIdentifier;
56
+ @property (nonatomic, strong) NSUUID *identifier;
57
+ @property (nonatomic, strong) NSURLSessionDataTask *task;
58
+ @property (nonatomic, strong) NSMutableArray <AFImageDownloaderResponseHandler*> *responseHandlers;
59
+
60
+ @end
61
+
62
+ @implementation AFImageDownloaderMergedTask
63
+
64
+ - (instancetype)initWithURLIdentifier:(NSString *)URLIdentifier identifier:(NSUUID *)identifier task:(NSURLSessionDataTask *)task {
65
+ if (self = [self init]) {
66
+ self.URLIdentifier = URLIdentifier;
67
+ self.task = task;
68
+ self.identifier = identifier;
69
+ self.responseHandlers = [[NSMutableArray alloc] init];
70
+ }
71
+ return self;
72
+ }
73
+
74
+ - (void)addResponseHandler:(AFImageDownloaderResponseHandler *)handler {
75
+ [self.responseHandlers addObject:handler];
76
+ }
77
+
78
+ - (void)removeResponseHandler:(AFImageDownloaderResponseHandler *)handler {
79
+ [self.responseHandlers removeObject:handler];
80
+ }
81
+
82
+ @end
83
+
84
+ @implementation AFImageDownloadReceipt
85
+
86
+ - (instancetype)initWithReceiptID:(NSUUID *)receiptID task:(NSURLSessionDataTask *)task {
87
+ if (self = [self init]) {
88
+ self.receiptID = receiptID;
89
+ self.task = task;
90
+ }
91
+ return self;
92
+ }
93
+
94
+ @end
95
+
96
+ @interface AFImageDownloader ()
97
+
98
+ @property (nonatomic, strong) dispatch_queue_t synchronizationQueue;
99
+ @property (nonatomic, strong) dispatch_queue_t responseQueue;
100
+
101
+ @property (nonatomic, assign) NSInteger maximumActiveDownloads;
102
+ @property (nonatomic, assign) NSInteger activeRequestCount;
103
+
104
+ @property (nonatomic, strong) NSMutableArray *queuedMergedTasks;
105
+ @property (nonatomic, strong) NSMutableDictionary *mergedTasks;
106
+
107
+ @end
108
+
109
+ @implementation AFImageDownloader
110
+
111
+ + (NSURLCache *)defaultURLCache {
112
+ NSUInteger memoryCapacity = 20 * 1024 * 1024; // 20MB
113
+ NSUInteger diskCapacity = 150 * 1024 * 1024; // 150MB
114
+ NSURL *cacheURL = [[[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory
115
+ inDomain:NSUserDomainMask
116
+ appropriateForURL:nil
117
+ create:YES
118
+ error:nil]
119
+ URLByAppendingPathComponent:@"com.alamofire.imagedownloader"];
120
+
121
+ #if TARGET_OS_MACCATALYST
122
+ return [[NSURLCache alloc] initWithMemoryCapacity:memoryCapacity
123
+ diskCapacity:diskCapacity
124
+ directoryURL:cacheURL];
125
+ #else
126
+ return [[NSURLCache alloc] initWithMemoryCapacity:memoryCapacity
127
+ diskCapacity:diskCapacity
128
+ diskPath:[cacheURL path]];
129
+ #endif
130
+ }
131
+
132
+ + (NSURLSessionConfiguration *)defaultURLSessionConfiguration {
133
+ NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
134
+
135
+ //TODO set the default HTTP headers
136
+
137
+ configuration.HTTPShouldSetCookies = YES;
138
+ configuration.HTTPShouldUsePipelining = NO;
139
+
140
+ configuration.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
141
+ configuration.allowsCellularAccess = YES;
142
+ configuration.timeoutIntervalForRequest = 60.0;
143
+ configuration.URLCache = [AFImageDownloader defaultURLCache];
144
+
145
+ return configuration;
146
+ }
147
+
148
+ - (instancetype)init {
149
+ NSURLSessionConfiguration *defaultConfiguration = [self.class defaultURLSessionConfiguration];
150
+ return [self initWithSessionConfiguration:defaultConfiguration];
151
+ }
152
+
153
+ - (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration {
154
+ AFHTTPSessionManager *sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:configuration];
155
+ sessionManager.responseSerializer = [AFImageResponseSerializer serializer];
156
+
157
+ return [self initWithSessionManager:sessionManager
158
+ downloadPrioritization:AFImageDownloadPrioritizationFIFO
159
+ maximumActiveDownloads:4
160
+ imageCache:[[AFAutoPurgingImageCache alloc] init]];
161
+ }
162
+
163
+ - (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager
164
+ downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization
165
+ maximumActiveDownloads:(NSInteger)maximumActiveDownloads
166
+ imageCache:(id <AFImageRequestCache>)imageCache {
167
+ if (self = [super init]) {
168
+ self.sessionManager = sessionManager;
169
+
170
+ self.downloadPrioritization = downloadPrioritization;
171
+ self.maximumActiveDownloads = maximumActiveDownloads;
172
+ self.imageCache = imageCache;
173
+
174
+ self.queuedMergedTasks = [[NSMutableArray alloc] init];
175
+ self.mergedTasks = [[NSMutableDictionary alloc] init];
176
+ self.activeRequestCount = 0;
177
+
178
+ NSString *name = [NSString stringWithFormat:@"com.alamofire.imagedownloader.synchronizationqueue-%@", [[NSUUID UUID] UUIDString]];
179
+ self.synchronizationQueue = dispatch_queue_create([name cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_SERIAL);
180
+
181
+ name = [NSString stringWithFormat:@"com.alamofire.imagedownloader.responsequeue-%@", [[NSUUID UUID] UUIDString]];
182
+ self.responseQueue = dispatch_queue_create([name cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT);
183
+ }
184
+
185
+ return self;
186
+ }
187
+
188
+ + (instancetype)defaultInstance {
189
+ static AFImageDownloader *sharedInstance = nil;
190
+ static dispatch_once_t onceToken;
191
+ dispatch_once(&onceToken, ^{
192
+ sharedInstance = [[self alloc] init];
193
+ });
194
+ return sharedInstance;
195
+ }
196
+
197
+ - (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
198
+ success:(void (^)(NSURLRequest * _Nonnull, NSHTTPURLResponse * _Nullable, UIImage * _Nonnull))success
199
+ failure:(void (^)(NSURLRequest * _Nonnull, NSHTTPURLResponse * _Nullable, NSError * _Nonnull))failure {
200
+ return [self downloadImageForURLRequest:request withReceiptID:[NSUUID UUID] success:success failure:failure];
201
+ }
202
+
203
+ - (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
204
+ withReceiptID:(nonnull NSUUID *)receiptID
205
+ success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
206
+ failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure {
207
+ __block NSURLSessionDataTask *task = nil;
208
+ dispatch_sync(self.synchronizationQueue, ^{
209
+ NSString *URLIdentifier = request.URL.absoluteString;
210
+ if (URLIdentifier == nil) {
211
+ if (failure) {
212
+ NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadURL userInfo:nil];
213
+ dispatch_async(dispatch_get_main_queue(), ^{
214
+ failure(request, nil, error);
215
+ });
216
+ }
217
+ return;
218
+ }
219
+
220
+ // 1) Append the success and failure blocks to a pre-existing request if it already exists
221
+ AFImageDownloaderMergedTask *existingMergedTask = self.mergedTasks[URLIdentifier];
222
+ if (existingMergedTask != nil) {
223
+ AFImageDownloaderResponseHandler *handler = [[AFImageDownloaderResponseHandler alloc] initWithUUID:receiptID success:success failure:failure];
224
+ [existingMergedTask addResponseHandler:handler];
225
+ task = existingMergedTask.task;
226
+ return;
227
+ }
228
+
229
+ // 2) Attempt to load the image from the image cache if the cache policy allows it
230
+ switch (request.cachePolicy) {
231
+ case NSURLRequestUseProtocolCachePolicy:
232
+ case NSURLRequestReturnCacheDataElseLoad:
233
+ case NSURLRequestReturnCacheDataDontLoad: {
234
+ UIImage *cachedImage = [self.imageCache imageforRequest:request withAdditionalIdentifier:nil];
235
+ if (cachedImage != nil) {
236
+ if (success) {
237
+ dispatch_async(dispatch_get_main_queue(), ^{
238
+ success(request, nil, cachedImage);
239
+ });
240
+ }
241
+ return;
242
+ }
243
+ break;
244
+ }
245
+ default:
246
+ break;
247
+ }
248
+
249
+ // 3) Create the request and set up authentication, validation and response serialization
250
+ NSUUID *mergedTaskIdentifier = [NSUUID UUID];
251
+ NSURLSessionDataTask *createdTask;
252
+ __weak __typeof__(self) weakSelf = self;
253
+
254
+ createdTask = [self.sessionManager
255
+ dataTaskWithRequest:request
256
+ uploadProgress:nil
257
+ downloadProgress:nil
258
+ completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
259
+ dispatch_async(self.responseQueue, ^{
260
+ __strong __typeof__(weakSelf) strongSelf = weakSelf;
261
+ AFImageDownloaderMergedTask *mergedTask = [strongSelf safelyGetMergedTask:URLIdentifier];
262
+ if ([mergedTask.identifier isEqual:mergedTaskIdentifier]) {
263
+ mergedTask = [strongSelf safelyRemoveMergedTaskWithURLIdentifier:URLIdentifier];
264
+ if (error) {
265
+ for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) {
266
+ if (handler.failureBlock) {
267
+ dispatch_async(dispatch_get_main_queue(), ^{
268
+ handler.failureBlock(request, (NSHTTPURLResponse *)response, error);
269
+ });
270
+ }
271
+ }
272
+ } else {
273
+ if ([strongSelf.imageCache shouldCacheImage:responseObject forRequest:request withAdditionalIdentifier:nil]) {
274
+ [strongSelf.imageCache addImage:responseObject forRequest:request withAdditionalIdentifier:nil];
275
+ }
276
+
277
+ for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) {
278
+ if (handler.successBlock) {
279
+ dispatch_async(dispatch_get_main_queue(), ^{
280
+ handler.successBlock(request, (NSHTTPURLResponse *)response, responseObject);
281
+ });
282
+ }
283
+ }
284
+
285
+ }
286
+ }
287
+ [strongSelf safelyDecrementActiveTaskCount];
288
+ [strongSelf safelyStartNextTaskIfNecessary];
289
+ });
290
+ }];
291
+
292
+ // 4) Store the response handler for use when the request completes
293
+ AFImageDownloaderResponseHandler *handler = [[AFImageDownloaderResponseHandler alloc] initWithUUID:receiptID
294
+ success:success
295
+ failure:failure];
296
+ AFImageDownloaderMergedTask *mergedTask = [[AFImageDownloaderMergedTask alloc]
297
+ initWithURLIdentifier:URLIdentifier
298
+ identifier:mergedTaskIdentifier
299
+ task:createdTask];
300
+ [mergedTask addResponseHandler:handler];
301
+ self.mergedTasks[URLIdentifier] = mergedTask;
302
+
303
+ // 5) Either start the request or enqueue it depending on the current active request count
304
+ if ([self isActiveRequestCountBelowMaximumLimit]) {
305
+ [self startMergedTask:mergedTask];
306
+ } else {
307
+ [self enqueueMergedTask:mergedTask];
308
+ }
309
+
310
+ task = mergedTask.task;
311
+ });
312
+ if (task) {
313
+ return [[AFImageDownloadReceipt alloc] initWithReceiptID:receiptID task:task];
314
+ } else {
315
+ return nil;
316
+ }
317
+ }
318
+
319
+ - (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt {
320
+ dispatch_sync(self.synchronizationQueue, ^{
321
+ NSString *URLIdentifier = imageDownloadReceipt.task.originalRequest.URL.absoluteString;
322
+ AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[URLIdentifier];
323
+ NSUInteger index = [mergedTask.responseHandlers indexOfObjectPassingTest:^BOOL(AFImageDownloaderResponseHandler * _Nonnull handler, __unused NSUInteger idx, __unused BOOL * _Nonnull stop) {
324
+ return handler.uuid == imageDownloadReceipt.receiptID;
325
+ }];
326
+
327
+ if (index != NSNotFound) {
328
+ AFImageDownloaderResponseHandler *handler = mergedTask.responseHandlers[index];
329
+ [mergedTask removeResponseHandler:handler];
330
+ NSString *failureReason = [NSString stringWithFormat:@"ImageDownloader cancelled URL request: %@",imageDownloadReceipt.task.originalRequest.URL.absoluteString];
331
+ NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey:failureReason};
332
+ NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo];
333
+ if (handler.failureBlock) {
334
+ dispatch_async(dispatch_get_main_queue(), ^{
335
+ handler.failureBlock(imageDownloadReceipt.task.originalRequest, nil, error);
336
+ });
337
+ }
338
+ }
339
+
340
+ if (mergedTask.responseHandlers.count == 0) {
341
+ [mergedTask.task cancel];
342
+ [self removeMergedTaskWithURLIdentifier:URLIdentifier];
343
+ }
344
+ });
345
+ }
346
+
347
+ - (AFImageDownloaderMergedTask *)safelyRemoveMergedTaskWithURLIdentifier:(NSString *)URLIdentifier {
348
+ __block AFImageDownloaderMergedTask *mergedTask = nil;
349
+ dispatch_sync(self.synchronizationQueue, ^{
350
+ mergedTask = [self removeMergedTaskWithURLIdentifier:URLIdentifier];
351
+ });
352
+ return mergedTask;
353
+ }
354
+
355
+ //This method should only be called from safely within the synchronizationQueue
356
+ - (AFImageDownloaderMergedTask *)removeMergedTaskWithURLIdentifier:(NSString *)URLIdentifier {
357
+ AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[URLIdentifier];
358
+ [self.mergedTasks removeObjectForKey:URLIdentifier];
359
+ return mergedTask;
360
+ }
361
+
362
+ - (void)safelyDecrementActiveTaskCount {
363
+ dispatch_sync(self.synchronizationQueue, ^{
364
+ if (self.activeRequestCount > 0) {
365
+ self.activeRequestCount -= 1;
366
+ }
367
+ });
368
+ }
369
+
370
+ - (void)safelyStartNextTaskIfNecessary {
371
+ dispatch_sync(self.synchronizationQueue, ^{
372
+ if ([self isActiveRequestCountBelowMaximumLimit]) {
373
+ while (self.queuedMergedTasks.count > 0) {
374
+ AFImageDownloaderMergedTask *mergedTask = [self dequeueMergedTask];
375
+ if (mergedTask.task.state == NSURLSessionTaskStateSuspended) {
376
+ [self startMergedTask:mergedTask];
377
+ break;
378
+ }
379
+ }
380
+ }
381
+ });
382
+ }
383
+
384
+ - (void)startMergedTask:(AFImageDownloaderMergedTask *)mergedTask {
385
+ [mergedTask.task resume];
386
+ ++self.activeRequestCount;
387
+ }
388
+
389
+ - (void)enqueueMergedTask:(AFImageDownloaderMergedTask *)mergedTask {
390
+ switch (self.downloadPrioritization) {
391
+ case AFImageDownloadPrioritizationFIFO:
392
+ [self.queuedMergedTasks addObject:mergedTask];
393
+ break;
394
+ case AFImageDownloadPrioritizationLIFO:
395
+ [self.queuedMergedTasks insertObject:mergedTask atIndex:0];
396
+ break;
397
+ }
398
+ }
399
+
400
+ - (AFImageDownloaderMergedTask *)dequeueMergedTask {
401
+ AFImageDownloaderMergedTask *mergedTask = nil;
402
+ mergedTask = [self.queuedMergedTasks firstObject];
403
+ [self.queuedMergedTasks removeObject:mergedTask];
404
+ return mergedTask;
405
+ }
406
+
407
+ - (BOOL)isActiveRequestCountBelowMaximumLimit {
408
+ return self.activeRequestCount < self.maximumActiveDownloads;
409
+ }
410
+
411
+ - (AFImageDownloaderMergedTask *)safelyGetMergedTask:(NSString *)URLIdentifier {
412
+ __block AFImageDownloaderMergedTask *mergedTask;
413
+ dispatch_sync(self.synchronizationQueue, ^(){
414
+ mergedTask = self.mergedTasks[URLIdentifier];
415
+ });
416
+ return mergedTask;
417
+ }
418
+
419
+ @end
420
+
421
+ #endif
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFNetworkActivityIndicatorManager.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 <Foundation/Foundation.h>
23
+
24
+ #import <TargetConditionals.h>
25
+
26
+ #if TARGET_OS_IOS
27
+
28
+ #import <UIKit/UIKit.h>
29
+
30
+ NS_ASSUME_NONNULL_BEGIN
31
+
32
+ /**
33
+ `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a session task has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero.
34
+
35
+ You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code:
36
+
37
+ [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
38
+
39
+ By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself.
40
+
41
+ See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information:
42
+ http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44
43
+ */
44
+ NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.")
45
+ @interface AFNetworkActivityIndicatorManager : NSObject
46
+
47
+ /**
48
+ A Boolean value indicating whether the manager is enabled.
49
+
50
+ If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO.
51
+ */
52
+ @property (nonatomic, assign, getter = isEnabled) BOOL enabled;
53
+
54
+ /**
55
+ A Boolean value indicating whether the network activity indicator manager is currently active.
56
+ */
57
+ @property (readonly, nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
58
+
59
+ /**
60
+ A time interval indicating the minimum duration of networking activity that should occur before the activity indicator is displayed. The default value 1 second. If the network activity indicator should be displayed immediately when network activity occurs, this value should be set to 0 seconds.
61
+
62
+ Apple's HIG describes the following:
63
+
64
+ > Display the network activity indicator to provide feedback when your app accesses the network for more than a couple of seconds. If the operation finishes sooner than that, you don’t have to show the network activity indicator, because the indicator is likely to disappear before users notice its presence.
65
+
66
+ */
67
+ @property (nonatomic, assign) NSTimeInterval activationDelay;
68
+
69
+ /**
70
+ A time interval indicating the duration of time of no networking activity required before the activity indicator is disabled. This allows for continuous display of the network activity indicator across multiple requests. The default value is 0.17 seconds.
71
+ */
72
+
73
+ @property (nonatomic, assign) NSTimeInterval completionDelay;
74
+
75
+ /**
76
+ Returns the shared network activity indicator manager object for the system.
77
+
78
+ @return The systemwide network activity indicator manager.
79
+ */
80
+ + (instancetype)sharedManager;
81
+
82
+ /**
83
+ Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator.
84
+ */
85
+ - (void)incrementActivityCount;
86
+
87
+ /**
88
+ Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator.
89
+ */
90
+ - (void)decrementActivityCount;
91
+
92
+ /**
93
+ Set the a custom method to be executed when the network activity indicator manager should be hidden/shown. By default, this is null, and the UIApplication Network Activity Indicator will be managed automatically. If this block is set, it is the responsiblity of the caller to manager the network activity indicator going forward.
94
+
95
+ @param block A block to be executed when the network activity indicator status changes.
96
+ */
97
+ - (void)setNetworkingActivityActionWithBlock:(nullable void (^)(BOOL networkActivityIndicatorVisible))block;
98
+
99
+ @end
100
+
101
+ NS_ASSUME_NONNULL_END
102
+
103
+ #endif
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // AFNetworkActivityIndicatorManager.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 "AFNetworkActivityIndicatorManager.h"
23
+
24
+ #if TARGET_OS_IOS
25
+ #import "AFURLSessionManager.h"
26
+
27
+ typedef NS_ENUM(NSInteger, AFNetworkActivityManagerState) {
28
+ AFNetworkActivityManagerStateNotActive,
29
+ AFNetworkActivityManagerStateDelayingStart,
30
+ AFNetworkActivityManagerStateActive,
31
+ AFNetworkActivityManagerStateDelayingEnd
32
+ };
33
+
34
+ static NSTimeInterval const kDefaultAFNetworkActivityManagerActivationDelay = 1.0;
35
+ static NSTimeInterval const kDefaultAFNetworkActivityManagerCompletionDelay = 0.17;
36
+
37
+ static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) {
38
+ if ([[notification object] respondsToSelector:@selector(originalRequest)]) {
39
+ return [(NSURLSessionTask *)[notification object] originalRequest];
40
+ } else {
41
+ return nil;
42
+ }
43
+ }
44
+
45
+ typedef void (^AFNetworkActivityActionBlock)(BOOL networkActivityIndicatorVisible);
46
+
47
+ @interface AFNetworkActivityIndicatorManager ()
48
+ @property (readwrite, nonatomic, assign) NSInteger activityCount;
49
+ @property (readwrite, nonatomic, strong) NSTimer *activationDelayTimer;
50
+ @property (readwrite, nonatomic, strong) NSTimer *completionDelayTimer;
51
+ @property (readonly, nonatomic, getter = isNetworkActivityOccurring) BOOL networkActivityOccurring;
52
+ @property (nonatomic, copy) AFNetworkActivityActionBlock networkActivityActionBlock;
53
+ @property (nonatomic, assign) AFNetworkActivityManagerState currentState;
54
+ @property (nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
55
+
56
+ - (void)updateCurrentStateForNetworkActivityChange;
57
+ @end
58
+
59
+ @implementation AFNetworkActivityIndicatorManager
60
+
61
+ + (instancetype)sharedManager {
62
+ static AFNetworkActivityIndicatorManager *_sharedManager = nil;
63
+ static dispatch_once_t oncePredicate;
64
+ dispatch_once(&oncePredicate, ^{
65
+ _sharedManager = [[self alloc] init];
66
+ });
67
+
68
+ return _sharedManager;
69
+ }
70
+
71
+ - (instancetype)init {
72
+ self = [super init];
73
+ if (!self) {
74
+ return nil;
75
+ }
76
+ self.currentState = AFNetworkActivityManagerStateNotActive;
77
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil];
78
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil];
79
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil];
80
+ self.activationDelay = kDefaultAFNetworkActivityManagerActivationDelay;
81
+ self.completionDelay = kDefaultAFNetworkActivityManagerCompletionDelay;
82
+
83
+ return self;
84
+ }
85
+
86
+ - (void)dealloc {
87
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
88
+
89
+ [_activationDelayTimer invalidate];
90
+ [_completionDelayTimer invalidate];
91
+ }
92
+
93
+ - (void)setEnabled:(BOOL)enabled {
94
+ _enabled = enabled;
95
+ if (enabled == NO) {
96
+ [self setCurrentState:AFNetworkActivityManagerStateNotActive];
97
+ }
98
+ }
99
+
100
+ - (void)setNetworkingActivityActionWithBlock:(void (^)(BOOL networkActivityIndicatorVisible))block {
101
+ self.networkActivityActionBlock = block;
102
+ }
103
+
104
+ - (BOOL)isNetworkActivityOccurring {
105
+ @synchronized(self) {
106
+ return self.activityCount > 0;
107
+ }
108
+ }
109
+
110
+ - (void)setNetworkActivityIndicatorVisible:(BOOL)networkActivityIndicatorVisible {
111
+ if (_networkActivityIndicatorVisible != networkActivityIndicatorVisible) {
112
+ @synchronized(self) {
113
+ _networkActivityIndicatorVisible = networkActivityIndicatorVisible;
114
+ }
115
+ if (self.networkActivityActionBlock) {
116
+ self.networkActivityActionBlock(networkActivityIndicatorVisible);
117
+ } else {
118
+ [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:networkActivityIndicatorVisible];
119
+ }
120
+ }
121
+ }
122
+
123
+
124
+ - (void)incrementActivityCount {
125
+ @synchronized(self) {
126
+ self.activityCount++;
127
+ }
128
+ dispatch_async(dispatch_get_main_queue(), ^{
129
+ [self updateCurrentStateForNetworkActivityChange];
130
+ });
131
+ }
132
+
133
+ - (void)decrementActivityCount {
134
+ @synchronized(self) {
135
+ self.activityCount = MAX(_activityCount - 1, 0);
136
+ }
137
+ dispatch_async(dispatch_get_main_queue(), ^{
138
+ [self updateCurrentStateForNetworkActivityChange];
139
+ });
140
+ }
141
+
142
+ - (void)networkRequestDidStart:(NSNotification *)notification {
143
+ if ([AFNetworkRequestFromNotification(notification) URL]) {
144
+ [self incrementActivityCount];
145
+ }
146
+ }
147
+
148
+ - (void)networkRequestDidFinish:(NSNotification *)notification {
149
+ if ([AFNetworkRequestFromNotification(notification) URL]) {
150
+ [self decrementActivityCount];
151
+ }
152
+ }
153
+
154
+ #pragma mark - Internal State Management
155
+ - (void)setCurrentState:(AFNetworkActivityManagerState)currentState {
156
+ @synchronized(self) {
157
+ if (_currentState != currentState) {
158
+ _currentState = currentState;
159
+ switch (currentState) {
160
+ case AFNetworkActivityManagerStateNotActive:
161
+ [self cancelActivationDelayTimer];
162
+ [self cancelCompletionDelayTimer];
163
+ [self setNetworkActivityIndicatorVisible:NO];
164
+ break;
165
+ case AFNetworkActivityManagerStateDelayingStart:
166
+ [self startActivationDelayTimer];
167
+ break;
168
+ case AFNetworkActivityManagerStateActive:
169
+ [self cancelCompletionDelayTimer];
170
+ [self setNetworkActivityIndicatorVisible:YES];
171
+ break;
172
+ case AFNetworkActivityManagerStateDelayingEnd:
173
+ [self startCompletionDelayTimer];
174
+ break;
175
+ }
176
+ }
177
+ }
178
+ }
179
+
180
+ - (void)updateCurrentStateForNetworkActivityChange {
181
+ if (self.enabled) {
182
+ switch (self.currentState) {
183
+ case AFNetworkActivityManagerStateNotActive:
184
+ if (self.isNetworkActivityOccurring) {
185
+ [self setCurrentState:AFNetworkActivityManagerStateDelayingStart];
186
+ }
187
+ break;
188
+ case AFNetworkActivityManagerStateDelayingStart:
189
+ //No op. Let the delay timer finish out.
190
+ break;
191
+ case AFNetworkActivityManagerStateActive:
192
+ if (!self.isNetworkActivityOccurring) {
193
+ [self setCurrentState:AFNetworkActivityManagerStateDelayingEnd];
194
+ }
195
+ break;
196
+ case AFNetworkActivityManagerStateDelayingEnd:
197
+ if (self.isNetworkActivityOccurring) {
198
+ [self setCurrentState:AFNetworkActivityManagerStateActive];
199
+ }
200
+ break;
201
+ }
202
+ }
203
+ }
204
+
205
+ - (void)startActivationDelayTimer {
206
+ self.activationDelayTimer = [NSTimer
207
+ timerWithTimeInterval:self.activationDelay target:self selector:@selector(activationDelayTimerFired) userInfo:nil repeats:NO];
208
+ [[NSRunLoop mainRunLoop] addTimer:self.activationDelayTimer forMode:NSRunLoopCommonModes];
209
+ }
210
+
211
+ - (void)activationDelayTimerFired {
212
+ if (self.networkActivityOccurring) {
213
+ [self setCurrentState:AFNetworkActivityManagerStateActive];
214
+ } else {
215
+ [self setCurrentState:AFNetworkActivityManagerStateNotActive];
216
+ }
217
+ }
218
+
219
+ - (void)startCompletionDelayTimer {
220
+ [self.completionDelayTimer invalidate];
221
+ self.completionDelayTimer = [NSTimer timerWithTimeInterval:self.completionDelay target:self selector:@selector(completionDelayTimerFired) userInfo:nil repeats:NO];
222
+ [[NSRunLoop mainRunLoop] addTimer:self.completionDelayTimer forMode:NSRunLoopCommonModes];
223
+ }
224
+
225
+ - (void)completionDelayTimerFired {
226
+ [self setCurrentState:AFNetworkActivityManagerStateNotActive];
227
+ }
228
+
229
+ - (void)cancelActivationDelayTimer {
230
+ [self.activationDelayTimer invalidate];
231
+ }
232
+
233
+ - (void)cancelCompletionDelayTimer {
234
+ [self.completionDelayTimer invalidate];
235
+ }
236
+
237
+ @end
238
+
239
+ #endif
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 <Foundation/Foundation.h>
23
+
24
+ #import <TargetConditionals.h>
25
+
26
+ #if TARGET_OS_IOS || TARGET_OS_TV
27
+
28
+ #import <UIKit/UIKit.h>
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
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 <objc/runtime.h>
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
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // UIButton+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 <Foundation/Foundation.h>
23
+
24
+ #import <TargetConditionals.h>
25
+
26
+ #if TARGET_OS_IOS || TARGET_OS_TV
27
+
28
+ #import <UIKit/UIKit.h>
29
+
30
+ NS_ASSUME_NONNULL_BEGIN
31
+
32
+ @class AFImageDownloader;
33
+
34
+ /**
35
+ This category adds methods to the UIKit framework's `UIButton` class. The methods in this category provide support for loading remote images and background images asynchronously from a URL.
36
+
37
+ @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported.
38
+ */
39
+ @interface UIButton (AFNetworking)
40
+
41
+ ///------------------------------------
42
+ /// @name Accessing the Image Downloader
43
+ ///------------------------------------
44
+
45
+ /**
46
+ Set the shared image downloader used to download images.
47
+
48
+ @param imageDownloader The shared image downloader used to download images.
49
+ */
50
+ + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader;
51
+
52
+ /**
53
+ The shared image downloader used to download images.
54
+ */
55
+ + (AFImageDownloader *)sharedImageDownloader;
56
+
57
+ ///--------------------
58
+ /// @name Setting Image
59
+ ///--------------------
60
+
61
+ /**
62
+ Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
63
+
64
+ If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
65
+
66
+ @param state The control state.
67
+ @param url The URL used for the image request.
68
+ */
69
+ - (void)setImageForState:(UIControlState)state
70
+ withURL:(NSURL *)url;
71
+
72
+ /**
73
+ Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
74
+
75
+ If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
76
+
77
+ @param state The control state.
78
+ @param url The URL used for the image request.
79
+ @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes.
80
+ */
81
+ - (void)setImageForState:(UIControlState)state
82
+ withURL:(NSURL *)url
83
+ placeholderImage:(nullable UIImage *)placeholderImage;
84
+
85
+ /**
86
+ Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
87
+
88
+ If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
89
+
90
+ If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setImage:forState:` is applied.
91
+
92
+ @param state The control state.
93
+ @param urlRequest The URL request used for the image request.
94
+ @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes.
95
+ @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
96
+ @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
97
+ */
98
+ - (void)setImageForState:(UIControlState)state
99
+ withURLRequest:(NSURLRequest *)urlRequest
100
+ placeholderImage:(nullable UIImage *)placeholderImage
101
+ success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
102
+ failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
103
+
104
+
105
+ ///-------------------------------
106
+ /// @name Setting Background Image
107
+ ///-------------------------------
108
+
109
+ /**
110
+ Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled.
111
+
112
+ If the background image is cached locally, the background image is set immediately, otherwise the specified placeholder background image will be set immediately, and then the remote background image will be set once the request is finished.
113
+
114
+ @param state The control state.
115
+ @param url The URL used for the background image request.
116
+ */
117
+ - (void)setBackgroundImageForState:(UIControlState)state
118
+ withURL:(NSURL *)url;
119
+
120
+ /**
121
+ Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
122
+
123
+ If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
124
+
125
+ @param state The control state.
126
+ @param url The URL used for the background image request.
127
+ @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes.
128
+ */
129
+ - (void)setBackgroundImageForState:(UIControlState)state
130
+ withURL:(NSURL *)url
131
+ placeholderImage:(nullable UIImage *)placeholderImage;
132
+
133
+ /**
134
+ Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
135
+
136
+ If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
137
+
138
+ If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setBackgroundImage:forState:` is applied.
139
+
140
+ @param state The control state.
141
+ @param urlRequest The URL request used for the image request.
142
+ @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes.
143
+ @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
144
+ @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
145
+ */
146
+ - (void)setBackgroundImageForState:(UIControlState)state
147
+ withURLRequest:(NSURLRequest *)urlRequest
148
+ placeholderImage:(nullable UIImage *)placeholderImage
149
+ success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
150
+ failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
151
+
152
+
153
+ ///------------------------------
154
+ /// @name Canceling Image Loading
155
+ ///------------------------------
156
+
157
+ /**
158
+ Cancels any executing image task for the specified control state of the receiver, if one exists.
159
+
160
+ @param state The control state.
161
+ */
162
+ - (void)cancelImageDownloadTaskForState:(UIControlState)state;
163
+
164
+ /**
165
+ Cancels any executing background image task for the specified control state of the receiver, if one exists.
166
+
167
+ @param state The control state.
168
+ */
169
+ - (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state;
170
+
171
+ @end
172
+
173
+ NS_ASSUME_NONNULL_END
174
+
175
+ #endif
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // UIButton+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 "UIButton+AFNetworking.h"
23
+
24
+ #import <objc/runtime.h>
25
+
26
+ #if TARGET_OS_IOS || TARGET_OS_TV
27
+
28
+ #import "UIImageView+AFNetworking.h"
29
+ #import "AFImageDownloader.h"
30
+
31
+ @interface UIButton (_AFNetworking)
32
+ @end
33
+
34
+ @implementation UIButton (_AFNetworking)
35
+
36
+ #pragma mark -
37
+
38
+ static char AFImageDownloadReceiptNormal;
39
+ static char AFImageDownloadReceiptHighlighted;
40
+ static char AFImageDownloadReceiptSelected;
41
+ static char AFImageDownloadReceiptDisabled;
42
+
43
+ static const char * af_imageDownloadReceiptKeyForState(UIControlState state) {
44
+ switch (state) {
45
+ case UIControlStateHighlighted:
46
+ return &AFImageDownloadReceiptHighlighted;
47
+ case UIControlStateSelected:
48
+ return &AFImageDownloadReceiptSelected;
49
+ case UIControlStateDisabled:
50
+ return &AFImageDownloadReceiptDisabled;
51
+ case UIControlStateNormal:
52
+ default:
53
+ return &AFImageDownloadReceiptNormal;
54
+ }
55
+ }
56
+
57
+ - (AFImageDownloadReceipt *)af_imageDownloadReceiptForState:(UIControlState)state {
58
+ return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_imageDownloadReceiptKeyForState(state));
59
+ }
60
+
61
+ - (void)af_setImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt
62
+ forState:(UIControlState)state
63
+ {
64
+ objc_setAssociatedObject(self, af_imageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
65
+ }
66
+
67
+ #pragma mark -
68
+
69
+ static char AFBackgroundImageDownloadReceiptNormal;
70
+ static char AFBackgroundImageDownloadReceiptHighlighted;
71
+ static char AFBackgroundImageDownloadReceiptSelected;
72
+ static char AFBackgroundImageDownloadReceiptDisabled;
73
+
74
+ static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState state) {
75
+ switch (state) {
76
+ case UIControlStateHighlighted:
77
+ return &AFBackgroundImageDownloadReceiptHighlighted;
78
+ case UIControlStateSelected:
79
+ return &AFBackgroundImageDownloadReceiptSelected;
80
+ case UIControlStateDisabled:
81
+ return &AFBackgroundImageDownloadReceiptDisabled;
82
+ case UIControlStateNormal:
83
+ default:
84
+ return &AFBackgroundImageDownloadReceiptNormal;
85
+ }
86
+ }
87
+
88
+ - (AFImageDownloadReceipt *)af_backgroundImageDownloadReceiptForState:(UIControlState)state {
89
+ return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state));
90
+ }
91
+
92
+ - (void)af_setBackgroundImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt
93
+ forState:(UIControlState)state
94
+ {
95
+ objc_setAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
96
+ }
97
+
98
+ @end
99
+
100
+ #pragma mark -
101
+
102
+ @implementation UIButton (AFNetworking)
103
+
104
+ + (AFImageDownloader *)sharedImageDownloader {
105
+
106
+ return objc_getAssociatedObject([UIButton class], @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
107
+ }
108
+
109
+ + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader {
110
+ objc_setAssociatedObject([UIButton class], @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
111
+ }
112
+
113
+ #pragma mark -
114
+
115
+ - (void)setImageForState:(UIControlState)state
116
+ withURL:(NSURL *)url
117
+ {
118
+ [self setImageForState:state withURL:url placeholderImage:nil];
119
+ }
120
+
121
+ - (void)setImageForState:(UIControlState)state
122
+ withURL:(NSURL *)url
123
+ placeholderImage:(UIImage *)placeholderImage
124
+ {
125
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
126
+ [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
127
+
128
+ [self setImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
129
+ }
130
+
131
+ - (void)setImageForState:(UIControlState)state
132
+ withURLRequest:(NSURLRequest *)urlRequest
133
+ placeholderImage:(nullable UIImage *)placeholderImage
134
+ success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
135
+ failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
136
+ {
137
+ if ([self isActiveTaskURLEqualToURLRequest:urlRequest forState:state]) {
138
+ return;
139
+ }
140
+
141
+ [self cancelImageDownloadTaskForState:state];
142
+
143
+ AFImageDownloader *downloader = [[self class] sharedImageDownloader];
144
+ id <AFImageRequestCache> imageCache = downloader.imageCache;
145
+
146
+ //Use the image from the image cache if it exists
147
+ UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil];
148
+ if (cachedImage) {
149
+ if (success) {
150
+ success(urlRequest, nil, cachedImage);
151
+ } else {
152
+ [self setImage:cachedImage forState:state];
153
+ }
154
+ [self af_setImageDownloadReceipt:nil forState:state];
155
+ } else {
156
+ if (placeholderImage) {
157
+ [self setImage:placeholderImage forState:state];
158
+ }
159
+
160
+ __weak __typeof(self)weakSelf = self;
161
+ NSUUID *downloadID = [NSUUID UUID];
162
+ AFImageDownloadReceipt *receipt;
163
+ receipt = [downloader
164
+ downloadImageForURLRequest:urlRequest
165
+ withReceiptID:downloadID
166
+ success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
167
+ __strong __typeof(weakSelf)strongSelf = weakSelf;
168
+ if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
169
+ if (success) {
170
+ success(request, response, responseObject);
171
+ } else if (responseObject) {
172
+ [strongSelf setImage:responseObject forState:state];
173
+ }
174
+ [strongSelf af_setImageDownloadReceipt:nil forState:state];
175
+ }
176
+
177
+ }
178
+ failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
179
+ __strong __typeof(weakSelf)strongSelf = weakSelf;
180
+ if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
181
+ if (failure) {
182
+ failure(request, response, error);
183
+ }
184
+ [strongSelf af_setImageDownloadReceipt:nil forState:state];
185
+ }
186
+ }];
187
+
188
+ [self af_setImageDownloadReceipt:receipt forState:state];
189
+ }
190
+ }
191
+
192
+ #pragma mark -
193
+
194
+ - (void)setBackgroundImageForState:(UIControlState)state
195
+ withURL:(NSURL *)url
196
+ {
197
+ [self setBackgroundImageForState:state withURL:url placeholderImage:nil];
198
+ }
199
+
200
+ - (void)setBackgroundImageForState:(UIControlState)state
201
+ withURL:(NSURL *)url
202
+ placeholderImage:(nullable UIImage *)placeholderImage
203
+ {
204
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
205
+ [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
206
+
207
+ [self setBackgroundImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
208
+ }
209
+
210
+ - (void)setBackgroundImageForState:(UIControlState)state
211
+ withURLRequest:(NSURLRequest *)urlRequest
212
+ placeholderImage:(nullable UIImage *)placeholderImage
213
+ success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
214
+ failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
215
+ {
216
+ if ([self isActiveBackgroundTaskURLEqualToURLRequest:urlRequest forState:state]) {
217
+ return;
218
+ }
219
+
220
+ [self cancelBackgroundImageDownloadTaskForState:state];
221
+
222
+ AFImageDownloader *downloader = [[self class] sharedImageDownloader];
223
+ id <AFImageRequestCache> imageCache = downloader.imageCache;
224
+
225
+ //Use the image from the image cache if it exists
226
+ UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil];
227
+ if (cachedImage) {
228
+ if (success) {
229
+ success(urlRequest, nil, cachedImage);
230
+ } else {
231
+ [self setBackgroundImage:cachedImage forState:state];
232
+ }
233
+ [self af_setBackgroundImageDownloadReceipt:nil forState:state];
234
+ } else {
235
+ if (placeholderImage) {
236
+ [self setBackgroundImage:placeholderImage forState:state];
237
+ }
238
+
239
+ __weak __typeof(self)weakSelf = self;
240
+ NSUUID *downloadID = [NSUUID UUID];
241
+ AFImageDownloadReceipt *receipt;
242
+ receipt = [downloader
243
+ downloadImageForURLRequest:urlRequest
244
+ withReceiptID:downloadID
245
+ success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
246
+ __strong __typeof(weakSelf)strongSelf = weakSelf;
247
+ if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
248
+ if (success) {
249
+ success(request, response, responseObject);
250
+ } else if (responseObject) {
251
+ [strongSelf setBackgroundImage:responseObject forState:state];
252
+ }
253
+ [strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state];
254
+ }
255
+
256
+ }
257
+ failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
258
+ __strong __typeof(weakSelf)strongSelf = weakSelf;
259
+ if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
260
+ if (failure) {
261
+ failure(request, response, error);
262
+ }
263
+ [strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state];
264
+ }
265
+ }];
266
+
267
+ [self af_setBackgroundImageDownloadReceipt:receipt forState:state];
268
+ }
269
+ }
270
+
271
+ #pragma mark -
272
+
273
+ - (void)cancelImageDownloadTaskForState:(UIControlState)state {
274
+ AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state];
275
+ if (receipt != nil) {
276
+ [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt];
277
+ [self af_setImageDownloadReceipt:nil forState:state];
278
+ }
279
+ }
280
+
281
+ - (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state {
282
+ AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state];
283
+ if (receipt != nil) {
284
+ [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt];
285
+ [self af_setBackgroundImageDownloadReceipt:nil forState:state];
286
+ }
287
+ }
288
+
289
+ - (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state {
290
+ AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state];
291
+ return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString];
292
+ }
293
+
294
+ - (BOOL)isActiveBackgroundTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state {
295
+ AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state];
296
+ return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString];
297
+ }
298
+
299
+
300
+ @end
301
+
302
+ #endif
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // UIImageView+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 <Foundation/Foundation.h>
23
+
24
+ #import <TargetConditionals.h>
25
+
26
+ #if TARGET_OS_IOS || TARGET_OS_TV
27
+
28
+ #import <UIKit/UIKit.h>
29
+
30
+ NS_ASSUME_NONNULL_BEGIN
31
+
32
+ @class AFImageDownloader;
33
+
34
+ /**
35
+ This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL.
36
+ */
37
+ @interface UIImageView (AFNetworking)
38
+
39
+ ///------------------------------------
40
+ /// @name Accessing the Image Downloader
41
+ ///------------------------------------
42
+
43
+ /**
44
+ Set the shared image downloader used to download images.
45
+
46
+ @param imageDownloader The shared image downloader used to download images.
47
+ */
48
+ + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader;
49
+
50
+ /**
51
+ The shared image downloader used to download images.
52
+ */
53
+ + (AFImageDownloader *)sharedImageDownloader;
54
+
55
+ ///--------------------
56
+ /// @name Setting Image
57
+ ///--------------------
58
+
59
+ /**
60
+ Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
61
+
62
+ If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
63
+
64
+ By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
65
+
66
+ @param url The URL used for the image request.
67
+ */
68
+ - (void)setImageWithURL:(NSURL *)url;
69
+
70
+ /**
71
+ Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
72
+
73
+ If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
74
+
75
+ By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
76
+
77
+ @param url The URL used for the image request.
78
+ @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
79
+ */
80
+ - (void)setImageWithURL:(NSURL *)url
81
+ placeholderImage:(nullable UIImage *)placeholderImage;
82
+
83
+ /**
84
+ Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
85
+
86
+ If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
87
+
88
+ If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied.
89
+
90
+ @param urlRequest The URL request used for the image request.
91
+ @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
92
+ @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
93
+ @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
94
+ */
95
+ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
96
+ placeholderImage:(nullable UIImage *)placeholderImage
97
+ success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
98
+ failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
99
+
100
+ /**
101
+ Cancels any executing image operation for the receiver, if one exists.
102
+ */
103
+ - (void)cancelImageDownloadTask;
104
+
105
+ @end
106
+
107
+ NS_ASSUME_NONNULL_END
108
+
109
+ #endif
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // UIImageView+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 "UIImageView+AFNetworking.h"
23
+
24
+ #import <objc/runtime.h>
25
+
26
+ #if TARGET_OS_IOS || TARGET_OS_TV
27
+
28
+ #import "AFImageDownloader.h"
29
+
30
+ @interface UIImageView (_AFNetworking)
31
+ @property (readwrite, nonatomic, strong, setter = af_setActiveImageDownloadReceipt:) AFImageDownloadReceipt *af_activeImageDownloadReceipt;
32
+ @end
33
+
34
+ @implementation UIImageView (_AFNetworking)
35
+
36
+ - (AFImageDownloadReceipt *)af_activeImageDownloadReceipt {
37
+ return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, @selector(af_activeImageDownloadReceipt));
38
+ }
39
+
40
+ - (void)af_setActiveImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt {
41
+ objc_setAssociatedObject(self, @selector(af_activeImageDownloadReceipt), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
42
+ }
43
+
44
+ @end
45
+
46
+ #pragma mark -
47
+
48
+ @implementation UIImageView (AFNetworking)
49
+
50
+ + (AFImageDownloader *)sharedImageDownloader {
51
+ return objc_getAssociatedObject([UIImageView class], @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
52
+ }
53
+
54
+ + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader {
55
+ objc_setAssociatedObject([UIImageView class], @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
56
+ }
57
+
58
+ #pragma mark -
59
+
60
+ - (void)setImageWithURL:(NSURL *)url {
61
+ [self setImageWithURL:url placeholderImage:nil];
62
+ }
63
+
64
+ - (void)setImageWithURL:(NSURL *)url
65
+ placeholderImage:(UIImage *)placeholderImage
66
+ {
67
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
68
+ [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
69
+
70
+ [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
71
+ }
72
+
73
+ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
74
+ placeholderImage:(UIImage *)placeholderImage
75
+ success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
76
+ failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
77
+ {
78
+ if ([urlRequest URL] == nil) {
79
+ self.image = placeholderImage;
80
+ if (failure) {
81
+ NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadURL userInfo:nil];
82
+ failure(urlRequest, nil, error);
83
+ }
84
+ return;
85
+ }
86
+
87
+ if ([self isActiveTaskURLEqualToURLRequest:urlRequest]) {
88
+ return;
89
+ }
90
+
91
+ [self cancelImageDownloadTask];
92
+
93
+ AFImageDownloader *downloader = [[self class] sharedImageDownloader];
94
+ id <AFImageRequestCache> imageCache = downloader.imageCache;
95
+
96
+ //Use the image from the image cache if it exists
97
+ UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil];
98
+ if (cachedImage) {
99
+ if (success) {
100
+ success(urlRequest, nil, cachedImage);
101
+ } else {
102
+ self.image = cachedImage;
103
+ }
104
+ [self clearActiveDownloadInformation];
105
+ } else {
106
+ if (placeholderImage) {
107
+ self.image = placeholderImage;
108
+ }
109
+
110
+ __weak __typeof(self)weakSelf = self;
111
+ NSUUID *downloadID = [NSUUID UUID];
112
+ AFImageDownloadReceipt *receipt;
113
+ receipt = [downloader
114
+ downloadImageForURLRequest:urlRequest
115
+ withReceiptID:downloadID
116
+ success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
117
+ __strong __typeof(weakSelf)strongSelf = weakSelf;
118
+ if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) {
119
+ if (success) {
120
+ success(request, response, responseObject);
121
+ } else if (responseObject) {
122
+ strongSelf.image = responseObject;
123
+ }
124
+ [strongSelf clearActiveDownloadInformation];
125
+ }
126
+
127
+ }
128
+ failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
129
+ __strong __typeof(weakSelf)strongSelf = weakSelf;
130
+ if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) {
131
+ if (failure) {
132
+ failure(request, response, error);
133
+ }
134
+ [strongSelf clearActiveDownloadInformation];
135
+ }
136
+ }];
137
+
138
+ self.af_activeImageDownloadReceipt = receipt;
139
+ }
140
+ }
141
+
142
+ - (void)cancelImageDownloadTask {
143
+ if (self.af_activeImageDownloadReceipt != nil) {
144
+ [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:self.af_activeImageDownloadReceipt];
145
+ [self clearActiveDownloadInformation];
146
+ }
147
+ }
148
+
149
+ - (void)clearActiveDownloadInformation {
150
+ self.af_activeImageDownloadReceipt = nil;
151
+ }
152
+
153
+ - (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest {
154
+ return [self.af_activeImageDownloadReceipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString];
155
+ }
156
+
157
+ @end
158
+
159
+ #endif
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #import <TargetConditionals.h>
24
+
25
+ #ifndef _UIKIT_AFNETWORKING_
26
+ #define _UIKIT_AFNETWORKING_
27
+
28
+ #if TARGET_OS_IOS || TARGET_OS_TV
29
+ #import "AFAutoPurgingImageCache.h"
30
+ #import "AFImageDownloader.h"
31
+ #import "UIActivityIndicatorView+AFNetworking.h"
32
+ #import "UIButton+AFNetworking.h"
33
+ #import "UIImageView+AFNetworking.h"
34
+ #import "UIProgressView+AFNetworking.h"
35
+ #endif
36
+
37
+ #if TARGET_OS_IOS
38
+ #import "AFNetworkActivityIndicatorManager.h"
39
+ #import "UIRefreshControl+AFNetworking.h"
40
+ #import "WKWebView+AFNetworking.h"
41
+ #endif
42
+
43
+ #endif /* _UIKIT_AFNETWORKING_ */
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 <Foundation/Foundation.h>
23
+
24
+ #import <TargetConditionals.h>
25
+
26
+ #if TARGET_OS_IOS || TARGET_OS_TV
27
+
28
+ #import <UIKit/UIKit.h>
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
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // UIProgressView+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 "UIProgressView+AFNetworking.h"
23
+
24
+ #import <objc/runtime.h>
25
+
26
+ #if TARGET_OS_IOS || TARGET_OS_TV
27
+
28
+ #import "AFURLSessionManager.h"
29
+
30
+ static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext;
31
+ static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext;
32
+
33
+ #pragma mark -
34
+
35
+ @implementation UIProgressView (AFNetworking)
36
+
37
+ - (BOOL)af_uploadProgressAnimated {
38
+ return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue];
39
+ }
40
+
41
+ - (void)af_setUploadProgressAnimated:(BOOL)animated {
42
+ objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
43
+ }
44
+
45
+ - (BOOL)af_downloadProgressAnimated {
46
+ return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue];
47
+ }
48
+
49
+ - (void)af_setDownloadProgressAnimated:(BOOL)animated {
50
+ objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
51
+ }
52
+
53
+ #pragma mark -
54
+
55
+ - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
56
+ animated:(BOOL)animated
57
+ {
58
+ if (task.state == NSURLSessionTaskStateCompleted) {
59
+ return;
60
+ }
61
+
62
+ [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext];
63
+ [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext];
64
+
65
+ [self af_setUploadProgressAnimated:animated];
66
+ }
67
+
68
+ - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
69
+ animated:(BOOL)animated
70
+ {
71
+ if (task.state == NSURLSessionTaskStateCompleted) {
72
+ return;
73
+ }
74
+
75
+ [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext];
76
+ [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext];
77
+
78
+ [self af_setDownloadProgressAnimated:animated];
79
+ }
80
+
81
+ #pragma mark - NSKeyValueObserving
82
+
83
+ - (void)observeValueForKeyPath:(NSString *)keyPath
84
+ ofObject:(id)object
85
+ change:(__unused NSDictionary *)change
86
+ context:(void *)context
87
+ {
88
+ if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) {
89
+ if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) {
90
+ if ([object countOfBytesExpectedToSend] > 0) {
91
+ dispatch_async(dispatch_get_main_queue(), ^{
92
+ [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated];
93
+ });
94
+ }
95
+ }
96
+
97
+ if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) {
98
+ if ([object countOfBytesExpectedToReceive] > 0) {
99
+ dispatch_async(dispatch_get_main_queue(), ^{
100
+ [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated];
101
+ });
102
+ }
103
+ }
104
+
105
+ if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) {
106
+ if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) {
107
+ @try {
108
+ [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))];
109
+
110
+ if (context == AFTaskCountOfBytesSentContext) {
111
+ [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))];
112
+ }
113
+
114
+ if (context == AFTaskCountOfBytesReceivedContext) {
115
+ [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))];
116
+ }
117
+ }
118
+ @catch (NSException * __unused exception) {}
119
+ }
120
+ }
121
+ }
122
+ }
123
+
124
+ @end
125
+
126
+ #endif
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 <Foundation/Foundation.h>
24
+
25
+ #import <TargetConditionals.h>
26
+
27
+ #if TARGET_OS_IOS
28
+
29
+ #import <UIKit/UIKit.h>
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
GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 <objc/runtime.h>
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