From e9016e28aa7df8870948309519cb56761e1fe808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=AF=20=E6=92=92?= <420391244@qq.com> Date: Thu, 21 May 2015 18:57:32 +0800 Subject: [PATCH] first init --- ABCDEF_city.plist | 42 + AFNetworking-master/.cocoadocs.yml | 7 + AFNetworking-master/.gitignore | 21 + AFNetworking-master/.travis.yml | 7 + AFNetworking-master/AFNetworking.podspec | 60 + .../AFNetworking/AFHTTPRequestOperation.h | 66 + .../AFNetworking/AFHTTPRequestOperation.m | 206 + .../AFHTTPRequestOperationManager.h | 323 ++ .../AFHTTPRequestOperationManager.m | 284 + .../AFNetworking/AFHTTPSessionManager.h | 247 + .../AFNetworking/AFHTTPSessionManager.m | 321 ++ .../AFNetworkReachabilityManager.h | 200 + .../AFNetworkReachabilityManager.m | 259 + .../AFNetworking/AFNetworking.h | 44 + .../AFNetworking/AFSecurityPolicy.h | 142 + .../AFNetworking/AFSecurityPolicy.m | 308 ++ .../AFNetworking/AFURLConnectionOperation.h | 343 ++ .../AFNetworking/AFURLConnectionOperation.m | 788 +++ .../AFNetworking/AFURLRequestSerialization.h | 467 ++ .../AFNetworking/AFURLRequestSerialization.m | 1384 +++++ .../AFNetworking/AFURLResponseSerialization.h | 309 ++ .../AFNetworking/AFURLResponseSerialization.m | 797 +++ .../AFNetworking/AFURLSessionManager.h | 546 ++ .../AFNetworking/AFURLSessionManager.m | 1103 ++++ AFNetworking-master/CHANGES | 1673 ++++++ AFNetworking-master/CONTRIBUTING.md | 91 + .../Example/AFNetworking Example.entitlements | 12 + .../project.pbxproj | 403 ++ .../project.pbxproj | 637 +++ AFNetworking-master/Example/AppDelegate.h | 44 + AFNetworking-master/Example/AppDelegate.m | 91 + .../Example/Classes/AFAppDotNetAPIClient.h | 30 + .../Example/Classes/AFAppDotNetAPIClient.m | 40 + .../GlobalTimelineViewController.h | 27 + .../GlobalTimelineViewController.m | 105 + .../Example/Classes/Models/Post.h | 38 + .../Example/Classes/Models/Post.m | 65 + .../Example/Classes/Models/User.h | 39 + .../Example/Classes/Models/User.m | 100 + .../Example/Classes/Views/PostTableViewCell.h | 33 + .../Example/Classes/Views/PostTableViewCell.m | 82 + .../Example/Default-568h@2x.png | Bin 0 -> 18594 bytes AFNetworking-master/Example/Default.png | Bin 0 -> 942 bytes AFNetworking-master/Example/Default@2x.png | Bin 0 -> 5104 bytes AFNetworking-master/Example/Icon.png | Bin 0 -> 6547 bytes AFNetworking-master/Example/Icon@2x.png | Bin 0 -> 10055 bytes .../Images/profile-image-placeholder.png | Bin 0 -> 1098 bytes .../Images/profile-image-placeholder@2x.png | Bin 0 -> 2767 bytes AFNetworking-master/Example/Mac-Info.plist | 34 + AFNetworking-master/Example/MainMenu.xib | 1894 +++++++ AFNetworking-master/Example/Prefix.pch | 21 + AFNetworking-master/Example/adn.cer | Bin 0 -> 1321 bytes AFNetworking-master/Example/digicert_ca_3.cer | Bin 0 -> 1628 bytes .../Example/en.lproj/MainMenu.xib | 4587 +++++++++++++++++ AFNetworking-master/Example/iOS-Info.plist | 60 + AFNetworking-master/Example/main.m | 37 + AFNetworking-master/Example/root_ca.cer | Bin 0 -> 969 bytes AFNetworking-master/LICENSE | 19 + AFNetworking-master/README.md | 385 ++ AFNetworking-master/Rakefile | 50 + .../project.pbxproj | 779 +++ .../Tests/AFNetworking-Prefix.pch | 16 + .../Tests/AFNetworkingTests-Info.plist | 22 + .../Tests/OS X Tests/OS X Tests-Info.plist | 22 + .../Tests/OS X Tests/OS X Tests-Prefix.pch | 9 + .../OS X Tests/en.lproj/InfoPlist.strings | 2 + AFNetworking-master/Tests/Podfile | 23 + .../ADN.net/ADNNetServerTrustChain/adn_0.cer | Bin 0 -> 1321 bytes .../ADN.net/ADNNetServerTrustChain/adn_1.cer | Bin 0 -> 1628 bytes .../ADN.net/ADNNetServerTrustChain/adn_2.cer | Bin 0 -> 969 bytes .../HTTPBin.org/AddTrust_External_CA_Root.cer | Bin 0 -> 1082 bytes .../COMODO_RSA_Certification_Authority.cer | Bin 0 -> 1400 bytes ...RSA_Domain_Validation_Secure_Server_CA.cer | Bin 0 -> 1548 bytes .../HTTPBinOrgServerTrustChain/httpbin_0.cer | Bin 0 -> 1364 bytes .../HTTPBinOrgServerTrustChain/httpbin_1.cer | Bin 0 -> 1548 bytes .../HTTPBinOrgServerTrustChain/httpbin_2.cer | Bin 0 -> 1400 bytes .../HTTPBinOrgServerTrustChain/httpbin_3.cer | Bin 0 -> 1082 bytes .../HTTPBin.org/httpbinorg_01162016.cer | Bin 0 -> 1364 bytes .../Tests/Resources/SelfSigned/AltName.cer | Bin 0 -> 766 bytes .../Tests/Resources/SelfSigned/NoDomains.cer | Bin 0 -> 747 bytes .../Tests/Resources/SelfSigned/foobar.com.cer | Bin 0 -> 747 bytes .../Tests/Schemes/OS X Tests.xcscheme | 83 + .../Tests/Schemes/iOS Tests.xcscheme | 83 + .../Tests/Tests/1.0 Tests/AFHTTPClientTests.m | 335 ++ .../1.0 Tests/AFHTTPRequestOperationTests.m | 240 + .../1.0 Tests/AFImageRequestOperationTests.m | 155 + .../1.0 Tests/AFJSONRequestOperationTests.m | 98 + .../Tests/Tests/1.0 Tests/AFMockURLProtocol.h | 37 + .../Tests/Tests/1.0 Tests/AFMockURLProtocol.m | 106 + .../Tests/Tests/1.0 Tests/AFNetworkingTests.h | 33 + .../Tests/Tests/1.0 Tests/AFNetworkingTests.m | 35 + .../1.0 Tests/AFURLConnectionOperationTests.m | 304 ++ .../Tests/Tests/AFHTTPRequestOperationTests.m | 458 ++ .../Tests/AFHTTPRequestSerializationTests.m | 151 + .../Tests/AFHTTPResponseSerializationTests.m | 67 + .../Tests/Tests/AFHTTPSessionManagerTests.m | 144 + .../Tests/Tests/AFJSONSerializationTests.m | 136 + .../Tests/AFNetworkActivityManagerTests.m | 107 + .../Tests/AFNetworkReachabilityManagerTests.m | 128 + .../AFPropertyListResponseSerializerTests.m | 48 + .../Tests/Tests/AFSecurityPolicyTests.m | 576 +++ AFNetworking-master/Tests/Tests/AFTestCase.h | 34 + AFNetworking-master/Tests/Tests/AFTestCase.m | 44 + .../Tests/Tests/AFURLSessionManagerTests.m | 81 + .../iOS Tests/en.lproj/InfoPlist.strings | 2 + .../Tests/iOS Tests/iOS Tests-Info.plist | 22 + .../Tests/iOS Tests/iOS Tests-Prefix.pch | 10 + .../AFNetworkActivityIndicatorManager.h | 75 + .../AFNetworkActivityIndicatorManager.m | 172 + .../UIActivityIndicatorView+AFNetworking.h | 63 + .../UIActivityIndicatorView+AFNetworking.m | 96 + .../UIAlertView+AFNetworking.h | 95 + .../UIAlertView+AFNetworking.m | 141 + .../UIButton+AFNetworking.h | 180 + .../UIButton+AFNetworking.m | 293 ++ .../UIImageView+AFNetworking.h | 142 + .../UIImageView+AFNetworking.m | 215 + .../UIKit+AFNetworking/UIKit+AFNetworking.h | 38 + .../UIProgressView+AFNetworking.h | 87 + .../UIProgressView+AFNetworking.m | 182 + .../UIRefreshControl+AFNetworking.h | 64 + .../UIRefreshControl+AFNetworking.m | 93 + .../UIWebView+AFNetworking.h | 82 + .../UIWebView+AFNetworking.m | 159 + AdDataModel.h | 24 + AdDataModel.m | 47 + AdDataPlist.plist | 18 + AdScrollView.h | 40 + AdScrollView.m | 173 + ArtistsCell.h | 16 + ArtistsCell.m | 23 + ArtistsCell.xib | 41 + ArtistsViewController.h | 13 + ArtistsViewController.m | 77 + ArtistsViewController.xib | 25 + CNPPopupController.h | 126 + CNPPopupController.m | 680 +++ .../DAContextMenuCell.h | 45 + .../DAContextMenuCell.m | 269 + .../DAContextMenuTableViewController.h | 16 + .../DAContextMenuTableViewController.m | 142 + .../DAOverlayView.h | 25 + .../DAOverlayView.m | 18 + DetailViewController.h | 13 + DetailViewController.m | 37 + DetailViewController.xib | 37 + DownSheet/DownSheet.xcodeproj/project.pbxproj | 766 +++ .../contents.xcworkspacedata | 7 + .../xcschemes/DownSheet.xcscheme | 110 + .../xcschemes/xcschememanagement.plist | 27 + .../xcdebugger/Breakpoints_v2.xcbkptlist | 183 + .../xcschemes/DownSheet.xcscheme | 112 + .../xcschemes/xcschememanagement.plist | 27 + .../xcschemes/DownSheet.xcscheme | 96 + .../xcschemes/xcschememanagement.plist | 27 + DownSheet/DownSheet/AppDelegate.h | 19 + DownSheet/DownSheet/AppDelegate.m | 56 + DownSheet/DownSheet/Classes/DownSheet.h | 55 + DownSheet/DownSheet/Classes/DownSheet.m | 385 ++ DownSheet/DownSheet/Classes/DownSheetCell.h | 28 + DownSheet/DownSheet/Classes/DownSheetCell.m | 58 + DownSheet/DownSheet/Classes/job_first.plist | 50 + .../DownSheet/Classes/job_second(0).plist | 10 + .../DownSheet/Classes/job_second(1).plist | 22 + .../DownSheet/Classes/job_second(10).plist | 18 + .../DownSheet/Classes/job_second(2).plist | 22 + .../DownSheet/Classes/job_second(3).plist | 22 + .../DownSheet/Classes/job_second(4).plist | 26 + .../DownSheet/Classes/job_second(5).plist | 22 + .../DownSheet/Classes/job_second(6).plist | 34 + .../DownSheet/Classes/job_second(7).plist | 22 + .../DownSheet/Classes/job_second(8).plist | 22 + .../DownSheet/Classes/job_second(9).plist | 14 + .../DownSheet/Classes/job_third(0).plist | 10 + .../DownSheet/Classes/job_third(1).plist | 54 + .../DownSheet/Classes/job_third(2).plist | 18 + DownSheet/DownSheet/DownSheet-Info.plist | 36 + DownSheet/DownSheet/DownSheet-Prefix.pch | 16 + .../AppIcon.appiconset/Contents.json | 23 + .../LaunchImage.launchimage/Contents.json | 23 + DownSheet/DownSheet/Receive_email.h | 27 + DownSheet/DownSheet/Receive_email.m | 144 + DownSheet/DownSheet/Resouce/icon_add@2x.png | Bin 0 -> 1275 bytes .../DownSheet/Resouce/icon_add_hover@2x.png | Bin 0 -> 1263 bytes DownSheet/DownSheet/Resouce/icon_album@2x.png | Bin 0 -> 1907 bytes .../DownSheet/Resouce/icon_album_hover@2x.png | Bin 0 -> 1718 bytes DownSheet/DownSheet/Resouce/icon_buy@2x.png | Bin 0 -> 1257 bytes .../DownSheet/Resouce/icon_buy_hover@2x.png | Bin 0 -> 1234 bytes .../DownSheet/Resouce/icon_computer@2x.png | Bin 0 -> 1382 bytes .../Resouce/icon_computer_hover@2x.png | Bin 0 -> 1376 bytes DownSheet/DownSheet/Resouce/icon_del@2x.png | Bin 0 -> 1711 bytes .../DownSheet/Resouce/icon_del_hover@2x.png | Bin 0 -> 1708 bytes DownSheet/DownSheet/Resouce/icon_down@2x.png | Bin 0 -> 1442 bytes .../DownSheet/Resouce/icon_down_hover@2x.png | Bin 0 -> 1381 bytes DownSheet/DownSheet/ViewController.h | 19 + DownSheet/DownSheet/ViewController.m | 76 + DownSheet/DownSheet/Work_Day.h | 32 + DownSheet/DownSheet/Work_Day.m | 184 + DownSheet/DownSheet/email.h | 24 + DownSheet/DownSheet/email.m | 48 + .../DownSheet/en.lproj/InfoPlist.strings | 2 + DownSheet/DownSheet/lowest_study.plist | 26 + DownSheet/DownSheet/main.m | 22 + DownSheet/DownSheet/salary_range.plist | 30 + DownSheet/DownSheet/school_exp.plist | 26 + DownSheet/DownSheet/send_cycle.plist | 14 + DownSheet/DownSheet/time_window.h | 39 + DownSheet/DownSheet/time_window.m | 182 + DownSheet/DownSheet/work_cell.h | 26 + DownSheet/DownSheet/work_cell.m | 54 + DownSheet/DownSheet/work_days.plist | 22 + DownSheet/DownSheet/work_time.plist | 22 + DownSheet/DownSheet/workday.h | 31 + DownSheet/DownSheet/workday.m | 133 + .../DownSheetTests/DownSheetTests-Info.plist | 22 + DownSheet/DownSheetTests/DownSheetTests.m | 38 + .../DownSheetTests/en.lproj/InfoPlist.strings | 2 + EAIntroPage.h | 32 + EAIntroPage.m | 34 + EAIntroView.h | 43 + EAIntroView.m | 394 ++ GHIJ_city.plist | 38 + KLMN_city.plist | 30 + NSData+SDDataCache.h | 17 + NSData+SDDataCache.m | 69 + OPQR_city.plist | 14 + PlayListCell.h | 16 + PlayListCell.m | 23 + PlayListCell.xib | 37 + PlayListTableViewController.h | 13 + PlayListTableViewController.m | 81 + PlayListTableViewController.xib | 24 + README.md | 1 + SDCollectionViewCell.h | 37 + SDCollectionViewCell.m | 96 + SDCycleScrollView.h | 60 + SDCycleScrollView.m | 331 ++ SRMonthPicker.h | 110 + SRMonthPicker.m | 313 ++ STUV_city.plist | 38 + SampleViewController.h | 13 + SampleViewController.m | 30 + SampleViewController.xib | 37 + ShiXiSeng_Main.xcodeproj/project.pbxproj | 1340 ++++- .../xcdebugger/Breakpoints_v2.xcbkptlist | 417 ++ ShiXiSeng_Main/>=.png | Bin 0 -> 3031 bytes ShiXiSeng_Main/About.h | 13 + ShiXiSeng_Main/About.m | 37 + ShiXiSeng_Main/Accountset.h | 13 + ShiXiSeng_Main/Accountset.m | 37 + ShiXiSeng_Main/AllMsg.h | 13 + ShiXiSeng_Main/AllMsg.m | 119 + ShiXiSeng_Main/AllMsg.xib | 25 + ShiXiSeng_Main/AppDelegate.m | 16 +- ShiXiSeng_Main/Base.lproj/LaunchScreen.xib | 41 +- ShiXiSeng_Main/Base.lproj/Main.storyboard | 25 - ShiXiSeng_Main/ChanceViewController.h | 38 + ShiXiSeng_Main/ChanceViewController.m | 344 ++ ShiXiSeng_Main/Classes/DownSheet.h | 55 + ShiXiSeng_Main/Classes/DownSheet.m | 378 ++ ShiXiSeng_Main/Classes/DownSheetCell.h | 28 + ShiXiSeng_Main/Classes/DownSheetCell.m | 58 + ShiXiSeng_Main/Classes/job_first.plist | 50 + ShiXiSeng_Main/Classes/job_second(0).plist | 10 + ShiXiSeng_Main/Classes/job_second(1).plist | 22 + ShiXiSeng_Main/Classes/job_second(10).plist | 18 + ShiXiSeng_Main/Classes/job_second(2).plist | 22 + ShiXiSeng_Main/Classes/job_second(3).plist | 22 + ShiXiSeng_Main/Classes/job_second(4).plist | 26 + ShiXiSeng_Main/Classes/job_second(5).plist | 22 + ShiXiSeng_Main/Classes/job_second(6).plist | 34 + ShiXiSeng_Main/Classes/job_second(7).plist | 22 + ShiXiSeng_Main/Classes/job_second(8).plist | 22 + ShiXiSeng_Main/Classes/job_second(9).plist | 14 + ShiXiSeng_Main/Classes/job_third(0).plist | 10 + ShiXiSeng_Main/Classes/job_third(1).plist | 54 + ShiXiSeng_Main/Classes/job_third(2).plist | 18 + ShiXiSeng_Main/CompanyInfoa.h | 13 + ShiXiSeng_Main/CompanyInfoa.m | 37 + ShiXiSeng_Main/CompanyPosition.h | 18 + ShiXiSeng_Main/CompanyPosition.m | 102 + ShiXiSeng_Main/CustomToolbar.h | 13 + ShiXiSeng_Main/CustomToolbar.m | 23 + ShiXiSeng_Main/Delegate.h | 18 + ShiXiSeng_Main/Education_exp.h | 24 + ShiXiSeng_Main/Education_exp.m | 97 + ShiXiSeng_Main/ExitViewController.h | 17 + ShiXiSeng_Main/ExitViewController.m | 58 + ShiXiSeng_Main/FeedBackViewController.h | 16 + ShiXiSeng_Main/FeedBackViewController.m | 41 + ShiXiSeng_Main/Fill_Record.h | 17 + ShiXiSeng_Main/Fill_Record.m | 333 ++ ShiXiSeng_Main/Fill_Record_Cell.h | 20 + ShiXiSeng_Main/Fill_Record_Cell.m | 29 + ShiXiSeng_Main/FindControllerViewController.h | 13 + ShiXiSeng_Main/FindControllerViewController.m | 78 + ShiXiSeng_Main/FindViewController.h | 15 + ShiXiSeng_Main/FindViewController.m | 108 + ShiXiSeng_Main/FixCom.h | 16 + ShiXiSeng_Main/FixCom.m | 171 + ShiXiSeng_Main/FixCompany.h | 13 + ShiXiSeng_Main/FixCompany.m | 37 + ShiXiSeng_Main/Hope.h | 33 + ShiXiSeng_Main/Hope.m | 151 + .../AppIcon.appiconset/29-1.png | Bin 0 -> 6526 bytes .../Images.xcassets/AppIcon.appiconset/29.png | Bin 0 -> 18729 bytes .../Images.xcassets/AppIcon.appiconset/40.png | Bin 0 -> 8704 bytes .../AppIcon.appiconset/57-1.png | Bin 0 -> 12255 bytes .../Images.xcassets/AppIcon.appiconset/57.png | Bin 0 -> 20340 bytes .../AppIcon.appiconset/60-1.png | Bin 0 -> 22776 bytes .../Images.xcassets/AppIcon.appiconset/60.png | Bin 0 -> 13174 bytes .../AppIcon.appiconset/Contents.json | 52 +- .../Chance/homeICON.imageset/Contents.json | 21 + .../Chance/homeICON.imageset/homeICON.png | Bin 0 -> 3965 bytes .../Chance/website.imageset/Contents.json | 21 + .../Chance/website.imageset/website.png | Bin 0 -> 4843 bytes .../Images.xcassets/Intro/1.imageset/1.png | Bin 0 -> 143003 bytes .../Intro/1.imageset/Contents.json | 21 + .../Images.xcassets/Intro/2.imageset/2.png | Bin 0 -> 3691024 bytes .../Intro/2.imageset/Contents.json | 21 + .../Images.xcassets/Intro/3.imageset/3.png | Bin 0 -> 3691024 bytes .../Intro/3.imageset/Contents.json | 21 + .../LaunchImage.launchimage/Contents.json | 39 + .../delete.imageset/Contents.json | 21 + .../delete.imageset/delete.png | Bin 0 -> 3295 bytes .../pencil.imageset/Contents.json | 21 + .../pencil.imageset/pencil.png | Bin 0 -> 3520 bytes .../Contents.json" | 21 + .../\345\217\221\347\216\260.png" | Bin 0 -> 17247 bytes .../Contents.json" | 21 + .../\346\210\221\347\232\204.png" | Bin 0 -> 17247 bytes .../Contents.json" | 21 + .../\346\234\272\344\274\232.png" | Bin 0 -> 17247 bytes .../Contents.json" | 21 + .../\346\266\210\346\201\257.png" | Bin 0 -> 17247 bytes .../Contents.json" | 21 + ...6\345\256\236\344\271\240\345\203\247.png" | Bin 0 -> 259017 bytes .../Contents.json" | 21 + .../\345\217\221\351\200\201.png" | Bin 0 -> 10932 bytes .../Contents.json" | 21 + ...3\345\206\231\347\256\200\345\216\206.png" | Bin 0 -> 9885 bytes .../add.imageset/Contents.json" | 21 + .../add.imageset/add.png" | Bin 0 -> 3492 bytes .../edit1.imageset/Contents.json" | 21 + .../edit1.imageset/edit1.png" | Bin 0 -> 3357 bytes .../email.imageset/Contents.json" | 21 + .../email.imageset/email.png" | Bin 0 -> 3070 bytes .../phone.imageset/Contents.json" | 21 + .../phone.imageset/phone.png" | Bin 0 -> 3364 bytes .../school.imageset/Contents.json" | 21 + .../school.imageset/school.png" | Bin 0 -> 3428 bytes .../Contents.json" | 21 + ...3\345\206\231\347\256\200\345\216\206.png" | Bin 0 -> 29212 bytes .../Contents.json" | 21 + .../\347\274\226\350\276\221.png" | Bin 0 -> 4084 bytes .../Contents.json" | 21 + .../\345\244\264\345\203\217.png" | Bin 0 -> 163002 bytes .../Contents.json" | 21 + ...3\346\263\250\345\205\254\345\217\270.png" | Bin 0 -> 9885 bytes .../Contents.json" | 21 + ...6\350\227\217\350\201\214\344\275\215.png" | Bin 0 -> 9885 bytes .../Contents.json" | 21 + .../MineBG.png" | Bin 0 -> 233457 bytes .../Contents.json" | 21 + ...5\351\200\222\347\272\252\345\275\225.png" | Bin 0 -> 9885 bytes .../Contents.json" | 21 + ...4\344\275\215\350\256\242\351\230\205.png" | Bin 0 -> 9885 bytes .../Contents.json" | 21 + .../\350\256\276\347\275\256.png" | Bin 0 -> 10932 bytes .../Contents.json" | 21 + ...0\350\275\275\351\241\265\351\235\242.png" | Bin 0 -> 3691024 bytes .../Contents.json" | 21 + ...3\345\275\225\347\225\214\351\235\242.png" | Bin 0 -> 3691024 bytes ShiXiSeng_Main/Info.plist | 20 +- ShiXiSeng_Main/InteMsg.h | 13 + ShiXiSeng_Main/InteMsg.m | 125 + ShiXiSeng_Main/InteMsg.xib | 24 + ShiXiSeng_Main/Job.h | 25 + ShiXiSeng_Main/Job.m | 26 + ShiXiSeng_Main/Job.plist | 102 + ShiXiSeng_Main/Job.xib | 25 + ShiXiSeng_Main/JobCell.h | 22 + ShiXiSeng_Main/JobCell.m | 23 + ShiXiSeng_Main/JobCollect.h | 16 + ShiXiSeng_Main/JobCollect.m | 111 + ShiXiSeng_Main/JobInfoa.h | 13 + ShiXiSeng_Main/JobInfoa.m | 37 + ShiXiSeng_Main/JobTable.h | 15 + ShiXiSeng_Main/JobTable.m | 145 + ShiXiSeng_Main/JobView.h | 15 + ShiXiSeng_Main/JobView.m | 21 + ShiXiSeng_Main/Job_Sub_Cell.h | 44 + ShiXiSeng_Main/Job_Sub_Cell.m | 268 + ShiXiSeng_Main/Job_Subscribe.h | 15 + ShiXiSeng_Main/Job_Subscribe.m | 143 + ShiXiSeng_Main/Jobdetail.h | 13 + ShiXiSeng_Main/Jobdetail.m | 41 + ShiXiSeng_Main/MViewController.h | 15 + ShiXiSeng_Main/MViewController.m | 82 + ShiXiSeng_Main/Main.storyboard | 3776 ++++++++++++++ ShiXiSeng_Main/MessageViewController.h | 13 + ShiXiSeng_Main/MessageViewController.m | 83 + ShiXiSeng_Main/MineTableViewController.h | 15 + ShiXiSeng_Main/MineTableViewController.m | 103 + ShiXiSeng_Main/MsgCell.h | 23 + ShiXiSeng_Main/MsgCell.m | 23 + ShiXiSeng_Main/MsgCell.xib | 58 + ShiXiSeng_Main/MsgDetail.h | 13 + ShiXiSeng_Main/MsgDetail.m | 37 + ShiXiSeng_Main/NewMessage.h | 13 + ShiXiSeng_Main/NewMessage.m | 37 + ShiXiSeng_Main/OneDelegate.m | 40 + ShiXiSeng_Main/PViewController.h | 13 + ShiXiSeng_Main/PViewController.m | 43 + ShiXiSeng_Main/Personinfo.h | 28 + ShiXiSeng_Main/Personinfo.m | 606 +++ ShiXiSeng_Main/PooCodeView.h | 15 + ShiXiSeng_Main/PooCodeView.m | 96 + ShiXiSeng_Main/PrefixHeader.pch | 20 + ShiXiSeng_Main/Project_exp.h | 18 + ShiXiSeng_Main/Project_exp.m | 81 + ShiXiSeng_Main/PwdViewController.h | 16 + ShiXiSeng_Main/PwdViewController.m | 40 + ShiXiSeng_Main/RefuseMsg.h | 15 + ShiXiSeng_Main/RefuseMsg.m | 124 + ShiXiSeng_Main/RefuseMsg.xib | 24 + ShiXiSeng_Main/Register.h | 17 + ShiXiSeng_Main/Register.m | 214 + ShiXiSeng_Main/Rest.h | 13 + ShiXiSeng_Main/Rest.m | 37 + ShiXiSeng_Main/School_exp.h | 17 + ShiXiSeng_Main/School_exp.m | 59 + ShiXiSeng_Main/SignIn.h | 14 + ShiXiSeng_Main/SignIn.m | 326 ++ ShiXiSeng_Main/TESTTableViewController.h | 15 + ShiXiSeng_Main/TESTTableViewController.m | 184 + ShiXiSeng_Main/TestController.h | 13 + ShiXiSeng_Main/TestController.m | 80 + ShiXiSeng_Main/TestViewController.h | 16 + ShiXiSeng_Main/TestViewController.m | 40 + ShiXiSeng_Main/ViewController.h | 3 + ShiXiSeng_Main/Work_Day.h | 38 + ShiXiSeng_Main/Work_Day.m | 217 + ShiXiSeng_Main/com.h | 53 + ShiXiSeng_Main/com.m | 276 + ShiXiSeng_Main/job_sub_content.h | 32 + ShiXiSeng_Main/job_sub_content.m | 94 + ShiXiSeng_Main/jobcollect_cell.h | 43 + ShiXiSeng_Main/jobcollect_cell.m | 251 + ShiXiSeng_Main/lookMsg.h | 13 + ShiXiSeng_Main/lookMsg.m | 124 + ShiXiSeng_Main/lookMsg.xib | 24 + ShiXiSeng_Main/position.h | 18 + ShiXiSeng_Main/position.m | 23 + ShiXiSeng_Main/salary_range.plist | 30 + ShiXiSeng_Main/work_cell.h | 26 + ShiXiSeng_Main/work_cell.m | 54 + ShiXiSeng_Main/work_days.plist | 22 + ShiXiSeng_Main/work_exp.h | 17 + ShiXiSeng_Main/work_exp.m | 83 + ShiXiSeng_Main/work_time.plist | 22 + ShiXiSeng_Main/workday.h | 31 + ShiXiSeng_Main/workday.m | 133 + ...5\347\247\221\345\255\246\351\231\242.png" | Bin 0 -> 6180 bytes "ShiXiSeng_Main/\344\272\254\344\270\234.png" | Bin 0 -> 5105 bytes ...0\345\227\222\346\270\205\345\215\225.png" | Bin 0 -> 5612 bytes "ShiXiSeng_Main/\345\256\232\344\275\215.png" | Bin 0 -> 3098 bytes "ShiXiSeng_Main/\346\227\245\345\216\206.png" | Bin 0 -> 3122 bytes .../\347\210\261\345\245\207\350\211\272.png" | Bin 0 -> 7475 bytes .../\347\231\276\350\257\215\346\226\251.png" | Bin 0 -> 4105 bytes "ShiXiSeng_Main/\350\201\224\346\203\263.png" | Bin 0 -> 3947 bytes TAAbstractDotView.h | 24 + TAAbstractDotView.m | 30 + TAAnimatedDotView.h | 15 + TAAnimatedDotView.m | 88 + TADotView.h | 13 + TADotView.m | 63 + TAPageControl.h | 106 + TAPageControl.m | 364 ++ UIView+SDExtension.h | 22 + UIView+SDExtension.m | 77 + VPImageCropper/VPImageCropperViewController.h | 28 + VPImageCropper/VPImageCropperViewController.m | 287 ++ WXYZ_city.plist | 38 + YSLContainerViewController.h | 35 + YSLContainerViewController.m | 195 + YSLScrollMenuView.h | 37 + YSLScrollMenuView.m | 197 + city/CollectionHeadView.h | 17 + city/CollectionHeadView.m | 38 + city/test.h | 37 + city/test.m | 390 ++ city/testcell.h | 15 + city/testcell.m | 41 + hot_city.plist | 30 + image0.png | Bin 0 -> 156562 bytes image1.png | Bin 0 -> 156562 bytes image2.png | Bin 0 -> 156562 bytes image3.png | Bin 0 -> 156562 bytes industry.h | 39 + industry.m | 219 + industry.plist | 78 + industry_cell.h | 22 + industry_cell.m | 46 + lowest_study.plist | 26 + test.png | Bin 0 -> 2901 bytes "\345\217\221\347\216\260.png" | Bin 0 -> 22069 bytes "\346\210\221\347\232\204.png" | Bin 0 -> 22069 bytes "\346\234\272\344\274\232.png" | Bin 0 -> 22069 bytes "\346\266\210\346\201\257.png" | Bin 0 -> 22069 bytes 510 files changed, 50491 insertions(+), 104 deletions(-) create mode 100644 ABCDEF_city.plist create mode 100755 AFNetworking-master/.cocoadocs.yml create mode 100755 AFNetworking-master/.gitignore create mode 100755 AFNetworking-master/.travis.yml create mode 100755 AFNetworking-master/AFNetworking.podspec create mode 100755 AFNetworking-master/AFNetworking/AFHTTPRequestOperation.h create mode 100755 AFNetworking-master/AFNetworking/AFHTTPRequestOperation.m create mode 100755 AFNetworking-master/AFNetworking/AFHTTPRequestOperationManager.h create mode 100755 AFNetworking-master/AFNetworking/AFHTTPRequestOperationManager.m create mode 100755 AFNetworking-master/AFNetworking/AFHTTPSessionManager.h create mode 100755 AFNetworking-master/AFNetworking/AFHTTPSessionManager.m create mode 100755 AFNetworking-master/AFNetworking/AFNetworkReachabilityManager.h create mode 100755 AFNetworking-master/AFNetworking/AFNetworkReachabilityManager.m create mode 100755 AFNetworking-master/AFNetworking/AFNetworking.h create mode 100755 AFNetworking-master/AFNetworking/AFSecurityPolicy.h create mode 100755 AFNetworking-master/AFNetworking/AFSecurityPolicy.m create mode 100755 AFNetworking-master/AFNetworking/AFURLConnectionOperation.h create mode 100755 AFNetworking-master/AFNetworking/AFURLConnectionOperation.m create mode 100755 AFNetworking-master/AFNetworking/AFURLRequestSerialization.h create mode 100755 AFNetworking-master/AFNetworking/AFURLRequestSerialization.m create mode 100755 AFNetworking-master/AFNetworking/AFURLResponseSerialization.h create mode 100755 AFNetworking-master/AFNetworking/AFURLResponseSerialization.m create mode 100755 AFNetworking-master/AFNetworking/AFURLSessionManager.h create mode 100755 AFNetworking-master/AFNetworking/AFURLSessionManager.m create mode 100755 AFNetworking-master/CHANGES create mode 100755 AFNetworking-master/CONTRIBUTING.md create mode 100755 AFNetworking-master/Example/AFNetworking Example.entitlements create mode 100755 AFNetworking-master/Example/AFNetworking OS X Example.xcodeproj/project.pbxproj create mode 100755 AFNetworking-master/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj create mode 100755 AFNetworking-master/Example/AppDelegate.h create mode 100755 AFNetworking-master/Example/AppDelegate.m create mode 100755 AFNetworking-master/Example/Classes/AFAppDotNetAPIClient.h create mode 100755 AFNetworking-master/Example/Classes/AFAppDotNetAPIClient.m create mode 100755 AFNetworking-master/Example/Classes/Controllers/GlobalTimelineViewController.h create mode 100755 AFNetworking-master/Example/Classes/Controllers/GlobalTimelineViewController.m create mode 100755 AFNetworking-master/Example/Classes/Models/Post.h create mode 100755 AFNetworking-master/Example/Classes/Models/Post.m create mode 100755 AFNetworking-master/Example/Classes/Models/User.h create mode 100755 AFNetworking-master/Example/Classes/Models/User.m create mode 100755 AFNetworking-master/Example/Classes/Views/PostTableViewCell.h create mode 100755 AFNetworking-master/Example/Classes/Views/PostTableViewCell.m create mode 100755 AFNetworking-master/Example/Default-568h@2x.png create mode 100755 AFNetworking-master/Example/Default.png create mode 100755 AFNetworking-master/Example/Default@2x.png create mode 100755 AFNetworking-master/Example/Icon.png create mode 100755 AFNetworking-master/Example/Icon@2x.png create mode 100755 AFNetworking-master/Example/Images/profile-image-placeholder.png create mode 100755 AFNetworking-master/Example/Images/profile-image-placeholder@2x.png create mode 100755 AFNetworking-master/Example/Mac-Info.plist create mode 100755 AFNetworking-master/Example/MainMenu.xib create mode 100755 AFNetworking-master/Example/Prefix.pch create mode 100755 AFNetworking-master/Example/adn.cer create mode 100755 AFNetworking-master/Example/digicert_ca_3.cer create mode 100755 AFNetworking-master/Example/en.lproj/MainMenu.xib create mode 100755 AFNetworking-master/Example/iOS-Info.plist create mode 100755 AFNetworking-master/Example/main.m create mode 100755 AFNetworking-master/Example/root_ca.cer create mode 100755 AFNetworking-master/LICENSE create mode 100755 AFNetworking-master/README.md create mode 100755 AFNetworking-master/Rakefile create mode 100755 AFNetworking-master/Tests/AFNetworking Tests.xcodeproj/project.pbxproj create mode 100755 AFNetworking-master/Tests/AFNetworking-Prefix.pch create mode 100755 AFNetworking-master/Tests/AFNetworkingTests-Info.plist create mode 100755 AFNetworking-master/Tests/OS X Tests/OS X Tests-Info.plist create mode 100755 AFNetworking-master/Tests/OS X Tests/OS X Tests-Prefix.pch create mode 100755 AFNetworking-master/Tests/OS X Tests/en.lproj/InfoPlist.strings create mode 100755 AFNetworking-master/Tests/Podfile create mode 100755 AFNetworking-master/Tests/Resources/ADN.net/ADNNetServerTrustChain/adn_0.cer create mode 100755 AFNetworking-master/Tests/Resources/ADN.net/ADNNetServerTrustChain/adn_1.cer create mode 100755 AFNetworking-master/Tests/Resources/ADN.net/ADNNetServerTrustChain/adn_2.cer create mode 100755 AFNetworking-master/Tests/Resources/HTTPBin.org/AddTrust_External_CA_Root.cer create mode 100755 AFNetworking-master/Tests/Resources/HTTPBin.org/COMODO_RSA_Certification_Authority.cer create mode 100755 AFNetworking-master/Tests/Resources/HTTPBin.org/COMODO_RSA_Domain_Validation_Secure_Server_CA.cer create mode 100755 AFNetworking-master/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_0.cer create mode 100755 AFNetworking-master/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_1.cer create mode 100755 AFNetworking-master/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_2.cer create mode 100755 AFNetworking-master/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_3.cer create mode 100755 AFNetworking-master/Tests/Resources/HTTPBin.org/httpbinorg_01162016.cer create mode 100755 AFNetworking-master/Tests/Resources/SelfSigned/AltName.cer create mode 100755 AFNetworking-master/Tests/Resources/SelfSigned/NoDomains.cer create mode 100755 AFNetworking-master/Tests/Resources/SelfSigned/foobar.com.cer create mode 100755 AFNetworking-master/Tests/Schemes/OS X Tests.xcscheme create mode 100755 AFNetworking-master/Tests/Schemes/iOS Tests.xcscheme create mode 100755 AFNetworking-master/Tests/Tests/1.0 Tests/AFHTTPClientTests.m create mode 100755 AFNetworking-master/Tests/Tests/1.0 Tests/AFHTTPRequestOperationTests.m create mode 100755 AFNetworking-master/Tests/Tests/1.0 Tests/AFImageRequestOperationTests.m create mode 100755 AFNetworking-master/Tests/Tests/1.0 Tests/AFJSONRequestOperationTests.m create mode 100755 AFNetworking-master/Tests/Tests/1.0 Tests/AFMockURLProtocol.h create mode 100755 AFNetworking-master/Tests/Tests/1.0 Tests/AFMockURLProtocol.m create mode 100755 AFNetworking-master/Tests/Tests/1.0 Tests/AFNetworkingTests.h create mode 100755 AFNetworking-master/Tests/Tests/1.0 Tests/AFNetworkingTests.m create mode 100755 AFNetworking-master/Tests/Tests/1.0 Tests/AFURLConnectionOperationTests.m create mode 100755 AFNetworking-master/Tests/Tests/AFHTTPRequestOperationTests.m create mode 100755 AFNetworking-master/Tests/Tests/AFHTTPRequestSerializationTests.m create mode 100755 AFNetworking-master/Tests/Tests/AFHTTPResponseSerializationTests.m create mode 100755 AFNetworking-master/Tests/Tests/AFHTTPSessionManagerTests.m create mode 100755 AFNetworking-master/Tests/Tests/AFJSONSerializationTests.m create mode 100755 AFNetworking-master/Tests/Tests/AFNetworkActivityManagerTests.m create mode 100755 AFNetworking-master/Tests/Tests/AFNetworkReachabilityManagerTests.m create mode 100755 AFNetworking-master/Tests/Tests/AFPropertyListResponseSerializerTests.m create mode 100755 AFNetworking-master/Tests/Tests/AFSecurityPolicyTests.m create mode 100755 AFNetworking-master/Tests/Tests/AFTestCase.h create mode 100755 AFNetworking-master/Tests/Tests/AFTestCase.m create mode 100755 AFNetworking-master/Tests/Tests/AFURLSessionManagerTests.m create mode 100755 AFNetworking-master/Tests/iOS Tests/en.lproj/InfoPlist.strings create mode 100755 AFNetworking-master/Tests/iOS Tests/iOS Tests-Info.plist create mode 100755 AFNetworking-master/Tests/iOS Tests/iOS Tests-Prefix.pch create mode 100755 AFNetworking-master/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h create mode 100755 AFNetworking-master/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIAlertView+AFNetworking.h create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIAlertView+AFNetworking.m create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIButton+AFNetworking.h create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIButton+AFNetworking.m create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIImageView+AFNetworking.h create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIImageView+AFNetworking.m create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIKit+AFNetworking.h create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIProgressView+AFNetworking.h create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIProgressView+AFNetworking.m create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIWebView+AFNetworking.h create mode 100755 AFNetworking-master/UIKit+AFNetworking/UIWebView+AFNetworking.m create mode 100644 AdDataModel.h create mode 100644 AdDataModel.m create mode 100644 AdDataPlist.plist create mode 100644 AdScrollView.h create mode 100644 AdScrollView.m create mode 100755 ArtistsCell.h create mode 100755 ArtistsCell.m create mode 100755 ArtistsCell.xib create mode 100755 ArtistsViewController.h create mode 100755 ArtistsViewController.m create mode 100755 ArtistsViewController.xib create mode 100755 CNPPopupController.h create mode 100755 CNPPopupController.m create mode 100755 DAContextMenuTableViewController/DAContextMenuCell.h create mode 100755 DAContextMenuTableViewController/DAContextMenuCell.m create mode 100755 DAContextMenuTableViewController/DAContextMenuTableViewController.h create mode 100755 DAContextMenuTableViewController/DAContextMenuTableViewController.m create mode 100755 DAContextMenuTableViewController/DAOverlayView.h create mode 100755 DAContextMenuTableViewController/DAOverlayView.m create mode 100755 DetailViewController.h create mode 100755 DetailViewController.m create mode 100755 DetailViewController.xib create mode 100644 DownSheet/DownSheet.xcodeproj/project.pbxproj create mode 100644 DownSheet/DownSheet.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 DownSheet/DownSheet.xcodeproj/xcuserdata/donelaccount.xcuserdatad/xcschemes/DownSheet.xcscheme create mode 100644 DownSheet/DownSheet.xcodeproj/xcuserdata/donelaccount.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 DownSheet/DownSheet.xcodeproj/xcuserdata/luyan13956039509.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist create mode 100644 DownSheet/DownSheet.xcodeproj/xcuserdata/luyan13956039509.xcuserdatad/xcschemes/DownSheet.xcscheme create mode 100644 DownSheet/DownSheet.xcodeproj/xcuserdata/luyan13956039509.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 DownSheet/DownSheet.xcodeproj/xcuserdata/wolf.xcuserdatad/xcschemes/DownSheet.xcscheme create mode 100644 DownSheet/DownSheet.xcodeproj/xcuserdata/wolf.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 DownSheet/DownSheet/AppDelegate.h create mode 100644 DownSheet/DownSheet/AppDelegate.m create mode 100755 DownSheet/DownSheet/Classes/DownSheet.h create mode 100755 DownSheet/DownSheet/Classes/DownSheet.m create mode 100755 DownSheet/DownSheet/Classes/DownSheetCell.h create mode 100755 DownSheet/DownSheet/Classes/DownSheetCell.m create mode 100644 DownSheet/DownSheet/Classes/job_first.plist create mode 100644 DownSheet/DownSheet/Classes/job_second(0).plist create mode 100644 DownSheet/DownSheet/Classes/job_second(1).plist create mode 100644 DownSheet/DownSheet/Classes/job_second(10).plist create mode 100644 DownSheet/DownSheet/Classes/job_second(2).plist create mode 100644 DownSheet/DownSheet/Classes/job_second(3).plist create mode 100644 DownSheet/DownSheet/Classes/job_second(4).plist create mode 100644 DownSheet/DownSheet/Classes/job_second(5).plist create mode 100644 DownSheet/DownSheet/Classes/job_second(6).plist create mode 100644 DownSheet/DownSheet/Classes/job_second(7).plist create mode 100644 DownSheet/DownSheet/Classes/job_second(8).plist create mode 100644 DownSheet/DownSheet/Classes/job_second(9).plist create mode 100644 DownSheet/DownSheet/Classes/job_third(0).plist create mode 100644 DownSheet/DownSheet/Classes/job_third(1).plist create mode 100644 DownSheet/DownSheet/Classes/job_third(2).plist create mode 100644 DownSheet/DownSheet/DownSheet-Info.plist create mode 100644 DownSheet/DownSheet/DownSheet-Prefix.pch create mode 100644 DownSheet/DownSheet/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100644 DownSheet/DownSheet/Images.xcassets/LaunchImage.launchimage/Contents.json create mode 100644 DownSheet/DownSheet/Receive_email.h create mode 100644 DownSheet/DownSheet/Receive_email.m create mode 100755 DownSheet/DownSheet/Resouce/icon_add@2x.png create mode 100755 DownSheet/DownSheet/Resouce/icon_add_hover@2x.png create mode 100755 DownSheet/DownSheet/Resouce/icon_album@2x.png create mode 100755 DownSheet/DownSheet/Resouce/icon_album_hover@2x.png create mode 100644 DownSheet/DownSheet/Resouce/icon_buy@2x.png create mode 100644 DownSheet/DownSheet/Resouce/icon_buy_hover@2x.png create mode 100644 DownSheet/DownSheet/Resouce/icon_computer@2x.png create mode 100644 DownSheet/DownSheet/Resouce/icon_computer_hover@2x.png create mode 100755 DownSheet/DownSheet/Resouce/icon_del@2x.png create mode 100755 DownSheet/DownSheet/Resouce/icon_del_hover@2x.png create mode 100755 DownSheet/DownSheet/Resouce/icon_down@2x.png create mode 100755 DownSheet/DownSheet/Resouce/icon_down_hover@2x.png create mode 100644 DownSheet/DownSheet/ViewController.h create mode 100644 DownSheet/DownSheet/ViewController.m create mode 100644 DownSheet/DownSheet/Work_Day.h create mode 100644 DownSheet/DownSheet/Work_Day.m create mode 100644 DownSheet/DownSheet/email.h create mode 100644 DownSheet/DownSheet/email.m create mode 100644 DownSheet/DownSheet/en.lproj/InfoPlist.strings create mode 100644 DownSheet/DownSheet/lowest_study.plist create mode 100644 DownSheet/DownSheet/main.m create mode 100644 DownSheet/DownSheet/salary_range.plist create mode 100644 DownSheet/DownSheet/school_exp.plist create mode 100644 DownSheet/DownSheet/send_cycle.plist create mode 100644 DownSheet/DownSheet/time_window.h create mode 100644 DownSheet/DownSheet/time_window.m create mode 100644 DownSheet/DownSheet/work_cell.h create mode 100644 DownSheet/DownSheet/work_cell.m create mode 100644 DownSheet/DownSheet/work_days.plist create mode 100644 DownSheet/DownSheet/work_time.plist create mode 100644 DownSheet/DownSheet/workday.h create mode 100644 DownSheet/DownSheet/workday.m create mode 100644 DownSheet/DownSheetTests/DownSheetTests-Info.plist create mode 100644 DownSheet/DownSheetTests/DownSheetTests.m create mode 100644 DownSheet/DownSheetTests/en.lproj/InfoPlist.strings create mode 100755 EAIntroPage.h create mode 100755 EAIntroPage.m create mode 100755 EAIntroView.h create mode 100755 EAIntroView.m create mode 100644 GHIJ_city.plist create mode 100644 KLMN_city.plist create mode 100755 NSData+SDDataCache.h create mode 100755 NSData+SDDataCache.m create mode 100644 OPQR_city.plist create mode 100755 PlayListCell.h create mode 100755 PlayListCell.m create mode 100755 PlayListCell.xib create mode 100755 PlayListTableViewController.h create mode 100755 PlayListTableViewController.m create mode 100755 PlayListTableViewController.xib create mode 100644 README.md create mode 100755 SDCollectionViewCell.h create mode 100755 SDCollectionViewCell.m create mode 100755 SDCycleScrollView.h create mode 100755 SDCycleScrollView.m create mode 100755 SRMonthPicker.h create mode 100755 SRMonthPicker.m create mode 100644 STUV_city.plist create mode 100755 SampleViewController.h create mode 100755 SampleViewController.m create mode 100755 SampleViewController.xib create mode 100644 ShiXiSeng_Main.xcodeproj/xcuserdata/luyan13956039509.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist create mode 100644 ShiXiSeng_Main/>=.png create mode 100644 ShiXiSeng_Main/About.h create mode 100644 ShiXiSeng_Main/About.m create mode 100644 ShiXiSeng_Main/Accountset.h create mode 100644 ShiXiSeng_Main/Accountset.m create mode 100644 ShiXiSeng_Main/AllMsg.h create mode 100644 ShiXiSeng_Main/AllMsg.m create mode 100644 ShiXiSeng_Main/AllMsg.xib delete mode 100644 ShiXiSeng_Main/Base.lproj/Main.storyboard create mode 100644 ShiXiSeng_Main/ChanceViewController.h create mode 100644 ShiXiSeng_Main/ChanceViewController.m create mode 100755 ShiXiSeng_Main/Classes/DownSheet.h create mode 100755 ShiXiSeng_Main/Classes/DownSheet.m create mode 100755 ShiXiSeng_Main/Classes/DownSheetCell.h create mode 100755 ShiXiSeng_Main/Classes/DownSheetCell.m create mode 100644 ShiXiSeng_Main/Classes/job_first.plist create mode 100644 ShiXiSeng_Main/Classes/job_second(0).plist create mode 100644 ShiXiSeng_Main/Classes/job_second(1).plist create mode 100644 ShiXiSeng_Main/Classes/job_second(10).plist create mode 100644 ShiXiSeng_Main/Classes/job_second(2).plist create mode 100644 ShiXiSeng_Main/Classes/job_second(3).plist create mode 100644 ShiXiSeng_Main/Classes/job_second(4).plist create mode 100644 ShiXiSeng_Main/Classes/job_second(5).plist create mode 100644 ShiXiSeng_Main/Classes/job_second(6).plist create mode 100644 ShiXiSeng_Main/Classes/job_second(7).plist create mode 100644 ShiXiSeng_Main/Classes/job_second(8).plist create mode 100644 ShiXiSeng_Main/Classes/job_second(9).plist create mode 100644 ShiXiSeng_Main/Classes/job_third(0).plist create mode 100644 ShiXiSeng_Main/Classes/job_third(1).plist create mode 100644 ShiXiSeng_Main/Classes/job_third(2).plist create mode 100644 ShiXiSeng_Main/CompanyInfoa.h create mode 100644 ShiXiSeng_Main/CompanyInfoa.m create mode 100644 ShiXiSeng_Main/CompanyPosition.h create mode 100644 ShiXiSeng_Main/CompanyPosition.m create mode 100644 ShiXiSeng_Main/CustomToolbar.h create mode 100644 ShiXiSeng_Main/CustomToolbar.m create mode 100644 ShiXiSeng_Main/Delegate.h create mode 100644 ShiXiSeng_Main/Education_exp.h create mode 100644 ShiXiSeng_Main/Education_exp.m create mode 100644 ShiXiSeng_Main/ExitViewController.h create mode 100644 ShiXiSeng_Main/ExitViewController.m create mode 100644 ShiXiSeng_Main/FeedBackViewController.h create mode 100644 ShiXiSeng_Main/FeedBackViewController.m create mode 100644 ShiXiSeng_Main/Fill_Record.h create mode 100644 ShiXiSeng_Main/Fill_Record.m create mode 100644 ShiXiSeng_Main/Fill_Record_Cell.h create mode 100644 ShiXiSeng_Main/Fill_Record_Cell.m create mode 100644 ShiXiSeng_Main/FindControllerViewController.h create mode 100644 ShiXiSeng_Main/FindControllerViewController.m create mode 100644 ShiXiSeng_Main/FindViewController.h create mode 100644 ShiXiSeng_Main/FindViewController.m create mode 100644 ShiXiSeng_Main/FixCom.h create mode 100644 ShiXiSeng_Main/FixCom.m create mode 100644 ShiXiSeng_Main/FixCompany.h create mode 100644 ShiXiSeng_Main/FixCompany.m create mode 100644 ShiXiSeng_Main/Hope.h create mode 100644 ShiXiSeng_Main/Hope.m create mode 100644 ShiXiSeng_Main/Images.xcassets/AppIcon.appiconset/29-1.png create mode 100644 ShiXiSeng_Main/Images.xcassets/AppIcon.appiconset/29.png create mode 100644 ShiXiSeng_Main/Images.xcassets/AppIcon.appiconset/40.png create mode 100644 ShiXiSeng_Main/Images.xcassets/AppIcon.appiconset/57-1.png create mode 100644 ShiXiSeng_Main/Images.xcassets/AppIcon.appiconset/57.png create mode 100644 ShiXiSeng_Main/Images.xcassets/AppIcon.appiconset/60-1.png create mode 100644 ShiXiSeng_Main/Images.xcassets/AppIcon.appiconset/60.png create mode 100644 ShiXiSeng_Main/Images.xcassets/Chance/homeICON.imageset/Contents.json create mode 100644 ShiXiSeng_Main/Images.xcassets/Chance/homeICON.imageset/homeICON.png create mode 100644 ShiXiSeng_Main/Images.xcassets/Chance/website.imageset/Contents.json create mode 100644 ShiXiSeng_Main/Images.xcassets/Chance/website.imageset/website.png create mode 100644 ShiXiSeng_Main/Images.xcassets/Intro/1.imageset/1.png create mode 100644 ShiXiSeng_Main/Images.xcassets/Intro/1.imageset/Contents.json create mode 100644 ShiXiSeng_Main/Images.xcassets/Intro/2.imageset/2.png create mode 100644 ShiXiSeng_Main/Images.xcassets/Intro/2.imageset/Contents.json create mode 100644 ShiXiSeng_Main/Images.xcassets/Intro/3.imageset/3.png create mode 100644 ShiXiSeng_Main/Images.xcassets/Intro/3.imageset/Contents.json create mode 100644 ShiXiSeng_Main/Images.xcassets/LaunchImage.launchimage/Contents.json create mode 100644 ShiXiSeng_Main/Images.xcassets/delete.imageset/Contents.json create mode 100644 ShiXiSeng_Main/Images.xcassets/delete.imageset/delete.png create mode 100644 ShiXiSeng_Main/Images.xcassets/pencil.imageset/Contents.json create mode 100644 ShiXiSeng_Main/Images.xcassets/pencil.imageset/pencil.png create mode 100644 "ShiXiSeng_Main/Images.xcassets/tabBar/\345\217\221\347\216\260.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/tabBar/\345\217\221\347\216\260.imageset/\345\217\221\347\216\260.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/tabBar/\346\210\221\347\232\204.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/tabBar/\346\210\221\347\232\204.imageset/\346\210\221\347\232\204.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/tabBar/\346\234\272\344\274\232.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/tabBar/\346\234\272\344\274\232.imageset/\346\234\272\344\274\232.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/tabBar/\346\266\210\346\201\257.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/tabBar/\346\266\210\346\201\257.imageset/\346\266\210\346\201\257.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\205\263\344\272\216\345\256\236\344\271\240\345\203\247/\345\205\263\344\272\216\345\256\236\344\271\240\345\203\247.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\205\263\344\272\216\345\256\236\344\271\240\345\203\247/\345\205\263\344\272\216\345\256\236\344\271\240\345\203\247.imageset/\345\205\263\344\272\216\345\256\236\344\271\240\345\203\247.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\205\263\344\272\216\345\256\236\344\271\240\345\203\247/\345\217\221\351\200\201.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\205\263\344\272\216\345\256\236\344\271\240\345\203\247/\345\217\221\351\200\201.imageset/\345\217\221\351\200\201.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206.imageset/\345\241\253\345\206\231\347\256\200\345\216\206.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/add.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/add.imageset/add.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/edit1.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/edit1.imageset/edit1.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/email.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/email.imageset/email.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/phone.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/phone.imageset/phone.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/school.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/school.imageset/school.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/\345\241\253\345\206\231\350\203\214\346\231\257.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/\345\241\253\345\206\231\350\203\214\346\231\257.imageset/\345\241\253\345\206\231\347\256\200\345\216\206.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/\347\274\226\350\276\221.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\241\253\345\206\231\347\256\200\345\216\206/\347\274\226\350\276\221.imageset/\347\274\226\350\276\221.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\244\264\345\203\217.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\244\264\345\203\217.imageset/\345\244\264\345\203\217.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\267\262\345\205\263\346\263\250\345\205\254\345\217\270.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\267\262\345\205\263\346\263\250\345\205\254\345\217\270.imageset/\345\267\262\345\205\263\346\263\250\345\205\254\345\217\270.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\267\262\346\224\266\350\227\217\350\201\214\344\275\215.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\345\267\262\346\224\266\350\227\217\350\201\214\344\275\215.imageset/\345\267\262\346\224\266\350\227\217\350\201\214\344\275\215.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\346\210\221\347\232\204\350\203\214\346\231\257.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\346\210\221\347\232\204\350\203\214\346\231\257.imageset/MineBG.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\346\212\225\351\200\222\347\272\252\345\275\225.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\346\212\225\351\200\222\347\272\252\345\275\225.imageset/\346\212\225\351\200\222\347\272\252\345\275\225.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\350\201\214\344\275\215\350\256\242\351\230\205.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\350\201\214\344\275\215\350\256\242\351\230\205.imageset/\350\201\214\344\275\215\350\256\242\351\230\205.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\350\256\276\347\275\256.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\344\270\252\344\272\272\344\270\255\345\277\203/\350\256\276\347\275\256.imageset/\350\256\276\347\275\256.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\345\207\206\345\244\207\351\241\265.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\345\207\206\345\244\207\351\241\265.imageset/\345\212\240\350\275\275\351\241\265\351\235\242.png" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\347\231\273\345\275\225\347\225\214\351\235\242.imageset/Contents.json" create mode 100644 "ShiXiSeng_Main/Images.xcassets/\347\231\273\345\275\225\347\225\214\351\235\242.imageset/\347\231\273\345\275\225\347\225\214\351\235\242.png" create mode 100644 ShiXiSeng_Main/InteMsg.h create mode 100644 ShiXiSeng_Main/InteMsg.m create mode 100644 ShiXiSeng_Main/InteMsg.xib create mode 100644 ShiXiSeng_Main/Job.h create mode 100644 ShiXiSeng_Main/Job.m create mode 100644 ShiXiSeng_Main/Job.plist create mode 100644 ShiXiSeng_Main/Job.xib create mode 100644 ShiXiSeng_Main/JobCell.h create mode 100644 ShiXiSeng_Main/JobCell.m create mode 100644 ShiXiSeng_Main/JobCollect.h create mode 100644 ShiXiSeng_Main/JobCollect.m create mode 100644 ShiXiSeng_Main/JobInfoa.h create mode 100644 ShiXiSeng_Main/JobInfoa.m create mode 100644 ShiXiSeng_Main/JobTable.h create mode 100644 ShiXiSeng_Main/JobTable.m create mode 100644 ShiXiSeng_Main/JobView.h create mode 100644 ShiXiSeng_Main/JobView.m create mode 100644 ShiXiSeng_Main/Job_Sub_Cell.h create mode 100644 ShiXiSeng_Main/Job_Sub_Cell.m create mode 100644 ShiXiSeng_Main/Job_Subscribe.h create mode 100644 ShiXiSeng_Main/Job_Subscribe.m create mode 100644 ShiXiSeng_Main/Jobdetail.h create mode 100644 ShiXiSeng_Main/Jobdetail.m create mode 100644 ShiXiSeng_Main/MViewController.h create mode 100644 ShiXiSeng_Main/MViewController.m create mode 100644 ShiXiSeng_Main/Main.storyboard create mode 100644 ShiXiSeng_Main/MessageViewController.h create mode 100644 ShiXiSeng_Main/MessageViewController.m create mode 100644 ShiXiSeng_Main/MineTableViewController.h create mode 100644 ShiXiSeng_Main/MineTableViewController.m create mode 100644 ShiXiSeng_Main/MsgCell.h create mode 100644 ShiXiSeng_Main/MsgCell.m create mode 100644 ShiXiSeng_Main/MsgCell.xib create mode 100644 ShiXiSeng_Main/MsgDetail.h create mode 100644 ShiXiSeng_Main/MsgDetail.m create mode 100644 ShiXiSeng_Main/NewMessage.h create mode 100644 ShiXiSeng_Main/NewMessage.m create mode 100644 ShiXiSeng_Main/OneDelegate.m create mode 100644 ShiXiSeng_Main/PViewController.h create mode 100644 ShiXiSeng_Main/PViewController.m create mode 100644 ShiXiSeng_Main/Personinfo.h create mode 100644 ShiXiSeng_Main/Personinfo.m create mode 100644 ShiXiSeng_Main/PooCodeView.h create mode 100644 ShiXiSeng_Main/PooCodeView.m create mode 100644 ShiXiSeng_Main/PrefixHeader.pch create mode 100644 ShiXiSeng_Main/Project_exp.h create mode 100644 ShiXiSeng_Main/Project_exp.m create mode 100644 ShiXiSeng_Main/PwdViewController.h create mode 100644 ShiXiSeng_Main/PwdViewController.m create mode 100644 ShiXiSeng_Main/RefuseMsg.h create mode 100644 ShiXiSeng_Main/RefuseMsg.m create mode 100644 ShiXiSeng_Main/RefuseMsg.xib create mode 100644 ShiXiSeng_Main/Register.h create mode 100644 ShiXiSeng_Main/Register.m create mode 100644 ShiXiSeng_Main/Rest.h create mode 100644 ShiXiSeng_Main/Rest.m create mode 100644 ShiXiSeng_Main/School_exp.h create mode 100644 ShiXiSeng_Main/School_exp.m create mode 100644 ShiXiSeng_Main/SignIn.h create mode 100644 ShiXiSeng_Main/SignIn.m create mode 100644 ShiXiSeng_Main/TESTTableViewController.h create mode 100644 ShiXiSeng_Main/TESTTableViewController.m create mode 100644 ShiXiSeng_Main/TestController.h create mode 100644 ShiXiSeng_Main/TestController.m create mode 100644 ShiXiSeng_Main/TestViewController.h create mode 100644 ShiXiSeng_Main/TestViewController.m create mode 100644 ShiXiSeng_Main/Work_Day.h create mode 100644 ShiXiSeng_Main/Work_Day.m create mode 100644 ShiXiSeng_Main/com.h create mode 100644 ShiXiSeng_Main/com.m create mode 100644 ShiXiSeng_Main/job_sub_content.h create mode 100644 ShiXiSeng_Main/job_sub_content.m create mode 100644 ShiXiSeng_Main/jobcollect_cell.h create mode 100644 ShiXiSeng_Main/jobcollect_cell.m create mode 100644 ShiXiSeng_Main/lookMsg.h create mode 100644 ShiXiSeng_Main/lookMsg.m create mode 100644 ShiXiSeng_Main/lookMsg.xib create mode 100644 ShiXiSeng_Main/position.h create mode 100644 ShiXiSeng_Main/position.m create mode 100644 ShiXiSeng_Main/salary_range.plist create mode 100644 ShiXiSeng_Main/work_cell.h create mode 100644 ShiXiSeng_Main/work_cell.m create mode 100644 ShiXiSeng_Main/work_days.plist create mode 100644 ShiXiSeng_Main/work_exp.h create mode 100644 ShiXiSeng_Main/work_exp.m create mode 100644 ShiXiSeng_Main/work_time.plist create mode 100644 ShiXiSeng_Main/workday.h create mode 100644 ShiXiSeng_Main/workday.m create mode 100644 "ShiXiSeng_Main/\344\270\255\345\233\275\347\247\221\345\255\246\351\231\242.png" create mode 100644 "ShiXiSeng_Main/\344\272\254\344\270\234.png" create mode 100644 "ShiXiSeng_Main/\345\230\200\345\227\222\346\270\205\345\215\225.png" create mode 100644 "ShiXiSeng_Main/\345\256\232\344\275\215.png" create mode 100644 "ShiXiSeng_Main/\346\227\245\345\216\206.png" create mode 100644 "ShiXiSeng_Main/\347\210\261\345\245\207\350\211\272.png" create mode 100644 "ShiXiSeng_Main/\347\231\276\350\257\215\346\226\251.png" create mode 100644 "ShiXiSeng_Main/\350\201\224\346\203\263.png" create mode 100755 TAAbstractDotView.h create mode 100755 TAAbstractDotView.m create mode 100755 TAAnimatedDotView.h create mode 100755 TAAnimatedDotView.m create mode 100755 TADotView.h create mode 100755 TADotView.m create mode 100755 TAPageControl.h create mode 100755 TAPageControl.m create mode 100755 UIView+SDExtension.h create mode 100755 UIView+SDExtension.m create mode 100755 VPImageCropper/VPImageCropperViewController.h create mode 100755 VPImageCropper/VPImageCropperViewController.m create mode 100644 WXYZ_city.plist create mode 100755 YSLContainerViewController.h create mode 100755 YSLContainerViewController.m create mode 100755 YSLScrollMenuView.h create mode 100755 YSLScrollMenuView.m create mode 100644 city/CollectionHeadView.h create mode 100644 city/CollectionHeadView.m create mode 100644 city/test.h create mode 100644 city/test.m create mode 100644 city/testcell.h create mode 100644 city/testcell.m create mode 100644 hot_city.plist create mode 100644 image0.png create mode 100644 image1.png create mode 100644 image2.png create mode 100644 image3.png create mode 100644 industry.h create mode 100644 industry.m create mode 100644 industry.plist create mode 100644 industry_cell.h create mode 100644 industry_cell.m create mode 100644 lowest_study.plist create mode 100644 test.png create mode 100644 "\345\217\221\347\216\260.png" create mode 100644 "\346\210\221\347\232\204.png" create mode 100644 "\346\234\272\344\274\232.png" create mode 100644 "\346\266\210\346\201\257.png" diff --git a/ABCDEF_city.plist b/ABCDEF_city.plist new file mode 100644 index 0000000..cadb6cd --- /dev/null +++ b/ABCDEF_city.plist @@ -0,0 +1,42 @@ + + + + + + hot_city + 北京 + + + hot_city + 成都 + + + hot_city + 大连 + + + hot_city + 重庆 + + + hot_city + 佛山 + + + hot_city + 大庆 + + + hot_city + 长沙 + + + hot_city + 福州 + + + hot_city + 长春 + + + diff --git a/AFNetworking-master/.cocoadocs.yml b/AFNetworking-master/.cocoadocs.yml new file mode 100755 index 0000000..aaf16cb --- /dev/null +++ b/AFNetworking-master/.cocoadocs.yml @@ -0,0 +1,7 @@ +highlight-color: "#F89915" +highlight-dark-color: "#E23B1B" +darker-color: "#D8A688" +darker-dark-color: "#E93D1C" +background-color: "#E9DFDB" +alt-link-color: "#E23B1B" +warning-color: "#E23B1B" diff --git a/AFNetworking-master/.gitignore b/AFNetworking-master/.gitignore new file mode 100755 index 0000000..d9b2144 --- /dev/null +++ b/AFNetworking-master/.gitignore @@ -0,0 +1,21 @@ +# Xcode +.DS_Store +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +*.xcworkspace +!default.xcworkspace +xcuserdata +profile +*.moved-aside +DerivedData +.idea/ +Tests/Pods +Tests/Podfile.lock +Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/ diff --git a/AFNetworking-master/.travis.yml b/AFNetworking-master/.travis.yml new file mode 100755 index 0000000..b669ab6 --- /dev/null +++ b/AFNetworking-master/.travis.yml @@ -0,0 +1,7 @@ +language: objective-c +before_install: + - gem install cocoapods --no-rdoc --no-ri --no-document --quiet + - gem install xcpretty --no-rdoc --no-ri --no-document --quiet + - cd Tests && pod install && cd $TRAVIS_BUILD_DIR +script: rake test + diff --git a/AFNetworking-master/AFNetworking.podspec b/AFNetworking-master/AFNetworking.podspec new file mode 100755 index 0000000..70739f5 --- /dev/null +++ b/AFNetworking-master/AFNetworking.podspec @@ -0,0 +1,60 @@ +Pod::Spec.new do |s| + s.name = 'AFNetworking' + s.version = '2.5.3' + s.license = 'MIT' + s.summary = 'A delightful iOS and OS X networking framework.' + s.homepage = 'https://github.com/AFNetworking/AFNetworking' + s.social_media_url = 'https://twitter.com/AFNetworking' + s.authors = { 'Mattt Thompson' => 'm@mattt.me' } + s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => s.version, :submodules => true } + s.requires_arc = true + + s.ios.deployment_target = '6.0' + s.osx.deployment_target = '10.8' + + s.public_header_files = 'AFNetworking/*.h' + s.source_files = 'AFNetworking/AFNetworking.h' + + s.subspec 'Serialization' do |ss| + ss.source_files = 'AFNetworking/AFURL{Request,Response}Serialization.{h,m}' + ss.ios.frameworks = 'MobileCoreServices', 'CoreGraphics' + ss.osx.frameworks = 'CoreServices' + end + + s.subspec 'Security' do |ss| + ss.source_files = 'AFNetworking/AFSecurityPolicy.{h,m}' + ss.frameworks = 'Security' + end + + s.subspec 'Reachability' do |ss| + ss.source_files = 'AFNetworking/AFNetworkReachabilityManager.{h,m}' + ss.frameworks = 'SystemConfiguration' + end + + s.subspec 'NSURLConnection' do |ss| + ss.dependency 'AFNetworking/Serialization' + ss.dependency 'AFNetworking/Reachability' + ss.dependency 'AFNetworking/Security' + + ss.source_files = 'AFNetworking/AFURLConnectionOperation.{h,m}', 'AFNetworking/AFHTTPRequestOperation.{h,m}', 'AFNetworking/AFHTTPRequestOperationManager.{h,m}' + end + + s.subspec 'NSURLSession' do |ss| + ss.dependency 'AFNetworking/Serialization' + ss.dependency 'AFNetworking/Reachability' + ss.dependency 'AFNetworking/Security' + + ss.source_files = 'AFNetworking/AFURLSessionManager.{h,m}', 'AFNetworking/AFHTTPSessionManager.{h,m}' + end + + s.subspec 'UIKit' do |ss| + ss.ios.deployment_target = '6.0' + + ss.dependency 'AFNetworking/NSURLConnection' + ss.dependency 'AFNetworking/NSURLSession' + + ss.ios.public_header_files = 'UIKit+AFNetworking/*.h' + ss.ios.source_files = 'UIKit+AFNetworking' + ss.osx.source_files = '' + end +end diff --git a/AFNetworking-master/AFNetworking/AFHTTPRequestOperation.h b/AFNetworking-master/AFNetworking/AFHTTPRequestOperation.h new file mode 100755 index 0000000..321d4e7 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFHTTPRequestOperation.h @@ -0,0 +1,66 @@ +// AFHTTPRequestOperation.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import "AFURLConnectionOperation.h" + +/** + `AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request. + */ +@interface AFHTTPRequestOperation : AFURLConnectionOperation + +///------------------------------------------------ +/// @name Getting HTTP URL Connection Information +///------------------------------------------------ + +/** + The last HTTP response received by the operation's connection. + */ +@property (readonly, nonatomic, strong) NSHTTPURLResponse *response; + +/** + 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 AFHTTPResponse serializer, which uses the raw data as its response object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed. + + @warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +/** + An object constructed by the `responseSerializer` from the response and response data. Returns `nil` unless the operation `isFinished`, has a `response`, and has `responseData` with non-zero content length. If an error occurs during serialization, `nil` will be returned, and the `error` property will be populated with the serialization error. + */ +@property (readonly, nonatomic, strong) id responseObject; + +///----------------------------------------------------------- +/// @name Setting Completion Block Success / Failure Callbacks +///----------------------------------------------------------- + +/** + Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed. + + This method should be overridden in subclasses in order to specify the response object passed into the success block. + + @param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request. + @param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request. + */ +- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +@end diff --git a/AFNetworking-master/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking-master/AFNetworking/AFHTTPRequestOperation.m new file mode 100755 index 0000000..b8deda8 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFHTTPRequestOperation.m @@ -0,0 +1,206 @@ +// AFHTTPRequestOperation.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFHTTPRequestOperation.h" + +static dispatch_queue_t http_request_operation_processing_queue() { + static dispatch_queue_t af_http_request_operation_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_http_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.http-request.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_http_request_operation_processing_queue; +} + +static dispatch_group_t http_request_operation_completion_group() { + static dispatch_group_t af_http_request_operation_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_http_request_operation_completion_group = dispatch_group_create(); + }); + + return af_http_request_operation_completion_group; +} + +#pragma mark - + +@interface AFURLConnectionOperation () +@property (readwrite, nonatomic, strong) NSURLRequest *request; +@property (readwrite, nonatomic, strong) NSURLResponse *response; +@end + +@interface AFHTTPRequestOperation () +@property (readwrite, nonatomic, strong) NSHTTPURLResponse *response; +@property (readwrite, nonatomic, strong) id responseObject; +@property (readwrite, nonatomic, strong) NSError *responseSerializationError; +@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; +@end + +@implementation AFHTTPRequestOperation +@dynamic response; +@dynamic lock; + +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest { + self = [super initWithRequest:urlRequest]; + if (!self) { + return nil; + } + + self.responseSerializer = [AFHTTPResponseSerializer serializer]; + + return self; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + [self.lock lock]; + _responseSerializer = responseSerializer; + self.responseObject = nil; + self.responseSerializationError = nil; + [self.lock unlock]; +} + +- (id)responseObject { + [self.lock lock]; + if (!_responseObject && [self isFinished] && !self.error) { + NSError *error = nil; + self.responseObject = [self.responseSerializer responseObjectForResponse:self.response data:self.responseData error:&error]; + if (error) { + self.responseSerializationError = error; + } + } + [self.lock unlock]; + + return _responseObject; +} + +- (NSError *)error { + if (_responseSerializationError) { + return _responseSerializationError; + } else { + return [super error]; + } +} + +#pragma mark - AFHTTPRequestOperation + +- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + // completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wgnu" + self.completionBlock = ^{ + if (self.completionGroup) { + dispatch_group_enter(self.completionGroup); + } + + dispatch_async(http_request_operation_processing_queue(), ^{ + if (self.error) { + if (failure) { + dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + id responseObject = self.responseObject; + if (self.error) { + if (failure) { + dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + if (success) { + dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ + success(self, responseObject); + }); + } + } + } + + if (self.completionGroup) { + dispatch_group_leave(self.completionGroup); + } + }); + }; +#pragma clang diagnostic pop +} + +#pragma mark - AFURLRequestOperation + +- (void)pause { + [super pause]; + + u_int64_t offset = 0; + if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) { + offset = [(NSNumber *)[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue]; + } else { + offset = [(NSData *)[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length]; + } + + NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy]; + if ([self.response respondsToSelector:@selector(allHeaderFields)] && [[self.response allHeaderFields] valueForKey:@"ETag"]) { + [mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"]; + } + [mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"]; + self.request = mutableURLRequest; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPRequestOperation *operation = [super copyWithZone:zone]; + + operation.responseSerializer = [self.responseSerializer copyWithZone:zone]; + operation.completionQueue = self.completionQueue; + operation.completionGroup = self.completionGroup; + + return operation; +} + +@end diff --git a/AFNetworking-master/AFNetworking/AFHTTPRequestOperationManager.h b/AFNetworking-master/AFNetworking/AFHTTPRequestOperationManager.h new file mode 100755 index 0000000..17caa78 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFHTTPRequestOperationManager.h @@ -0,0 +1,323 @@ +// AFHTTPRequestOperationManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import +#import + +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#import +#else +#import +#endif + +#import "AFHTTPRequestOperation.h" +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" +#import "AFSecurityPolicy.h" +#import "AFNetworkReachabilityManager.h" + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +/** + `AFHTTPRequestOperationManager` encapsulates the common patterns of communicating with a web application over HTTP, including request creation, response serialization, network reachability monitoring, and security, as well as request operation management. + + ## Subclassing Notes + + 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. + + For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect. + + ## Methods to Override + + To change the behavior of all request operation construction for an `AFHTTPRequestOperationManager` subclass, override `HTTPRequestOperationWithRequest:success:failure`. + + ## Serialization + + Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``. + + Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `` + + ## URL Construction Using Relative Paths + + 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:`. + + Below are a few examples of how `baseURL` and relative paths interact: + + NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; + [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz + [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo + [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ + [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ + + 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. + + ## Network Reachability Monitoring + + 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. + + ## NSSecureCoding & NSCopying Caveats + + `AFHTTPRequestOperationManager` conforms to the `NSSecureCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. There are a few minor caveats to keep in mind, however: + + - Archives and copies of HTTP clients will be initialized with an empty operation queue. + - NSSecureCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set. + */ +@interface AFHTTPRequestOperationManager : NSObject + +/** + The URL used to monitor reachability, and construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. + */ +@property (readonly, nonatomic, strong) NSURL *baseURL; + +/** + 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. + + @warning `requestSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; + +/** + 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 a JSON serializer, which serializes data from responses with a `application/json` MIME type, and falls back to the raw data object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +/** + The operation queue on which request operations are scheduled and run. + */ +@property (nonatomic, strong) NSOperationQueue *operationQueue; + +///------------------------------- +/// @name Managing URL Credentials +///------------------------------- + +/** + Whether request operations should consult the credential storage for authenticating the connection. `YES` by default. + + @see AFURLConnectionOperation -shouldUseCredentialStorage + */ +@property (nonatomic, assign) BOOL shouldUseCredentialStorage; + +/** + The credential used by request operations for authentication challenges. + + @see AFURLConnectionOperation -credential + */ +@property (nonatomic, strong) NSURLCredential *credential; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used by created request operations to evaluate server trust for secure connections. `AFHTTPRequestOperationManager` uses the `defaultPolicy` unless otherwise specified. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +///------------------------------------ +/// @name Managing Network Reachability +///------------------------------------ + +/** + The network reachability manager. `AFHTTPRequestOperationManager` uses the `sharedManager` by default. + */ +@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager; + +///------------------------------- +/// @name Managing Callback Queues +///------------------------------- + +/** + The dispatch queue for the `completionBlock` of request operations. If `NULL` (default), the main queue is used. + */ +#if OS_OBJECT_HAVE_OBJC_SUPPORT +@property (nonatomic, strong) dispatch_queue_t completionQueue; +#else +@property (nonatomic, assign) dispatch_queue_t completionQueue; +#endif + +/** + The dispatch group for the `completionBlock` of request operations. If `NULL` (default), a private dispatch group is used. + */ +#if OS_OBJECT_HAVE_OBJC_SUPPORT +@property (nonatomic, strong) dispatch_group_t completionGroup; +#else +@property (nonatomic, assign) dispatch_group_t completionGroup; +#endif + +///--------------------------------------------- +/// @name Creating and Initializing HTTP Clients +///--------------------------------------------- + +/** + Creates and returns an `AFHTTPRequestOperationManager` object. + */ ++ (instancetype)manager; + +/** + Initializes an `AFHTTPRequestOperationManager` object with the specified base URL. + + This is the designated initializer. + + @param url The base URL for the HTTP client. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(NSURL *)url NS_DESIGNATED_INITIALIZER; + +///--------------------------------------- +/// @name Managing HTTP Request Operations +///--------------------------------------- + +/** + Creates an `AFHTTPRequestOperation`, and sets the response serializers to that of the HTTP client. + + @param request The request object to be loaded asynchronously during execution of the operation. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. + */ +- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +///--------------------------- +/// @name Making HTTP Requests +///--------------------------- + +/** + Creates and runs an `AFHTTPRequestOperation` with a `GET` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `HEAD` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes a single arguments: the request operation. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a multipart `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @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. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `PUT` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `PATCH` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `DELETE` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (AFHTTPRequestOperation *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +@end + diff --git a/AFNetworking-master/AFNetworking/AFHTTPRequestOperationManager.m b/AFNetworking-master/AFNetworking/AFHTTPRequestOperationManager.m new file mode 100755 index 0000000..60739e5 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFHTTPRequestOperationManager.m @@ -0,0 +1,284 @@ +// AFHTTPRequestOperationManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import "AFHTTPRequestOperationManager.h" +#import "AFHTTPRequestOperation.h" + +#import +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#endif + +@interface AFHTTPRequestOperationManager () +@property (readwrite, nonatomic, strong) NSURL *baseURL; +@end + +@implementation AFHTTPRequestOperationManager + ++ (instancetype)manager { + return [[self alloc] initWithBaseURL:nil]; +} + +- (instancetype)init { + return [self initWithBaseURL:nil]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url { + self = [super init]; + if (!self) { + return nil; + } + + // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected + if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { + url = [url URLByAppendingPathComponent:@""]; + } + + self.baseURL = url; + + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + + self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; + + self.operationQueue = [[NSOperationQueue alloc] init]; + + self.shouldUseCredentialStorage = YES; + + return self; +} + +#pragma mark - + +#ifdef _SYSTEMCONFIGURATION_H +#endif + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + NSParameterAssert(requestSerializer); + + _requestSerializer = requestSerializer; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + _responseSerializer = responseSerializer; +} + +#pragma mark - + +- (AFHTTPRequestOperation *)HTTPRequestOperationWithHTTPMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + return [self HTTPRequestOperationWithRequest:request success:success failure:failure]; +} + +- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + operation.responseSerializer = self.responseSerializer; + operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; + operation.credential = self.credential; + operation.securityPolicy = self.securityPolicy; + + [operation setCompletionBlockWithSuccess:success failure:failure]; + operation.completionQueue = self.completionQueue; + operation.completionGroup = self.completionGroup; + + return operation; +} + +#pragma mark - + +- (AFHTTPRequestOperation *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"GET" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters success:^(AFHTTPRequestOperation *requestOperation, __unused id responseObject) { + if (success) { + success(requestOperation); + } + } failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"POST" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.operationQueue]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURL *baseURL = [decoder decodeObjectForKey:NSStringFromSelector(@selector(baseURL))]; + + self = [self initWithBaseURL:baseURL]; + if (!self) { + return nil; + } + + self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; + [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPRequestOperationManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL]; + + HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; + HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; + + return HTTPClient; +} + +@end diff --git a/AFNetworking-master/AFNetworking/AFHTTPSessionManager.h b/AFNetworking-master/AFNetworking/AFHTTPSessionManager.h new file mode 100755 index 0000000..cc98bab --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1,247 @@ +// AFHTTPSessionManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import +#import + +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#import +#else +#import +#endif + +#import "AFURLSessionManager.h" + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +/** + `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. + + ## Subclassing Notes + + 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. + + For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect. + + ## Methods to Override + + To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:completionHandler:`. + + ## Serialization + + Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``. + + Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `` + + ## URL Construction Using Relative Paths + + 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:`. + + Below are a few examples of how `baseURL` and relative paths interact: + + NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; + [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz + [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo + [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ + [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ + + 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. + + @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. + */ + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) + +@interface AFHTTPSessionManager : AFURLSessionManager + +/** + The URL used to monitor reachability, and construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. + */ +@property (readonly, nonatomic, strong) NSURL *baseURL; + +/** + 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. + + @warning `requestSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; + +/** + 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`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns an `AFHTTPSessionManager` object. + */ ++ (instancetype)manager; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + @param url The base URL for the HTTP client. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(NSURL *)url; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + This is the designated initializer. + + @param url The base URL for the HTTP client. + @param configuration The configuration used to create the managed session. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(NSURL *)url + sessionConfiguration:(NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; + +///--------------------------- +/// @name Making HTTP Requests +///--------------------------- + +/** + Creates and runs an `NSURLSessionDataTask` with a `GET` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @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. + @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. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `HEAD` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @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. + @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. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @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. + @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. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @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. + @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. + @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. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PUT` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @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. + @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. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PATCH` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @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. + @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. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `DELETE` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @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. + @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. + + @see -dataTaskWithRequest:completionHandler: + */ +- (NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +@end + +#endif diff --git a/AFNetworking-master/AFNetworking/AFHTTPSessionManager.m b/AFNetworking-master/AFNetworking/AFHTTPSessionManager.m new file mode 100755 index 0000000..2b8352e --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFHTTPSessionManager.m @@ -0,0 +1,321 @@ +// AFHTTPSessionManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFHTTPSessionManager.h" + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) + +#import "AFURLRequestSerialization.h" +#import "AFURLResponseSerialization.h" + +#import +#import + +#ifdef _SYSTEMCONFIGURATION_H +#import +#import +#import +#import +#import +#endif + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#endif + +@interface AFHTTPSessionManager () +@property (readwrite, nonatomic, strong) NSURL *baseURL; +@end + +@implementation AFHTTPSessionManager +@dynamic responseSerializer; + ++ (instancetype)manager { + return [[[self class] alloc] initWithBaseURL:nil]; +} + +- (instancetype)init { + return [self initWithBaseURL:nil]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url { + return [self initWithBaseURL:url sessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + return [self initWithBaseURL:nil sessionConfiguration:configuration]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url + sessionConfiguration:(NSURLSessionConfiguration *)configuration +{ + self = [super initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected + if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { + url = [url URLByAppendingPathComponent:@""]; + } + + self.baseURL = url; + + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + return self; +} + +#pragma mark - + +#ifdef _SYSTEMCONFIGURATION_H +#endif + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + NSParameterAssert(requestSerializer); + + _requestSerializer = requestSerializer; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + [super setResponseSerializer:responseSerializer]; +} + +#pragma mark - + +- (NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"GET" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters success:^(NSURLSessionDataTask *task, __unused id responseObject) { + if (success) { + success(task); + } + } failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + __block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:nil completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(task, error); + } + } else { + if (success) { + success(task, responseObject); + } + } + }]; + + [task resume]; + + return task; +} + +- (NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *, id))success + failure:(void (^)(NSURLSessionDataTask *, NSError *))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + __block NSURLSessionDataTask *dataTask = nil; + dataTask = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(dataTask, error); + } + } else { + if (success) { + success(dataTask, responseObject); + } + } + }]; + + return dataTask; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))]; + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + if (!configuration) { + NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"]; + if (configurationIdentifier) { +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1100) + configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier]; +#else + configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:configurationIdentifier]; +#endif + } + } + + self = [self initWithBaseURL:baseURL sessionConfiguration:configuration]; + if (!self) { + return nil; + } + + self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; + if ([self.session.configuration conformsToProtocol:@protocol(NSCoding)]) { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; + } else { + [coder encodeObject:self.session.configuration.identifier forKey:@"identifier"]; + } + [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration]; + + HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; + HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; + + return HTTPClient; +} + +@end + +#endif diff --git a/AFNetworking-master/AFNetworking/AFNetworkReachabilityManager.h b/AFNetworking-master/AFNetworking/AFNetworkReachabilityManager.h new file mode 100755 index 0000000..4ce2a36 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1,200 @@ +// AFNetworkReachabilityManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) { + AFNetworkReachabilityStatusUnknown = -1, + AFNetworkReachabilityStatusNotReachable = 0, + AFNetworkReachabilityStatusReachableViaWWAN = 1, + AFNetworkReachabilityStatusReachableViaWiFi = 2, +}; + +/** + `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. + + 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. + + See Apple's Reachability Sample Code (https://developer.apple.com/library/ios/samplecode/reachability/) + + @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. + */ +@interface AFNetworkReachabilityManager : NSObject + +/** + The current network reachability status. + */ +@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; + +/** + Whether or not the network is currently reachable. + */ +@property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable; + +/** + Whether or not the network is currently reachable via WWAN. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN; + +/** + Whether or not the network is currently reachable via WiFi. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Returns the shared network reachability manager. + */ ++ (instancetype)sharedManager; + +/** + Creates and returns a network reachability manager for the specified domain. + + @param domain The domain used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified domain. + */ ++ (instancetype)managerForDomain:(NSString *)domain; + +/** + Creates and returns a network reachability manager for the socket address. + + @param address The socket address (`sockaddr_in`) used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified socket address. + */ ++ (instancetype)managerForAddress:(const void *)address; + +/** + Initializes an instance of a network reachability manager from the specified reachability object. + + @param reachability The reachability object to monitor. + + @return An initialized network reachability manager, actively monitoring the specified reachability. + */ +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER; + +///-------------------------------------------------- +/// @name Starting & Stopping Reachability Monitoring +///-------------------------------------------------- + +/** + Starts monitoring for changes in network reachability status. + */ +- (void)startMonitoring; + +/** + Stops monitoring for changes in network reachability status. + */ +- (void)stopMonitoring; + +///------------------------------------------------- +/// @name Getting Localized Reachability Description +///------------------------------------------------- + +/** + Returns a localized string representation of the current network reachability status. + */ +- (NSString *)localizedNetworkReachabilityStatusString; + +///--------------------------------------------------- +/// @name Setting Network Reachability Change Callback +///--------------------------------------------------- + +/** + Sets a callback to be executed when the network availability of the `baseURL` host changes. + + @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`. + */ +- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Network Reachability + + The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses. + + enum { + AFNetworkReachabilityStatusUnknown, + AFNetworkReachabilityStatusNotReachable, + AFNetworkReachabilityStatusReachableViaWWAN, + AFNetworkReachabilityStatusReachableViaWiFi, + } + + `AFNetworkReachabilityStatusUnknown` + The `baseURL` host reachability is not known. + + `AFNetworkReachabilityStatusNotReachable` + The `baseURL` host cannot be reached. + + `AFNetworkReachabilityStatusReachableViaWWAN` + The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. + + `AFNetworkReachabilityStatusReachableViaWiFi` + The `baseURL` host can be reached via a Wi-Fi connection. + + ### Keys for Notification UserInfo Dictionary + + Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. + + `AFNetworkingReachabilityNotificationStatusItem` + A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. + The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. + */ + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when network reachability changes. + 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. + + @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 ` to the header prefix of the project (`Prefix.pch`). + */ +extern NSString * const AFNetworkingReachabilityDidChangeNotification; +extern NSString * const AFNetworkingReachabilityNotificationStatusItem; + +///-------------------- +/// @name Functions +///-------------------- + +/** + Returns a localized string representation of an `AFNetworkReachabilityStatus` value. + */ +extern NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status); diff --git a/AFNetworking-master/AFNetworking/AFNetworkReachabilityManager.m b/AFNetworking-master/AFNetworking/AFNetworkReachabilityManager.m new file mode 100755 index 0000000..25e9581 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFNetworkReachabilityManager.m @@ -0,0 +1,259 @@ +// AFNetworkReachabilityManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFNetworkReachabilityManager.h" + +#import +#import +#import +#import +#import + +NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; +NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; + +typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); + +typedef NS_ENUM(NSUInteger, AFNetworkReachabilityAssociation) { + AFNetworkReachabilityForAddress = 1, + AFNetworkReachabilityForAddressPair = 2, + AFNetworkReachabilityForName = 3, +}; + +NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) { + switch (status) { + case AFNetworkReachabilityStatusNotReachable: + return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWWAN: + return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWiFi: + return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil); + case AFNetworkReachabilityStatusUnknown: + default: + return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil); + } +} + +static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { + BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); + BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); + BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); + BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0); + BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction)); + + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; + if (isNetworkReachable == NO) { + status = AFNetworkReachabilityStatusNotReachable; + } +#if TARGET_OS_IPHONE + else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { + status = AFNetworkReachabilityStatusReachableViaWWAN; + } +#endif + else { + status = AFNetworkReachabilityStatusReachableViaWiFi; + } + + return status; +} + +static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); + AFNetworkReachabilityStatusBlock block = (__bridge AFNetworkReachabilityStatusBlock)info; + if (block) { + block(status); + } + + + dispatch_async(dispatch_get_main_queue(), ^{ + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) }; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo]; + }); + +} + +static const void * AFNetworkReachabilityRetainCallback(const void *info) { + return Block_copy(info); +} + +static void AFNetworkReachabilityReleaseCallback(const void *info) { + if (info) { + Block_release(info); + } +} + +@interface AFNetworkReachabilityManager () +@property (readwrite, nonatomic, assign) SCNetworkReachabilityRef networkReachability; +@property (readwrite, nonatomic, assign) AFNetworkReachabilityAssociation networkReachabilityAssociation; +@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; +@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; +@end + +@implementation AFNetworkReachabilityManager + ++ (instancetype)sharedManager { + static AFNetworkReachabilityManager *_sharedManager = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + struct sockaddr_in address; + bzero(&address, sizeof(address)); + address.sin_len = sizeof(address); + address.sin_family = AF_INET; + + _sharedManager = [self managerForAddress:&address]; + }); + + return _sharedManager; +} + ++ (instancetype)managerForDomain:(NSString *)domain { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]); + + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + manager.networkReachabilityAssociation = AFNetworkReachabilityForName; + + return manager; +} + ++ (instancetype)managerForAddress:(const void *)address { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address); + + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + manager.networkReachabilityAssociation = AFNetworkReachabilityForAddress; + + return manager; +} + +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability { + self = [super init]; + if (!self) { + return nil; + } + + self.networkReachability = reachability; + self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; + + return self; +} + +- (void)dealloc { + [self stopMonitoring]; + + if (_networkReachability) { + CFRelease(_networkReachability); + _networkReachability = NULL; + } +} + +#pragma mark - + +- (BOOL)isReachable { + return [self isReachableViaWWAN] || [self isReachableViaWiFi]; +} + +- (BOOL)isReachableViaWWAN { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN; +} + +- (BOOL)isReachableViaWiFi { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi; +} + +#pragma mark - + +- (void)startMonitoring { + [self stopMonitoring]; + + if (!self.networkReachability) { + return; + } + + __weak __typeof(self)weakSelf = self; + AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + + strongSelf.networkReachabilityStatus = status; + if (strongSelf.networkReachabilityStatusBlock) { + strongSelf.networkReachabilityStatusBlock(status); + } + + }; + + SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; + SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); + SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); + + switch (self.networkReachabilityAssociation) { + case AFNetworkReachabilityForName: + break; + case AFNetworkReachabilityForAddress: + case AFNetworkReachabilityForAddressPair: + default: { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ + SCNetworkReachabilityFlags flags; + SCNetworkReachabilityGetFlags(self.networkReachability, &flags); + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); + dispatch_async(dispatch_get_main_queue(), ^{ + callback(status); + + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:@{ AFNetworkingReachabilityNotificationStatusItem: @(status) }]; + + + }); + }); + } + break; + } +} + +- (void)stopMonitoring { + if (!self.networkReachability) { + return; + } + + SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); +} + +#pragma mark - + +- (NSString *)localizedNetworkReachabilityStatusString { + return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus); +} + +#pragma mark - + +- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { + self.networkReachabilityStatusBlock = block; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { + if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) { + return [NSSet setWithObject:@"networkReachabilityStatus"]; + } + + return [super keyPathsForValuesAffectingValueForKey:key]; +} + +@end diff --git a/AFNetworking-master/AFNetworking/AFNetworking.h b/AFNetworking-master/AFNetworking/AFNetworking.h new file mode 100755 index 0000000..68273da --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFNetworking.h @@ -0,0 +1,44 @@ +// AFNetworking.h +// +// Copyright (c) 2013 AFNetworking (http://afnetworking.com/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +#ifndef _AFNETWORKING_ + #define _AFNETWORKING_ + + #import "AFURLRequestSerialization.h" + #import "AFURLResponseSerialization.h" + #import "AFSecurityPolicy.h" + #import "AFNetworkReachabilityManager.h" + + #import "AFURLConnectionOperation.h" + #import "AFHTTPRequestOperation.h" + #import "AFHTTPRequestOperationManager.h" + +#if ( ( defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || \ + ( defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 ) ) + #import "AFURLSessionManager.h" + #import "AFHTTPSessionManager.h" +#endif + +#endif /* _AFNETWORKING_ */ diff --git a/AFNetworking-master/AFNetworking/AFSecurityPolicy.h b/AFNetworking-master/AFNetworking/AFSecurityPolicy.h new file mode 100755 index 0000000..c6cec83 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1,142 @@ +// AFSecurityPolicy.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, +}; + +/** + `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. + + 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. + */ +@interface AFSecurityPolicy : NSObject + +/** + The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. + */ +@property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; + +/** + Whether to evaluate an entire SSL certificate chain, or just the leaf certificate. Defaults to `YES`. + */ +@property (nonatomic, assign) BOOL validatesCertificateChain; + +/** + The certificates used to evaluate server trust according to the SSL pinning mode. By default, this property is set to any (`.cer`) certificates included in the app bundle. + */ +@property (nonatomic, strong) NSArray *pinnedCertificates; + +/** + Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL allowInvalidCertificates; + +/** + Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`. + */ +@property (nonatomic, assign) BOOL validatesDomainName; + +///----------------------------------------- +/// @name Getting Specific Security Policies +///----------------------------------------- + +/** + 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. + + @return The default security policy. + */ ++ (instancetype)defaultPolicy; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a security policy with the specified pinning mode. + + @param pinningMode The SSL pinning mode. + + @return A new security policy. + */ ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; + +///------------------------------ +/// @name Evaluating Server Trust +///------------------------------ + +/** + Whether or not the specified server trust should be accepted, based on the security policy. + + This method should be used when responding to an authentication challenge from a server. + + @param serverTrust The X.509 certificate trust of the server. + + @return Whether or not to trust the server. + + @warning This method has been deprecated in favor of `-evaluateServerTrust:forDomain:`. + */ +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust DEPRECATED_ATTRIBUTE; + +/** + Whether or not the specified server trust should be accepted, based on the security policy. + + This method should be used when responding to an authentication challenge from a server. + + @param serverTrust The X.509 certificate trust of the server. + @param domain The domain of serverTrust. If `nil`, the domain will not be validated. + + @return Whether or not to trust the server. + */ +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(NSString *)domain; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## SSL Pinning Modes + + The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. + + enum { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, + } + + `AFSSLPinningModeNone` + Do not used pinned certificates to validate servers. + + `AFSSLPinningModePublicKey` + Validate host certificates against public keys of pinned certificates. + + `AFSSLPinningModeCertificate` + Validate host certificates against pinned certificates. +*/ diff --git a/AFNetworking-master/AFNetworking/AFSecurityPolicy.m b/AFNetworking-master/AFNetworking/AFSecurityPolicy.m new file mode 100755 index 0000000..2bbff62 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFSecurityPolicy.m @@ -0,0 +1,308 @@ +// AFSecurityPolicy.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFSecurityPolicy.h" + +#import + +#if !defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +static NSData * AFSecKeyGetData(SecKeyRef key) { + CFDataRef data = NULL; + + __Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out); + + return (__bridge_transfer NSData *)data; + +_out: + if (data) { + CFRelease(data); + } + + return nil; +} +#endif + +static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + return [(__bridge id)key1 isEqual:(__bridge id)key2]; +#else + return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)]; +#endif +} + +static id AFPublicKeyForCertificate(NSData *certificate) { + id allowedPublicKey = nil; + SecCertificateRef allowedCertificate; + SecCertificateRef allowedCertificates[1]; + CFArrayRef tempCertificates = nil; + SecPolicyRef policy = nil; + SecTrustRef allowedTrust = nil; + SecTrustResultType result; + + allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate); + __Require_Quiet(allowedCertificate != NULL, _out); + + allowedCertificates[0] = allowedCertificate; + tempCertificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL); + + policy = SecPolicyCreateBasicX509(); + __Require_noErr_Quiet(SecTrustCreateWithCertificates(tempCertificates, policy, &allowedTrust), _out); + __Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out); + + allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust); + +_out: + if (allowedTrust) { + CFRelease(allowedTrust); + } + + if (policy) { + CFRelease(policy); + } + + if (tempCertificates) { + CFRelease(tempCertificates); + } + + if (allowedCertificate) { + CFRelease(allowedCertificate); + } + + return allowedPublicKey; +} + +static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { + BOOL isValid = NO; + SecTrustResultType result; + __Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out); + + isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed); + +_out: + return isValid; +} + +static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; + } + + return [NSArray arrayWithArray:trustChain]; +} + +static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) { + SecPolicyRef policy = SecPolicyCreateBasicX509(); + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + + SecCertificateRef someCertificates[] = {certificate}; + CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL); + + SecTrustRef trust; + __Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out); + + SecTrustResultType result; + __Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out); + + [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; + + _out: + if (trust) { + CFRelease(trust); + } + + if (certificates) { + CFRelease(certificates); + } + + continue; + } + CFRelease(policy); + + return [NSArray arrayWithArray:trustChain]; +} + +#pragma mark - + +@interface AFSecurityPolicy() +@property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode; +@property (readwrite, nonatomic, strong) NSArray *pinnedPublicKeys; +@end + +@implementation AFSecurityPolicy + ++ (NSArray *)defaultPinnedCertificates { + static NSArray *_defaultPinnedCertificates = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; + + NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]]; + for (NSString *path in paths) { + NSData *certificateData = [NSData dataWithContentsOfFile:path]; + [certificates addObject:certificateData]; + } + + _defaultPinnedCertificates = [[NSArray alloc] initWithArray:certificates]; + }); + + return _defaultPinnedCertificates; +} + ++ (instancetype)defaultPolicy { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = AFSSLPinningModeNone; + + return securityPolicy; +} + ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = pinningMode; + + [securityPolicy setPinnedCertificates:[self defaultPinnedCertificates]]; + + return securityPolicy; +} + +- (id)init { + self = [super init]; + if (!self) { + return nil; + } + + self.validatesCertificateChain = YES; + self.validatesDomainName = YES; + + return self; +} + +- (void)setPinnedCertificates:(NSArray *)pinnedCertificates { + _pinnedCertificates = pinnedCertificates; + + if (self.pinnedCertificates) { + NSMutableArray *mutablePinnedPublicKeys = [NSMutableArray arrayWithCapacity:[self.pinnedCertificates count]]; + for (NSData *certificate in self.pinnedCertificates) { + id publicKey = AFPublicKeyForCertificate(certificate); + if (!publicKey) { + continue; + } + [mutablePinnedPublicKeys addObject:publicKey]; + } + self.pinnedPublicKeys = [NSArray arrayWithArray:mutablePinnedPublicKeys]; + } else { + self.pinnedPublicKeys = nil; + } +} + +#pragma mark - + +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust { + return [self evaluateServerTrust:serverTrust forDomain:nil]; +} + +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(NSString *)domain +{ + NSMutableArray *policies = [NSMutableArray array]; + if (self.validatesDomainName) { + [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)]; + } else { + [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()]; + } + + SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies); + + if (self.SSLPinningMode == AFSSLPinningModeNone) { + if (self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust)){ + return YES; + } else { + return NO; + } + } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) { + return NO; + } + + NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust); + switch (self.SSLPinningMode) { + case AFSSLPinningModeNone: + default: + return NO; + case AFSSLPinningModeCertificate: { + NSMutableArray *pinnedCertificates = [NSMutableArray array]; + for (NSData *certificateData in self.pinnedCertificates) { + [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)]; + } + SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); + + if (!AFServerTrustIsValid(serverTrust)) { + return NO; + } + + if (!self.validatesCertificateChain) { + return YES; + } + + NSUInteger trustedCertificateCount = 0; + for (NSData *trustChainCertificate in serverCertificates) { + if ([self.pinnedCertificates containsObject:trustChainCertificate]) { + trustedCertificateCount++; + } + } + + return trustedCertificateCount == [serverCertificates count]; + } + case AFSSLPinningModePublicKey: { + NSUInteger trustedPublicKeyCount = 0; + NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust); + if (!self.validatesCertificateChain && [publicKeys count] > 0) { + publicKeys = @[[publicKeys firstObject]]; + } + + for (id trustChainPublicKey in publicKeys) { + for (id pinnedPublicKey in self.pinnedPublicKeys) { + if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) { + trustedPublicKeyCount += 1; + } + } + } + + return trustedPublicKeyCount > 0 && ((self.validatesCertificateChain && trustedPublicKeyCount == [serverCertificates count]) || (!self.validatesCertificateChain && trustedPublicKeyCount >= 1)); + } + } + + return NO; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys { + return [NSSet setWithObject:@"pinnedCertificates"]; +} + +@end diff --git a/AFNetworking-master/AFNetworking/AFURLConnectionOperation.h b/AFNetworking-master/AFNetworking/AFURLConnectionOperation.h new file mode 100755 index 0000000..0248e67 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFURLConnectionOperation.h @@ -0,0 +1,343 @@ +// AFURLConnectionOperation.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import +#import "AFURLRequestSerialization.h" +#import "AFURLResponseSerialization.h" +#import "AFSecurityPolicy.h" + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +/** + `AFURLConnectionOperation` is a subclass of `NSOperation` that implements `NSURLConnection` delegate methods. + + ## Subclassing Notes + + This is the base class of all network request operations. You may wish to create your own subclass in order to implement additional `NSURLConnection` delegate methods (see "`NSURLConnection` Delegate Methods" below), or to provide additional properties and/or class constructors. + + If you are creating a subclass that communicates over the HTTP or HTTPS protocols, you may want to consider subclassing `AFHTTPRequestOperation` instead, as it supports specifying acceptable content types or status codes. + + ## NSURLConnection Delegate Methods + + `AFURLConnectionOperation` implements the following `NSURLConnection` delegate methods: + + - `connection:didReceiveResponse:` + - `connection:didReceiveData:` + - `connectionDidFinishLoading:` + - `connection:didFailWithError:` + - `connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:` + - `connection:willCacheResponse:` + - `connectionShouldUseCredentialStorage:` + - `connection:needNewBodyStream:` + - `connection:willSendRequestForAuthenticationChallenge:` + + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. + + ## Callbacks and Completion Blocks + + The built-in `completionBlock` provided by `NSOperation` allows for custom behavior to be executed after the request finishes. It is a common pattern for class constructors in subclasses to take callback block parameters, and execute them conditionally in the body of its `completionBlock`. Make sure to handle cancelled operations appropriately when setting a `completionBlock` (i.e. returning early before parsing response data). See the implementation of any of the `AFHTTPRequestOperation` subclasses for an example of this. + + Subclasses are strongly discouraged from overriding `setCompletionBlock:`, as `AFURLConnectionOperation`'s implementation includes a workaround to mitigate retain cycles, and what Apple rather ominously refers to as ["The Deallocation Problem"](http://developer.apple.com/library/ios/#technotes/tn2109/). + + ## SSL Pinning + + Relying on the CA trust model to validate SSL certificates exposes your app to security vulnerabilities, such as man-in-the-middle attacks. For applications that connect to known servers, SSL certificate pinning provides an increased level of security, by checking server certificate validity against those specified in the app bundle. + + SSL with certificate pinning is strongly recommended for any application that transmits sensitive information to an external webservice. + + Connections will be validated on all matching certificates with a `.cer` extension in the bundle root. + + ## App Extensions + + When using AFNetworking in an App Extension, `#define AF_APP_EXTENSIONS` to avoid using unavailable APIs. + + ## NSCoding & NSCopying Conformance + + `AFURLConnectionOperation` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. However, because of the intrinsic limitations of capturing the exact state of an operation at a particular moment, there are some important caveats to keep in mind: + + ### NSCoding Caveats + + - Encoded operations do not include any block or stream properties. Be sure to set `completionBlock`, `outputStream`, and any callback blocks as necessary when using `-initWithCoder:` or `NSKeyedUnarchiver`. + - Operations are paused on `encodeWithCoder:`. If the operation was encoded while paused or still executing, its archived state will return `YES` for `isReady`. Otherwise, the state of an operation when encoding will remain unchanged. + + ### NSCopying Caveats + + - `-copy` and `-copyWithZone:` return a new operation with the `NSURLRequest` of the original. So rather than an exact copy of the operation at that particular instant, the copying mechanism returns a completely new instance, which can be useful for retrying operations. + - A copy of an operation will not include the `outputStream` of the original. + - Operation copies do not include `completionBlock`, as it often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ operation when copied. + */ + +@interface AFURLConnectionOperation : NSOperation + +///------------------------------- +/// @name Accessing Run Loop Modes +///------------------------------- + +/** + The run loop modes in which the operation will run on the network thread. By default, this is a single-member set containing `NSRunLoopCommonModes`. + */ +@property (nonatomic, strong) NSSet *runLoopModes; + +///----------------------------------------- +/// @name Getting URL Connection Information +///----------------------------------------- + +/** + The request used by the operation's connection. + */ +@property (readonly, nonatomic, strong) NSURLRequest *request; + +/** + The last response received by the operation's connection. + */ +@property (readonly, nonatomic, strong) NSURLResponse *response; + +/** + The error, if any, that occurred in the lifecycle of the request. + */ +@property (readonly, nonatomic, strong) NSError *error; + +///---------------------------- +/// @name Getting Response Data +///---------------------------- + +/** + The data received during the request. + */ +@property (readonly, nonatomic, strong) NSData *responseData; + +/** + The string representation of the response data. + */ +@property (readonly, nonatomic, copy) NSString *responseString; + +/** + The string encoding of the response. + + If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`. + */ +@property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; + +///------------------------------- +/// @name Managing URL Credentials +///------------------------------- + +/** + Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. + + This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. + */ +@property (nonatomic, assign) BOOL shouldUseCredentialStorage; + +/** + The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. + + This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. + */ +@property (nonatomic, strong) NSURLCredential *credential; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used to evaluate server trust for secure connections. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +///------------------------ +/// @name Accessing Streams +///------------------------ + +/** + The input stream used to read data to be sent during the request. + + This property acts as a proxy to the `HTTPBodyStream` property of `request`. + */ +@property (nonatomic, strong) NSInputStream *inputStream; + +/** + The output stream that is used to write data received until the request is finished. + + By default, data is accumulated into a buffer that is stored into `responseData` upon completion of the request, with the intermediary `outputStream` property set to `nil`. When `outputStream` is set, the data will not be accumulated into an internal buffer, and as a result, the `responseData` property of the completed request will be `nil`. The output stream will be scheduled in the network thread runloop upon being set. + */ +@property (nonatomic, strong) NSOutputStream *outputStream; + +///--------------------------------- +/// @name Managing Callback Queues +///--------------------------------- + +/** + The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used. + */ +#if OS_OBJECT_HAVE_OBJC_SUPPORT +@property (nonatomic, strong) dispatch_queue_t completionQueue; +#else +@property (nonatomic, assign) dispatch_queue_t completionQueue; +#endif + +/** + The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used. + */ +#if OS_OBJECT_HAVE_OBJC_SUPPORT +@property (nonatomic, strong) dispatch_group_t completionGroup; +#else +@property (nonatomic, assign) dispatch_group_t completionGroup; +#endif + +///--------------------------------------------- +/// @name Managing Request Operation Information +///--------------------------------------------- + +/** + The user info dictionary for the receiver. + */ +@property (nonatomic, strong) NSDictionary *userInfo; + +///------------------------------------------------------ +/// @name Initializing an AFURLConnectionOperation Object +///------------------------------------------------------ + +/** + Initializes and returns a newly allocated operation object with a url connection configured with the specified url request. + + This is the designated initializer. + + @param urlRequest The request object to be used by the operation connection. + */ +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest NS_DESIGNATED_INITIALIZER; + +///---------------------------------- +/// @name Pausing / Resuming Requests +///---------------------------------- + +/** + Pauses the execution of the request operation. + + A paused operation returns `NO` for `-isReady`, `-isExecuting`, and `-isFinished`. As such, it will remain in an `NSOperationQueue` until it is either cancelled or resumed. Pausing a finished, cancelled, or paused operation has no effect. + */ +- (void)pause; + +/** + Whether the request operation is currently paused. + + @return `YES` if the operation is currently paused, otherwise `NO`. + */ +- (BOOL)isPaused; + +/** + Resumes the execution of the paused request operation. + + Pause/Resume behavior varies depending on the underlying implementation for the operation class. In its base implementation, resuming a paused requests restarts the original request. However, since HTTP defines a specification for how to request a specific content range, `AFHTTPRequestOperation` will resume downloading the request from where it left off, instead of restarting the original request. + */ +- (void)resume; + +///---------------------------------------------- +/// @name Configuring Backgrounding Task Behavior +///---------------------------------------------- + +/** + Specifies that the operation should continue execution after the app has entered the background, and the expiration handler for that background task. + + @param handler A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified. + */ +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) +- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler; +#endif + +///--------------------------------- +/// @name Setting Progress Callbacks +///--------------------------------- + +/** + Sets a callback to be called when an undetermined number of bytes have been uploaded to the server. + + @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 three arguments: 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. + */ +- (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block; + +/** + Sets a callback to be called when an undetermined number of bytes have been downloaded from the server. + + @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 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 main thread. + */ +- (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block; + +///------------------------------------------------- +/// @name Setting NSURLConnection Delegate Callbacks +///------------------------------------------------- + +/** + Sets a block to be executed when the connection will authenticate a challenge in order to download its request, as handled by the `NSURLConnectionDelegate` method `connection:willSendRequestForAuthenticationChallenge:`. + + @param block A block object to be executed when the connection will authenticate a challenge in order to download its request. The block has no return type and takes two arguments: the URL connection object, and the challenge that must be authenticated. This block must invoke one of the challenge-responder methods (NSURLAuthenticationChallengeSender protocol). + + If `allowsInvalidSSLCertificate` is set to YES, `connection:willSendRequestForAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. + */ +- (void)setWillSendRequestForAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block; + +/** + Sets a block to be executed when the server redirects the request from one URL to another URL, or when the request URL changed by the `NSURLProtocol` subclass handling the request in order to standardize its format, as handled by the `NSURLConnectionDataDelegate` method `connection:willSendRequest:redirectResponse:`. + + @param block A block object to be executed when the request URL was changed. The block returns an `NSURLRequest` object, the URL request to redirect, and takes three arguments: the URL connection object, the the proposed redirected request, and the URL response that caused the redirect. + */ +- (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block; + + +/** + Sets a block to be executed to modify the response a connection will cache, if any, as handled by the `NSURLConnectionDelegate` method `connection:willCacheResponse:`. + + @param block A block object to be executed to determine what response a connection will cache, if any. The block returns an `NSCachedURLResponse` object, the cached response to store in memory or `nil` to prevent the response from being cached, and takes two arguments: the URL connection object, and the cached response provided for the request. + */ +- (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block; + +/// + +/** + + */ ++ (NSArray *)batchOfRequestOperations:(NSArray *)operations + progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock + completionBlock:(void (^)(NSArray *operations))completionBlock; + +@end + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when an operation begins executing. + */ +extern NSString * const AFNetworkingOperationDidStartNotification; + +/** + Posted when an operation finishes. + */ +extern NSString * const AFNetworkingOperationDidFinishNotification; diff --git a/AFNetworking-master/AFNetworking/AFURLConnectionOperation.m b/AFNetworking-master/AFNetworking/AFURLConnectionOperation.m new file mode 100755 index 0000000..8d32092 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFURLConnectionOperation.m @@ -0,0 +1,788 @@ +// AFURLConnectionOperation.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLConnectionOperation.h" + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#endif + +#if !__has_feature(objc_arc) +#error AFNetworking must be built with ARC. +// You can turn on ARC for only AFNetworking files by adding -fobjc-arc to the build phase for each of its files. +#endif + +typedef NS_ENUM(NSInteger, AFOperationState) { + AFOperationPausedState = -1, + AFOperationReadyState = 1, + AFOperationExecutingState = 2, + AFOperationFinishedState = 3, +}; + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) +typedef UIBackgroundTaskIdentifier AFBackgroundTaskIdentifier; +#else +typedef id AFBackgroundTaskIdentifier; +#endif + +static dispatch_group_t url_request_operation_completion_group() { + static dispatch_group_t af_url_request_operation_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_request_operation_completion_group = dispatch_group_create(); + }); + + return af_url_request_operation_completion_group; +} + +static dispatch_queue_t url_request_operation_completion_queue() { + static dispatch_queue_t af_url_request_operation_completion_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_request_operation_completion_queue = dispatch_queue_create("com.alamofire.networking.operation.queue", DISPATCH_QUEUE_CONCURRENT ); + }); + + return af_url_request_operation_completion_queue; +} + +static NSString * const kAFNetworkingLockName = @"com.alamofire.networking.operation.lock"; + +NSString * const AFNetworkingOperationDidStartNotification = @"com.alamofire.networking.operation.start"; +NSString * const AFNetworkingOperationDidFinishNotification = @"com.alamofire.networking.operation.finish"; + +typedef void (^AFURLConnectionOperationProgressBlock)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); +typedef void (^AFURLConnectionOperationAuthenticationChallengeBlock)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge); +typedef NSCachedURLResponse * (^AFURLConnectionOperationCacheResponseBlock)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse); +typedef NSURLRequest * (^AFURLConnectionOperationRedirectResponseBlock)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse); + +static inline NSString * AFKeyPathFromOperationState(AFOperationState state) { + switch (state) { + case AFOperationReadyState: + return @"isReady"; + case AFOperationExecutingState: + return @"isExecuting"; + case AFOperationFinishedState: + return @"isFinished"; + case AFOperationPausedState: + return @"isPaused"; + default: { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" + return @"state"; +#pragma clang diagnostic pop + } + } +} + +static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperationState toState, BOOL isCancelled) { + switch (fromState) { + case AFOperationReadyState: + switch (toState) { + case AFOperationPausedState: + case AFOperationExecutingState: + return YES; + case AFOperationFinishedState: + return isCancelled; + default: + return NO; + } + case AFOperationExecutingState: + switch (toState) { + case AFOperationPausedState: + case AFOperationFinishedState: + return YES; + default: + return NO; + } + case AFOperationFinishedState: + return NO; + case AFOperationPausedState: + return toState == AFOperationReadyState; + default: { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" + switch (toState) { + case AFOperationPausedState: + case AFOperationReadyState: + case AFOperationExecutingState: + case AFOperationFinishedState: + return YES; + default: + return NO; + } + } +#pragma clang diagnostic pop + } +} + +@interface AFURLConnectionOperation () +@property (readwrite, nonatomic, assign) AFOperationState state; +@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; +@property (readwrite, nonatomic, strong) NSURLConnection *connection; +@property (readwrite, nonatomic, strong) NSURLRequest *request; +@property (readwrite, nonatomic, strong) NSURLResponse *response; +@property (readwrite, nonatomic, strong) NSError *error; +@property (readwrite, nonatomic, strong) NSData *responseData; +@property (readwrite, nonatomic, copy) NSString *responseString; +@property (readwrite, nonatomic, assign) NSStringEncoding responseStringEncoding; +@property (readwrite, nonatomic, assign) long long totalBytesRead; +@property (readwrite, nonatomic, assign) AFBackgroundTaskIdentifier backgroundTaskIdentifier; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock uploadProgress; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock downloadProgress; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationAuthenticationChallengeBlock authenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationCacheResponseBlock cacheResponse; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationRedirectResponseBlock redirectResponse; + +- (void)operationDidStart; +- (void)finish; +- (void)cancelConnection; +@end + +@implementation AFURLConnectionOperation +@synthesize outputStream = _outputStream; + ++ (void)networkRequestThreadEntryPoint:(id)__unused object { + @autoreleasepool { + [[NSThread currentThread] setName:@"AFNetworking"]; + + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + [runLoop addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode]; + [runLoop run]; + } +} + ++ (NSThread *)networkRequestThread { + static NSThread *_networkRequestThread = nil; + static dispatch_once_t oncePredicate; + dispatch_once(&oncePredicate, ^{ + _networkRequestThread = [[NSThread alloc] initWithTarget:self selector:@selector(networkRequestThreadEntryPoint:) object:nil]; + [_networkRequestThread start]; + }); + + return _networkRequestThread; +} + +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest { + NSParameterAssert(urlRequest); + + self = [super init]; + if (!self) { + return nil; + } + + _state = AFOperationReadyState; + + self.lock = [[NSRecursiveLock alloc] init]; + self.lock.name = kAFNetworkingLockName; + + self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes]; + + self.request = urlRequest; + + self.shouldUseCredentialStorage = YES; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + + return self; +} + +- (void)dealloc { + if (_outputStream) { + [_outputStream close]; + _outputStream = nil; + } + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) + if (_backgroundTaskIdentifier) { + [[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier]; + _backgroundTaskIdentifier = UIBackgroundTaskInvalid; + } +#endif +} + +#pragma mark - + +- (void)setResponseData:(NSData *)responseData { + [self.lock lock]; + if (!responseData) { + _responseData = nil; + } else { + _responseData = [NSData dataWithBytes:responseData.bytes length:responseData.length]; + } + [self.lock unlock]; +} + +- (NSString *)responseString { + [self.lock lock]; + if (!_responseString && self.response && self.responseData) { + self.responseString = [[NSString alloc] initWithData:self.responseData encoding:self.responseStringEncoding]; + } + [self.lock unlock]; + + return _responseString; +} + +- (NSStringEncoding)responseStringEncoding { + [self.lock lock]; + if (!_responseStringEncoding && self.response) { + NSStringEncoding stringEncoding = NSUTF8StringEncoding; + if (self.response.textEncodingName) { + CFStringEncoding IANAEncoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)self.response.textEncodingName); + if (IANAEncoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(IANAEncoding); + } + } + + self.responseStringEncoding = stringEncoding; + } + [self.lock unlock]; + + return _responseStringEncoding; +} + +- (NSInputStream *)inputStream { + return self.request.HTTPBodyStream; +} + +- (void)setInputStream:(NSInputStream *)inputStream { + NSMutableURLRequest *mutableRequest = [self.request mutableCopy]; + mutableRequest.HTTPBodyStream = inputStream; + self.request = mutableRequest; +} + +- (NSOutputStream *)outputStream { + if (!_outputStream) { + self.outputStream = [NSOutputStream outputStreamToMemory]; + } + + return _outputStream; +} + +- (void)setOutputStream:(NSOutputStream *)outputStream { + [self.lock lock]; + if (outputStream != _outputStream) { + if (_outputStream) { + [_outputStream close]; + } + + _outputStream = outputStream; + } + [self.lock unlock]; +} + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) +- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler { + [self.lock lock]; + if (!self.backgroundTaskIdentifier) { + UIApplication *application = [UIApplication sharedApplication]; + __weak __typeof(self)weakSelf = self; + self.backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{ + __strong __typeof(weakSelf)strongSelf = weakSelf; + + if (handler) { + handler(); + } + + if (strongSelf) { + [strongSelf cancel]; + + [application endBackgroundTask:strongSelf.backgroundTaskIdentifier]; + strongSelf.backgroundTaskIdentifier = UIBackgroundTaskInvalid; + } + }]; + } + [self.lock unlock]; +} +#endif + +#pragma mark - + +- (void)setState:(AFOperationState)state { + if (!AFStateTransitionIsValid(self.state, state, [self isCancelled])) { + return; + } + + [self.lock lock]; + NSString *oldStateKey = AFKeyPathFromOperationState(self.state); + NSString *newStateKey = AFKeyPathFromOperationState(state); + + [self willChangeValueForKey:newStateKey]; + [self willChangeValueForKey:oldStateKey]; + _state = state; + [self didChangeValueForKey:oldStateKey]; + [self didChangeValueForKey:newStateKey]; + [self.lock unlock]; +} + +- (void)pause { + if ([self isPaused] || [self isFinished] || [self isCancelled]) { + return; + } + + [self.lock lock]; + if ([self isExecuting]) { + [self performSelector:@selector(operationDidPause) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + + dispatch_async(dispatch_get_main_queue(), ^{ + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + }); + } + + self.state = AFOperationPausedState; + [self.lock unlock]; +} + +- (void)operationDidPause { + [self.lock lock]; + [self.connection cancel]; + [self.lock unlock]; +} + +- (BOOL)isPaused { + return self.state == AFOperationPausedState; +} + +- (void)resume { + if (![self isPaused]) { + return; + } + + [self.lock lock]; + self.state = AFOperationReadyState; + + [self start]; + [self.lock unlock]; +} + +#pragma mark - + +- (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block { + self.uploadProgress = block; +} + +- (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block { + self.downloadProgress = block; +} + +- (void)setWillSendRequestForAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block { + self.authenticationChallenge = block; +} + +- (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block { + self.cacheResponse = block; +} + +- (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block { + self.redirectResponse = block; +} + +#pragma mark - NSOperation + +- (void)setCompletionBlock:(void (^)(void))block { + [self.lock lock]; + if (!block) { + [super setCompletionBlock:nil]; + } else { + __weak __typeof(self)weakSelf = self; + [super setCompletionBlock:^ { + __strong __typeof(weakSelf)strongSelf = weakSelf; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_group_t group = strongSelf.completionGroup ?: url_request_operation_completion_group(); + dispatch_queue_t queue = strongSelf.completionQueue ?: dispatch_get_main_queue(); +#pragma clang diagnostic pop + + dispatch_group_async(group, queue, ^{ + block(); + }); + + dispatch_group_notify(group, url_request_operation_completion_queue(), ^{ + [strongSelf setCompletionBlock:nil]; + }); + }]; + } + [self.lock unlock]; +} + +- (BOOL)isReady { + return self.state == AFOperationReadyState && [super isReady]; +} + +- (BOOL)isExecuting { + return self.state == AFOperationExecutingState; +} + +- (BOOL)isFinished { + return self.state == AFOperationFinishedState; +} + +- (BOOL)isConcurrent { + return YES; +} + +- (void)start { + [self.lock lock]; + if ([self isCancelled]) { + [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + } else if ([self isReady]) { + self.state = AFOperationExecutingState; + + [self performSelector:@selector(operationDidStart) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + } + [self.lock unlock]; +} + +- (void)operationDidStart { + [self.lock lock]; + if (![self isCancelled]) { + self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO]; + + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + for (NSString *runLoopMode in self.runLoopModes) { + [self.connection scheduleInRunLoop:runLoop forMode:runLoopMode]; + [self.outputStream scheduleInRunLoop:runLoop forMode:runLoopMode]; + } + + [self.outputStream open]; + [self.connection start]; + } + [self.lock unlock]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; + }); +} + +- (void)finish { + [self.lock lock]; + self.state = AFOperationFinishedState; + [self.lock unlock]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + }); +} + +- (void)cancel { + [self.lock lock]; + if (![self isFinished] && ![self isCancelled]) { + [super cancel]; + + if ([self isExecuting]) { + [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + } + } + [self.lock unlock]; +} + +- (void)cancelConnection { + NSDictionary *userInfo = nil; + if ([self.request URL]) { + userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; + } + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]; + + if (![self isFinished]) { + if (self.connection) { + [self.connection cancel]; + [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:error]; + } else { + // Accomodate race condition where `self.connection` has not yet been set before cancellation + self.error = error; + [self finish]; + } + } +} + +#pragma mark - + ++ (NSArray *)batchOfRequestOperations:(NSArray *)operations + progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock + completionBlock:(void (^)(NSArray *operations))completionBlock +{ + if (!operations || [operations count] == 0) { + return @[[NSBlockOperation blockOperationWithBlock:^{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (completionBlock) { + completionBlock(@[]); + } + }); + }]]; + } + + __block dispatch_group_t group = dispatch_group_create(); + NSBlockOperation *batchedOperation = [NSBlockOperation blockOperationWithBlock:^{ + dispatch_group_notify(group, dispatch_get_main_queue(), ^{ + if (completionBlock) { + completionBlock(operations); + } + }); + }]; + + for (AFURLConnectionOperation *operation in operations) { + operation.completionGroup = group; + void (^originalCompletionBlock)(void) = [operation.completionBlock copy]; + __weak __typeof(operation)weakOperation = operation; + operation.completionBlock = ^{ + __strong __typeof(weakOperation)strongOperation = weakOperation; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_queue_t queue = strongOperation.completionQueue ?: dispatch_get_main_queue(); +#pragma clang diagnostic pop + dispatch_group_async(group, queue, ^{ + if (originalCompletionBlock) { + originalCompletionBlock(); + } + + NSUInteger numberOfFinishedOperations = [[operations indexesOfObjectsPassingTest:^BOOL(id op, NSUInteger __unused idx, BOOL __unused *stop) { + return [op isFinished]; + }] count]; + + if (progressBlock) { + progressBlock(numberOfFinishedOperations, [operations count]); + } + + dispatch_group_leave(group); + }); + }; + + dispatch_group_enter(group); + [batchedOperation addDependency:operation]; + } + + return [operations arrayByAddingObject:batchedOperation]; +} + +#pragma mark - NSObject + +- (NSString *)description { + [self.lock lock]; + NSString *description = [NSString stringWithFormat:@"<%@: %p, state: %@, cancelled: %@ request: %@, response: %@>", NSStringFromClass([self class]), self, AFKeyPathFromOperationState(self.state), ([self isCancelled] ? @"YES" : @"NO"), self.request, self.response]; + [self.lock unlock]; + return description; +} + +#pragma mark - NSURLConnectionDelegate + +- (void)connection:(NSURLConnection *)connection +willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge +{ + if (self.authenticationChallenge) { + self.authenticationChallenge(connection, challenge); + return; + } + + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; + } + } else { + if ([challenge previousFailureCount] == 0) { + if (self.credential) { + [[challenge sender] useCredential:self.credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; + } + } else { + [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; + } + } +} + +- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection { + return self.shouldUseCredentialStorage; +} + +- (NSURLRequest *)connection:(NSURLConnection *)connection + willSendRequest:(NSURLRequest *)request + redirectResponse:(NSURLResponse *)redirectResponse +{ + if (self.redirectResponse) { + return self.redirectResponse(connection, request, redirectResponse); + } else { + return request; + } +} + +- (void)connection:(NSURLConnection __unused *)connection + didSendBodyData:(NSInteger)bytesWritten + totalBytesWritten:(NSInteger)totalBytesWritten +totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite +{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (self.uploadProgress) { + self.uploadProgress((NSUInteger)bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + } + }); +} + +- (void)connection:(NSURLConnection __unused *)connection +didReceiveResponse:(NSURLResponse *)response +{ + self.response = response; +} + +- (void)connection:(NSURLConnection __unused *)connection + didReceiveData:(NSData *)data +{ + NSUInteger length = [data length]; + while (YES) { + NSInteger totalNumberOfBytesWritten = 0; + if ([self.outputStream hasSpaceAvailable]) { + const uint8_t *dataBuffer = (uint8_t *)[data bytes]; + + NSInteger numberOfBytesWritten = 0; + while (totalNumberOfBytesWritten < (NSInteger)length) { + numberOfBytesWritten = [self.outputStream write:&dataBuffer[(NSUInteger)totalNumberOfBytesWritten] maxLength:(length - (NSUInteger)totalNumberOfBytesWritten)]; + if (numberOfBytesWritten == -1) { + break; + } + + totalNumberOfBytesWritten += numberOfBytesWritten; + } + + break; + } + + if (self.outputStream.streamError) { + [self.connection cancel]; + [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.outputStream.streamError]; + return; + } + } + + dispatch_async(dispatch_get_main_queue(), ^{ + self.totalBytesRead += (long long)length; + + if (self.downloadProgress) { + self.downloadProgress(length, self.totalBytesRead, self.response.expectedContentLength); + } + }); +} + +- (void)connectionDidFinishLoading:(NSURLConnection __unused *)connection { + self.responseData = [self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey]; + + [self.outputStream close]; + if (self.responseData) { + self.outputStream = nil; + } + + self.connection = nil; + + [self finish]; +} + +- (void)connection:(NSURLConnection __unused *)connection + didFailWithError:(NSError *)error +{ + self.error = error; + + [self.outputStream close]; + if (self.responseData) { + self.outputStream = nil; + } + + self.connection = nil; + + [self finish]; +} + +- (NSCachedURLResponse *)connection:(NSURLConnection *)connection + willCacheResponse:(NSCachedURLResponse *)cachedResponse +{ + if (self.cacheResponse) { + return self.cacheResponse(connection, cachedResponse); + } else { + if ([self isCancelled]) { + return nil; + } + + return cachedResponse; + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURLRequest *request = [decoder decodeObjectOfClass:[NSURLRequest class] forKey:NSStringFromSelector(@selector(request))]; + + self = [self initWithRequest:request]; + if (!self) { + return nil; + } + + self.state = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(state))] integerValue]; + self.response = [decoder decodeObjectOfClass:[NSHTTPURLResponse class] forKey:NSStringFromSelector(@selector(response))]; + self.error = [decoder decodeObjectOfClass:[NSError class] forKey:NSStringFromSelector(@selector(error))]; + self.responseData = [decoder decodeObjectOfClass:[NSData class] forKey:NSStringFromSelector(@selector(responseData))]; + self.totalBytesRead = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(totalBytesRead))] longLongValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [self pause]; + + [coder encodeObject:self.request forKey:NSStringFromSelector(@selector(request))]; + + switch (self.state) { + case AFOperationExecutingState: + case AFOperationPausedState: + [coder encodeInteger:AFOperationReadyState forKey:NSStringFromSelector(@selector(state))]; + break; + default: + [coder encodeInteger:self.state forKey:NSStringFromSelector(@selector(state))]; + break; + } + + [coder encodeObject:self.response forKey:NSStringFromSelector(@selector(response))]; + [coder encodeObject:self.error forKey:NSStringFromSelector(@selector(error))]; + [coder encodeObject:self.responseData forKey:NSStringFromSelector(@selector(responseData))]; + [coder encodeInt64:self.totalBytesRead forKey:NSStringFromSelector(@selector(totalBytesRead))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFURLConnectionOperation *operation = [(AFURLConnectionOperation *)[[self class] allocWithZone:zone] initWithRequest:self.request]; + + operation.uploadProgress = self.uploadProgress; + operation.downloadProgress = self.downloadProgress; + operation.authenticationChallenge = self.authenticationChallenge; + operation.cacheResponse = self.cacheResponse; + operation.redirectResponse = self.redirectResponse; + operation.completionQueue = self.completionQueue; + operation.completionGroup = self.completionGroup; + + return operation; +} + +@end diff --git a/AFNetworking-master/AFNetworking/AFURLRequestSerialization.h b/AFNetworking-master/AFNetworking/AFURLRequestSerialization.h new file mode 100755 index 0000000..bb8d444 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1,467 @@ +// AFURLRequestSerialization.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#endif + +/** + 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. + + 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`. + */ +@protocol AFURLRequestSerialization + +/** + Returns a request with the specified parameters encoded into a copy of the original request. + + @param request The original request. + @param parameters The parameters to be encoded. + @param error The error that occurred while attempting to encode the request parameters. + + @return A serialized request. + */ +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError * __autoreleasing *)error; + +@end + +#pragma mark - + +/** + + */ +typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) { + AFHTTPRequestQueryStringDefaultStyle = 0, +}; + +@protocol AFMultipartFormData; + +/** + `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. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPRequestSerializer : NSObject + +/** + The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + Whether created requests can use the device’s cellular radio (if present). `YES` by default. + + @see NSMutableURLRequest -setAllowsCellularAccess: + */ +@property (nonatomic, assign) BOOL allowsCellularAccess; + +/** + The cache policy of created requests. `NSURLRequestUseProtocolCachePolicy` by default. + + @see NSMutableURLRequest -setCachePolicy: + */ +@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy; + +/** + Whether created requests should use the default cookie handling. `YES` by default. + + @see NSMutableURLRequest -setHTTPShouldHandleCookies: + */ +@property (nonatomic, assign) BOOL HTTPShouldHandleCookies; + +/** + Whether created requests can continue transmitting data before receiving a response from an earlier transmission. `NO` by default + + @see NSMutableURLRequest -setHTTPShouldUsePipelining: + */ +@property (nonatomic, assign) BOOL HTTPShouldUsePipelining; + +/** + The network service type for created requests. `NSURLNetworkServiceTypeDefault` by default. + + @see NSMutableURLRequest -setNetworkServiceType: + */ +@property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType; + +/** + The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds. + + @see NSMutableURLRequest -setTimeoutInterval: + */ +@property (nonatomic, assign) NSTimeInterval timeoutInterval; + +///--------------------------------------- +/// @name Configuring HTTP Request Headers +///--------------------------------------- + +/** + Default HTTP header field values to be applied to serialized requests. By default, these include the following: + + - `Accept-Language` with the contents of `NSLocale +preferredLanguages` + - `User-Agent` with the contents of various bundle identifiers and OS designations + + @discussion To add or remove default request headers, use `setValue:forHTTPHeaderField:`. + */ +@property (readonly, nonatomic, strong) NSDictionary *HTTPRequestHeaders; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +/** + 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. + + @param field The HTTP header to set a default value for + @param value The value set as default for the specified header, or `nil` + */ +- (void)setValue:(NSString *)value +forHTTPHeaderField:(NSString *)field; + +/** + Returns the value for the HTTP headers set in the request serializer. + + @param field The HTTP header to retrieve the default value for + + @return The value set as default for the specified header, or `nil` + */ +- (NSString *)valueForHTTPHeaderField:(NSString *)field; + +/** + 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. + + @param username The HTTP basic auth username + @param password The HTTP basic auth password + */ +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password; + +/** + @deprecated This method has been deprecated. Use -setValue:forHTTPHeaderField: instead. + */ +- (void)setAuthorizationHeaderFieldWithToken:(NSString *)token DEPRECATED_ATTRIBUTE; + + +/** + Clears any existing value for the "Authorization" HTTP header. + */ +- (void)clearAuthorizationHeader; + +///------------------------------------------------------- +/// @name Configuring Query String Parameter Serialization +///------------------------------------------------------- + +/** + HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default. + */ +@property (nonatomic, strong) NSSet *HTTPMethodsEncodingParametersInURI; + +/** + Set the method of query string serialization according to one of the pre-defined styles. + + @param style The serialization style. + + @see AFHTTPRequestQueryStringSerializationStyle + */ +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style; + +/** + Set the a custom method of query string serialization according to the specified block. + + @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. + */ +- (void)setQueryStringSerializationWithBlock:(NSString * (^)(NSURLRequest *request, id parameters, NSError * __autoreleasing *error))block; + +///------------------------------- +/// @name Creating Request Objects +///------------------------------- + +/** + @deprecated This method has been deprecated. Use -requestWithMethod:URLString:parameters:error: instead. + */ +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters DEPRECATED_ATTRIBUTE; + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string. + + 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. + + @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body. + @param error The error that occured while constructing the request. + + @return An `NSMutableURLRequest` object. + */ +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + error:(NSError * __autoreleasing *)error; + +/** + @deprecated This method has been deprecated. Use -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error: instead. + */ +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block DEPRECATED_ATTRIBUTE; + +/** + 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 + + 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. + + @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded and set in the request HTTP body. + @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. + @param error The error that occured while constructing the request. + + @return An `NSMutableURLRequest` object + */ +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block + error:(NSError * __autoreleasing *)error; + +/** + 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. + + @param request The multipart form request. The `HTTPBodyStream` property of `request` must not be `nil`. + @param fileURL The file URL to write multipart form contents to. + @param handler A handler block to execute. + + @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. + + @see https://github.com/AFNetworking/AFNetworking/issues/1398 + */ +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(void (^)(NSError *error))handler; + +@end + +#pragma mark - + +/** + The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPRequestSerializer -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:`. + */ +@protocol AFMultipartFormData + +/** + 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. + + 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. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended, otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * __autoreleasing *)error; + +/** + 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. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`. + @param mimeType The declared MIME type of the file data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * __autoreleasing *)error; + +/** + 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. + + @param inputStream The input stream to be appended to the form data + @param name The name to be associated with the specified input stream. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`. + @param length The length of the specified input stream in bytes. + @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`. + */ +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType; + +/** + 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. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified data. This parameter must not be `nil`. + @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`. + */ +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType; + +/** + Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + */ + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name; + + +/** + Appends HTTP headers, followed by the encoded data and the multipart form boundary. + + @param headers The HTTP headers to be appended to the form data. + @param body The data to be encoded and appended to the form data. This parameter must not be `nil`. + */ +- (void)appendPartWithHeaders:(NSDictionary *)headers + body:(NSData *)body; + +/** + Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream. + + 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. + + @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 16kb. + @param delay Duration of delay each time a packet is read. By default, no delay is set. + */ +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay; + +@end + +#pragma mark - + +/** + `AFJSONRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`. + */ +@interface AFJSONRequestSerializer : AFHTTPRequestSerializer + +/** + Options for writing the request JSON data from Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONWritingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONWritingOptions writingOptions; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param writingOptions The specified JSON writing options. + */ ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions; + +@end + +#pragma mark - + +/** + `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`. + */ +@interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + @warning The `writeOptions` property is currently unused. + */ +@property (nonatomic, assign) NSPropertyListWriteOptions writeOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param writeOptions The property list write options. + + @warning The `writeOptions` property is currently unused. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions; + +@end + +#pragma mark - + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLRequestSerializationErrorDomain` + + ### Constants + + `AFURLRequestSerializationErrorDomain` + AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +extern NSString * const AFURLRequestSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLRequestErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLRequestErrorKey` + The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`. + */ +extern NSString * const AFNetworkingOperationFailingURLRequestErrorKey; + +/** + ## Throttling Bandwidth for HTTP Request Input Streams + + @see -throttleBandwidthWithPacketSize:delay: + + ### Constants + + `kAFUploadStream3GSuggestedPacketSize` + Maximum packet size, in number of bytes. Equal to 16kb. + + `kAFUploadStream3GSuggestedDelay` + Duration of delay each time a packet is read. Equal to 0.2 seconds. + */ +extern NSUInteger const kAFUploadStream3GSuggestedPacketSize; +extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; diff --git a/AFNetworking-master/AFNetworking/AFURLRequestSerialization.m b/AFNetworking-master/AFNetworking/AFURLRequestSerialization.m new file mode 100755 index 0000000..5b55b5f --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFURLRequestSerialization.m @@ -0,0 +1,1384 @@ +// AFURLRequestSerialization.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLRequestSerialization.h" + +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#import +#else +#import +#endif + +NSString * const AFURLRequestSerializationErrorDomain = @"com.alamofire.error.serialization.request"; +NSString * const AFNetworkingOperationFailingURLRequestErrorKey = @"com.alamofire.serialization.request.error.response"; + +typedef NSString * (^AFQueryStringSerializationBlock)(NSURLRequest *request, id parameters, NSError *__autoreleasing *error); + +static NSString * AFBase64EncodedStringFromString(NSString *string) { + NSData *data = [NSData dataWithBytes:[string UTF8String] length:[string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]]; + NSUInteger length = [data length]; + NSMutableData *mutableData = [NSMutableData dataWithLength:((length + 2) / 3) * 4]; + + uint8_t *input = (uint8_t *)[data bytes]; + uint8_t *output = (uint8_t *)[mutableData mutableBytes]; + + for (NSUInteger i = 0; i < length; i += 3) { + NSUInteger value = 0; + for (NSUInteger j = i; j < (i + 3); j++) { + value <<= 8; + if (j < length) { + value |= (0xFF & input[j]); + } + } + + static uint8_t const kAFBase64EncodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + NSUInteger idx = (i / 3) * 4; + output[idx + 0] = kAFBase64EncodingTable[(value >> 18) & 0x3F]; + output[idx + 1] = kAFBase64EncodingTable[(value >> 12) & 0x3F]; + output[idx + 2] = (i + 1) < length ? kAFBase64EncodingTable[(value >> 6) & 0x3F] : '='; + output[idx + 3] = (i + 2) < length ? kAFBase64EncodingTable[(value >> 0) & 0x3F] : '='; + } + + return [[NSString alloc] initWithData:mutableData encoding:NSASCIIStringEncoding]; +} + +static NSString * const kAFCharactersToBeEscapedInQueryString = @":/?&=;+!@#$()',*"; + +static NSString * AFPercentEscapedQueryStringKeyFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { + static NSString * const kAFCharactersToLeaveUnescapedInQueryStringPairKey = @"[]."; + + return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, (__bridge CFStringRef)kAFCharactersToLeaveUnescapedInQueryStringPairKey, (__bridge CFStringRef)kAFCharactersToBeEscapedInQueryString, CFStringConvertNSStringEncodingToEncoding(encoding)); +} + +static NSString * AFPercentEscapedQueryStringValueFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { + return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, NULL, (__bridge CFStringRef)kAFCharactersToBeEscapedInQueryString, CFStringConvertNSStringEncodingToEncoding(encoding)); +} + +#pragma mark - + +@interface AFQueryStringPair : NSObject +@property (readwrite, nonatomic, strong) id field; +@property (readwrite, nonatomic, strong) id value; + +- (id)initWithField:(id)field value:(id)value; + +- (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding; +@end + +@implementation AFQueryStringPair + +- (id)initWithField:(id)field value:(id)value { + self = [super init]; + if (!self) { + return nil; + } + + self.field = field; + self.value = value; + + return self; +} + +- (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding { + if (!self.value || [self.value isEqual:[NSNull null]]) { + return AFPercentEscapedQueryStringKeyFromStringWithEncoding([self.field description], stringEncoding); + } else { + return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedQueryStringKeyFromStringWithEncoding([self.field description], stringEncoding), AFPercentEscapedQueryStringValueFromStringWithEncoding([self.value description], stringEncoding)]; + } +} + +@end + +#pragma mark - + +extern NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary); +extern NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value); + +static NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding stringEncoding) { + NSMutableArray *mutablePairs = [NSMutableArray array]; + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + [mutablePairs addObject:[pair URLEncodedStringValueWithEncoding:stringEncoding]]; + } + + return [mutablePairs componentsJoinedByString:@"&"]; +} + +NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary) { + return AFQueryStringPairsFromKeyAndValue(nil, dictionary); +} + +NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { + NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; + + NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(compare:)]; + + if ([value isKindOfClass:[NSDictionary class]]) { + NSDictionary *dictionary = value; + // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries + for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + id nestedValue = [dictionary objectForKey:nestedKey]; + if (nestedValue) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; + } + } + } else if ([value isKindOfClass:[NSArray class]]) { + NSArray *array = value; + for (id nestedValue in array) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; + } + } else if ([value isKindOfClass:[NSSet class]]) { + NSSet *set = value; + for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, obj)]; + } + } else { + [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]]; + } + + return mutableQueryStringComponents; +} + +#pragma mark - + +@interface AFStreamingMultipartFormData : NSObject +- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding; + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData; +@end + +#pragma mark - + +static NSArray * AFHTTPRequestSerializerObservedKeyPaths() { + static NSArray *_AFHTTPRequestSerializerObservedKeyPaths = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _AFHTTPRequestSerializerObservedKeyPaths = @[NSStringFromSelector(@selector(allowsCellularAccess)), NSStringFromSelector(@selector(cachePolicy)), NSStringFromSelector(@selector(HTTPShouldHandleCookies)), NSStringFromSelector(@selector(HTTPShouldUsePipelining)), NSStringFromSelector(@selector(networkServiceType)), NSStringFromSelector(@selector(timeoutInterval))]; + }); + + return _AFHTTPRequestSerializerObservedKeyPaths; +} + +static void *AFHTTPRequestSerializerObserverContext = &AFHTTPRequestSerializerObserverContext; + +@interface AFHTTPRequestSerializer () +@property (readwrite, nonatomic, strong) NSMutableSet *mutableObservedChangedKeyPaths; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableHTTPRequestHeaders; +@property (readwrite, nonatomic, assign) AFHTTPRequestQueryStringSerializationStyle queryStringSerializationStyle; +@property (readwrite, nonatomic, copy) AFQueryStringSerializationBlock queryStringSerialization; +@end + +@implementation AFHTTPRequestSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = NSUTF8StringEncoding; + + self.mutableHTTPRequestHeaders = [NSMutableDictionary dictionary]; + + // Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 + NSMutableArray *acceptLanguagesComponents = [NSMutableArray array]; + [[NSLocale preferredLanguages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + float q = 1.0f - (idx * 0.1f); + [acceptLanguagesComponents addObject:[NSString stringWithFormat:@"%@;q=%0.1g", obj, q]]; + *stop = q <= 0.5f; + }]; + [self setValue:[acceptLanguagesComponents componentsJoinedByString:@", "] forHTTPHeaderField:@"Accept-Language"]; + + NSString *userAgent = nil; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]; +#endif +#pragma clang diagnostic pop + if (userAgent) { + if (![userAgent canBeConvertedToEncoding:NSASCIIStringEncoding]) { + NSMutableString *mutableUserAgent = [userAgent mutableCopy]; + if (CFStringTransform((__bridge CFMutableStringRef)(mutableUserAgent), NULL, (__bridge CFStringRef)@"Any-Latin; Latin-ASCII; [:^ASCII:] Remove", false)) { + userAgent = mutableUserAgent; + } + } + [self setValue:userAgent forHTTPHeaderField:@"User-Agent"]; + } + + // HTTP Method Definitions; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html + self.HTTPMethodsEncodingParametersInURI = [NSSet setWithObjects:@"GET", @"HEAD", @"DELETE", nil]; + + self.mutableObservedChangedKeyPaths = [NSMutableSet set]; + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:AFHTTPRequestSerializerObserverContext]; + } + } + + return self; +} + +- (void)dealloc { + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self removeObserver:self forKeyPath:keyPath context:AFHTTPRequestSerializerObserverContext]; + } + } +} + +#pragma mark - + +// Workarounds for crashing behavior using Key-Value Observing with XCTest +// See https://github.com/AFNetworking/AFNetworking/issues/2523 + +- (void)setAllowsCellularAccess:(BOOL)allowsCellularAccess { + [self willChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))]; + _allowsCellularAccess = allowsCellularAccess; + [self didChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))]; +} + +- (void)setCachePolicy:(NSURLRequestCachePolicy)cachePolicy { + [self willChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))]; + _cachePolicy = cachePolicy; + [self didChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))]; +} + +- (void)setHTTPShouldHandleCookies:(BOOL)HTTPShouldHandleCookies { + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))]; + _HTTPShouldHandleCookies = HTTPShouldHandleCookies; + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))]; +} + +- (void)setHTTPShouldUsePipelining:(BOOL)HTTPShouldUsePipelining { + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))]; + _HTTPShouldUsePipelining = HTTPShouldUsePipelining; + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))]; +} + +- (void)setNetworkServiceType:(NSURLRequestNetworkServiceType)networkServiceType { + [self willChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))]; + _networkServiceType = networkServiceType; + [self didChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))]; +} + +- (void)setTimeoutInterval:(NSTimeInterval)timeoutInterval { + [self willChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))]; + _timeoutInterval = timeoutInterval; + [self didChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))]; +} + +#pragma mark - + +- (NSDictionary *)HTTPRequestHeaders { + return [NSDictionary dictionaryWithDictionary:self.mutableHTTPRequestHeaders]; +} + +- (void)setValue:(NSString *)value +forHTTPHeaderField:(NSString *)field +{ + [self.mutableHTTPRequestHeaders setValue:value forKey:field]; +} + +- (NSString *)valueForHTTPHeaderField:(NSString *)field { + return [self.mutableHTTPRequestHeaders valueForKey:field]; +} + +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password +{ + NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", username, password]; + [self setValue:[NSString stringWithFormat:@"Basic %@", AFBase64EncodedStringFromString(basicAuthCredentials)] forHTTPHeaderField:@"Authorization"]; +} + +- (void)setAuthorizationHeaderFieldWithToken:(NSString *)token { + [self setValue:[NSString stringWithFormat:@"Token token=\"%@\"", token] forHTTPHeaderField:@"Authorization"]; +} + +- (void)clearAuthorizationHeader { + [self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"]; +} + +#pragma mark - + +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style { + self.queryStringSerializationStyle = style; + self.queryStringSerialization = nil; +} + +- (void)setQueryStringSerializationWithBlock:(NSString *(^)(NSURLRequest *, id, NSError *__autoreleasing *))block { + self.queryStringSerialization = block; +} + +#pragma mark - + +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters +{ + return [self requestWithMethod:method URLString:URLString parameters:parameters error:nil]; +} + +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(URLString); + + NSURL *url = [NSURL URLWithString:URLString]; + + NSParameterAssert(url); + + NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url]; + mutableRequest.HTTPMethod = method; + + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self.mutableObservedChangedKeyPaths containsObject:keyPath]) { + [mutableRequest setValue:[self valueForKeyPath:keyPath] forKey:keyPath]; + } + } + + mutableRequest = [[self requestBySerializingRequest:mutableRequest withParameters:parameters error:error] mutableCopy]; + + return mutableRequest; +} + +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block +{ + return [self multipartFormRequestWithMethod:method URLString:URLString parameters:parameters constructingBodyWithBlock:block error:nil]; +} + +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]); + + NSMutableURLRequest *mutableRequest = [self requestWithMethod:method URLString:URLString parameters:nil error:error]; + + __block AFStreamingMultipartFormData *formData = [[AFStreamingMultipartFormData alloc] initWithURLRequest:mutableRequest stringEncoding:NSUTF8StringEncoding]; + + if (parameters) { + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + NSData *data = nil; + if ([pair.value isKindOfClass:[NSData class]]) { + data = pair.value; + } else if ([pair.value isEqual:[NSNull null]]) { + data = [NSData data]; + } else { + data = [[pair.value description] dataUsingEncoding:self.stringEncoding]; + } + + if (data) { + [formData appendPartWithFormData:data name:[pair.field description]]; + } + } + } + + if (block) { + block(formData); + } + + return [formData requestByFinalizingMultipartFormData]; +} + +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(void (^)(NSError *error))handler +{ + NSParameterAssert(request.HTTPBodyStream); + NSParameterAssert([fileURL isFileURL]); + + NSInputStream *inputStream = request.HTTPBodyStream; + NSOutputStream *outputStream = [[NSOutputStream alloc] initWithURL:fileURL append:NO]; + __block NSError *error = nil; + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + + [inputStream open]; + [outputStream open]; + + while ([inputStream hasBytesAvailable] && [outputStream hasSpaceAvailable]) { + uint8_t buffer[1024]; + + NSInteger bytesRead = [inputStream read:buffer maxLength:1024]; + if (inputStream.streamError || bytesRead < 0) { + error = inputStream.streamError; + break; + } + + NSInteger bytesWritten = [outputStream write:buffer maxLength:(NSUInteger)bytesRead]; + if (outputStream.streamError || bytesWritten < 0) { + error = outputStream.streamError; + break; + } + + if (bytesRead == 0 && bytesWritten == 0) { + break; + } + } + + [outputStream close]; + [inputStream close]; + + if (handler) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler(error); + }); + } + }); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + mutableRequest.HTTPBodyStream = nil; + + return mutableRequest; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + NSString *query = nil; + if (self.queryStringSerialization) { + NSError *serializationError; + query = self.queryStringSerialization(request, parameters, &serializationError); + + if (serializationError) { + if (error) { + *error = serializationError; + } + + return nil; + } + } else { + switch (self.queryStringSerializationStyle) { + case AFHTTPRequestQueryStringDefaultStyle: + query = AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding); + break; + } + } + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + mutableRequest.URL = [NSURL URLWithString:[[mutableRequest.URL absoluteString] stringByAppendingFormat:mutableRequest.URL.query ? @"&%@" : @"?%@", query]]; + } else { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; + } + [mutableRequest setHTTPBody:[query dataUsingEncoding:self.stringEncoding]]; + } + } + + return mutableRequest; +} + +#pragma mark - NSKeyValueObserving + ++ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key { + if ([AFHTTPRequestSerializerObservedKeyPaths() containsObject:key]) { + return NO; + } + + return [super automaticallyNotifiesObserversForKey:key]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(__unused id)object + change:(NSDictionary *)change + context:(void *)context +{ + if (context == AFHTTPRequestSerializerObserverContext) { + if ([change[NSKeyValueChangeNewKey] isEqual:[NSNull null]]) { + [self.mutableObservedChangedKeyPaths removeObject:keyPath]; + } else { + [self.mutableObservedChangedKeyPaths addObject:keyPath]; + } + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.mutableHTTPRequestHeaders = [[decoder decodeObjectOfClass:[NSDictionary class] forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))] mutableCopy]; + self.queryStringSerializationStyle = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.mutableHTTPRequestHeaders forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))]; + [coder encodeInteger:self.queryStringSerializationStyle forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPRequestSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.mutableHTTPRequestHeaders = [self.mutableHTTPRequestHeaders mutableCopyWithZone:zone]; + serializer.queryStringSerializationStyle = self.queryStringSerializationStyle; + serializer.queryStringSerialization = self.queryStringSerialization; + + return serializer; +} + +@end + +#pragma mark - + +static NSString * AFCreateMultipartFormBoundary() { + return [NSString stringWithFormat:@"Boundary+%08X%08X", arc4random(), arc4random()]; +} + +static NSString * const kAFMultipartFormCRLF = @"\r\n"; + +static inline NSString * AFMultipartFormInitialBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"--%@%@", boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormEncapsulationBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormFinalBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@--%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFContentTypeForPathExtension(NSString *extension) { +#ifdef __UTTYPE__ + NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL); + NSString *contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType); + if (!contentType) { + return @"application/octet-stream"; + } else { + return contentType; + } +#else +#pragma unused (extension) + return @"application/octet-stream"; +#endif +} + +NSUInteger const kAFUploadStream3GSuggestedPacketSize = 1024 * 16; +NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; + +@interface AFHTTPBodyPart : NSObject +@property (nonatomic, assign) NSStringEncoding stringEncoding; +@property (nonatomic, strong) NSDictionary *headers; +@property (nonatomic, copy) NSString *boundary; +@property (nonatomic, strong) id body; +@property (nonatomic, assign) unsigned long long bodyContentLength; +@property (nonatomic, strong) NSInputStream *inputStream; + +@property (nonatomic, assign) BOOL hasInitialBoundary; +@property (nonatomic, assign) BOOL hasFinalBoundary; + +@property (readonly, nonatomic, assign, getter = hasBytesAvailable) BOOL bytesAvailable; +@property (readonly, nonatomic, assign) unsigned long long contentLength; + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@interface AFMultipartBodyStream : NSInputStream +@property (nonatomic, assign) NSUInteger numberOfBytesInPacket; +@property (nonatomic, assign) NSTimeInterval delay; +@property (nonatomic, strong) NSInputStream *inputStream; +@property (readonly, nonatomic, assign) unsigned long long contentLength; +@property (readonly, nonatomic, assign, getter = isEmpty) BOOL empty; + +- (id)initWithStringEncoding:(NSStringEncoding)encoding; +- (void)setInitialAndFinalBoundaries; +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart; +@end + +#pragma mark - + +@interface AFStreamingMultipartFormData () +@property (readwrite, nonatomic, copy) NSMutableURLRequest *request; +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, copy) NSString *boundary; +@property (readwrite, nonatomic, strong) AFMultipartBodyStream *bodyStream; +@end + +@implementation AFStreamingMultipartFormData + +- (id)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding +{ + self = [super init]; + if (!self) { + return nil; + } + + self.request = urlRequest; + self.stringEncoding = encoding; + self.boundary = AFCreateMultipartFormBoundary(); + self.bodyStream = [[AFMultipartBodyStream alloc] initWithStringEncoding:encoding]; + + return self; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + + NSString *fileName = [fileURL lastPathComponent]; + NSString *mimeType = AFContentTypeForPathExtension([fileURL pathExtension]); + + return [self appendPartWithFileURL:fileURL name:name fileName:fileName mimeType:mimeType error:error]; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + if (![fileURL isFileURL]) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"File URL not reachable.", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } + + NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:error]; + if (!fileAttributes) { + return NO; + } + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = fileURL; + bodyPart.bodyContentLength = [[fileAttributes objectForKey:NSFileSize] unsignedLongLongValue]; + [self.bodyStream appendHTTPBodyPart:bodyPart]; + + return YES; +} + +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = inputStream; + + bodyPart.bodyContentLength = (unsigned long long)length; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name +{ + NSParameterAssert(name); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithHeaders:(NSDictionary *)headers + body:(NSData *)body +{ + NSParameterAssert(body); + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = headers; + bodyPart.boundary = self.boundary; + bodyPart.bodyContentLength = [body length]; + bodyPart.body = body; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay +{ + self.bodyStream.numberOfBytesInPacket = numberOfBytes; + self.bodyStream.delay = delay; +} + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData { + if ([self.bodyStream isEmpty]) { + return self.request; + } + + // Reset the initial and final boundaries to ensure correct Content-Length + [self.bodyStream setInitialAndFinalBoundaries]; + [self.request setHTTPBodyStream:self.bodyStream]; + + [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", self.boundary] forHTTPHeaderField:@"Content-Type"]; + [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"]; + + return self.request; +} + +@end + +#pragma mark - + +@interface NSStream () +@property (readwrite) NSStreamStatus streamStatus; +@property (readwrite, copy) NSError *streamError; +@end + +@interface AFMultipartBodyStream () +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, strong) NSMutableArray *HTTPBodyParts; +@property (readwrite, nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator; +@property (readwrite, nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart; +@property (readwrite, nonatomic, strong) NSOutputStream *outputStream; +@property (readwrite, nonatomic, strong) NSMutableData *buffer; +@end + +@implementation AFMultipartBodyStream +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wimplicit-atomic-properties" +#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) +@synthesize delegate; +#endif +@synthesize streamStatus; +@synthesize streamError; +#pragma clang diagnostic pop + +- (id)initWithStringEncoding:(NSStringEncoding)encoding { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = encoding; + self.HTTPBodyParts = [NSMutableArray array]; + self.numberOfBytesInPacket = NSIntegerMax; + + return self; +} + +- (void)setInitialAndFinalBoundaries { + if ([self.HTTPBodyParts count] > 0) { + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + bodyPart.hasInitialBoundary = NO; + bodyPart.hasFinalBoundary = NO; + } + + [[self.HTTPBodyParts objectAtIndex:0] setHasInitialBoundary:YES]; + [[self.HTTPBodyParts lastObject] setHasFinalBoundary:YES]; + } +} + +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart { + [self.HTTPBodyParts addObject:bodyPart]; +} + +- (BOOL)isEmpty { + return [self.HTTPBodyParts count] == 0; +} + +#pragma mark - NSInputStream + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + if ([self streamStatus] == NSStreamStatusClosed) { + return 0; + } + + NSInteger totalNumberOfBytesRead = 0; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + while ((NSUInteger)totalNumberOfBytesRead < MIN(length, self.numberOfBytesInPacket)) { + if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) { + if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) { + break; + } + } else { + NSUInteger maxLength = length - (NSUInteger)totalNumberOfBytesRead; + NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:&buffer[totalNumberOfBytesRead] maxLength:maxLength]; + if (numberOfBytesRead == -1) { + self.streamError = self.currentHTTPBodyPart.inputStream.streamError; + break; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if (self.delay > 0.0f) { + [NSThread sleepForTimeInterval:self.delay]; + } + } + } + } +#pragma clang diagnostic pop + + return totalNumberOfBytesRead; +} + +- (BOOL)getBuffer:(__unused uint8_t **)buffer + length:(__unused NSUInteger *)len +{ + return NO; +} + +- (BOOL)hasBytesAvailable { + return [self streamStatus] == NSStreamStatusOpen; +} + +#pragma mark - NSStream + +- (void)open { + if (self.streamStatus == NSStreamStatusOpen) { + return; + } + + self.streamStatus = NSStreamStatusOpen; + + [self setInitialAndFinalBoundaries]; + self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator]; +} + +- (void)close { + self.streamStatus = NSStreamStatusClosed; +} + +- (id)propertyForKey:(__unused NSString *)key { + return nil; +} + +- (BOOL)setProperty:(__unused id)property + forKey:(__unused NSString *)key +{ + return NO; +} + +- (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + length += [bodyPart contentLength]; + } + + return length; +} + +#pragma mark - Undocumented CFReadStream Bridged Methods + +- (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags + callback:(__unused CFReadStreamClientCallBack)inCallback + context:(__unused CFStreamClientContext *)inContext { + return NO; +} + +#pragma mark - NSCopying + +-(id)copyWithZone:(NSZone *)zone { + AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; + + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + [bodyStreamCopy appendHTTPBodyPart:[bodyPart copy]]; + } + + [bodyStreamCopy setInitialAndFinalBoundaries]; + + return bodyStreamCopy; +} + +@end + +#pragma mark - + +typedef enum { + AFEncapsulationBoundaryPhase = 1, + AFHeaderPhase = 2, + AFBodyPhase = 3, + AFFinalBoundaryPhase = 4, +} AFHTTPBodyPartReadPhase; + +@interface AFHTTPBodyPart () { + AFHTTPBodyPartReadPhase _phase; + NSInputStream *_inputStream; + unsigned long long _phaseReadOffset; +} + +- (BOOL)transitionToNextPhase; +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@implementation AFHTTPBodyPart + +- (id)init { + self = [super init]; + if (!self) { + return nil; + } + + [self transitionToNextPhase]; + + return self; +} + +- (void)dealloc { + if (_inputStream) { + [_inputStream close]; + _inputStream = nil; + } +} + +- (NSInputStream *)inputStream { + if (!_inputStream) { + if ([self.body isKindOfClass:[NSData class]]) { + _inputStream = [NSInputStream inputStreamWithData:self.body]; + } else if ([self.body isKindOfClass:[NSURL class]]) { + _inputStream = [NSInputStream inputStreamWithURL:self.body]; + } else if ([self.body isKindOfClass:[NSInputStream class]]) { + _inputStream = self.body; + } else { + _inputStream = [NSInputStream inputStreamWithData:[NSData data]]; + } + } + + return _inputStream; +} + +- (NSString *)stringForHeaders { + NSMutableString *headerString = [NSMutableString string]; + for (NSString *field in [self.headers allKeys]) { + [headerString appendString:[NSString stringWithFormat:@"%@: %@%@", field, [self.headers valueForKey:field], kAFMultipartFormCRLF]]; + } + [headerString appendString:kAFMultipartFormCRLF]; + + return [NSString stringWithString:headerString]; +} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + length += [encapsulationBoundaryData length]; + + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + length += [headersData length]; + + length += _bodyContentLength; + + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + length += [closingBoundaryData length]; + + return length; +} + +- (BOOL)hasBytesAvailable { + // Allows `read:maxLength:` to be called again if `AFMultipartFormFinalBoundary` doesn't fit into the available buffer + if (_phase == AFFinalBoundaryPhase) { + return YES; + } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" + switch (self.inputStream.streamStatus) { + case NSStreamStatusNotOpen: + case NSStreamStatusOpening: + case NSStreamStatusOpen: + case NSStreamStatusReading: + case NSStreamStatusWriting: + return YES; + case NSStreamStatusAtEnd: + case NSStreamStatusClosed: + case NSStreamStatusError: + default: + return NO; + } +#pragma clang diagnostic pop +} + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + NSInteger totalNumberOfBytesRead = 0; + + if (_phase == AFEncapsulationBoundaryPhase) { + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFHeaderPhase) { + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:headersData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFBodyPhase) { + NSInteger numberOfBytesRead = 0; + + numberOfBytesRead = [self.inputStream read:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + if (numberOfBytesRead == -1) { + return -1; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if ([self.inputStream streamStatus] >= NSStreamStatusAtEnd) { + [self transitionToNextPhase]; + } + } + } + + if (_phase == AFFinalBoundaryPhase) { + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + totalNumberOfBytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + return totalNumberOfBytesRead; +} + +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + NSRange range = NSMakeRange((NSUInteger)_phaseReadOffset, MIN([data length] - ((NSUInteger)_phaseReadOffset), length)); + [data getBytes:buffer range:range]; +#pragma clang diagnostic pop + + _phaseReadOffset += range.length; + + if (((NSUInteger)_phaseReadOffset) >= [data length]) { + [self transitionToNextPhase]; + } + + return (NSInteger)range.length; +} + +- (BOOL)transitionToNextPhase { + if (![[NSThread currentThread] isMainThread]) { + dispatch_sync(dispatch_get_main_queue(), ^{ + [self transitionToNextPhase]; + }); + return YES; + } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" + switch (_phase) { + case AFEncapsulationBoundaryPhase: + _phase = AFHeaderPhase; + break; + case AFHeaderPhase: + [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; + [self.inputStream open]; + _phase = AFBodyPhase; + break; + case AFBodyPhase: + [self.inputStream close]; + _phase = AFFinalBoundaryPhase; + break; + case AFFinalBoundaryPhase: + default: + _phase = AFEncapsulationBoundaryPhase; + break; + } + _phaseReadOffset = 0; +#pragma clang diagnostic pop + + return YES; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPBodyPart *bodyPart = [[[self class] allocWithZone:zone] init]; + + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = self.headers; + bodyPart.bodyContentLength = self.bodyContentLength; + bodyPart.body = self.body; + bodyPart.boundary = self.boundary; + + return bodyPart; +} + +@end + +#pragma mark - + +@implementation AFJSONRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithWritingOptions:(NSJSONWritingOptions)0]; +} + ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions +{ + AFJSONRequestSerializer *serializer = [[self alloc] init]; + serializer.writingOptions = writingOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; + } + + [mutableRequest setHTTPBody:[NSJSONSerialization dataWithJSONObject:parameters options:self.writingOptions error:error]]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.writingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writingOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeInteger:self.writingOptions forKey:NSStringFromSelector(@selector(writingOptions))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFJSONRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.writingOptions = self.writingOptions; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFPropertyListRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 writeOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions +{ + AFPropertyListRequestSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.writeOptions = writeOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerializer + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-plist" forHTTPHeaderField:@"Content-Type"]; + } + + [mutableRequest setHTTPBody:[NSPropertyListSerialization dataWithPropertyList:parameters format:self.format options:self.writeOptions error:error]]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.writeOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writeOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeInteger:self.format forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFPropertyListRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.format = self.format; + serializer.writeOptions = self.writeOptions; + + return serializer; +} + +@end diff --git a/AFNetworking-master/AFNetworking/AFURLResponseSerialization.h b/AFNetworking-master/AFNetworking/AFURLResponseSerialization.h new file mode 100755 index 0000000..9cd4ad2 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1,309 @@ +// AFURLResponseSerialization.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +/** + 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. + + 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. + */ +@protocol AFURLResponseSerialization + +/** + The response object decoded from the data associated with a specified response. + + @param response The response to be processed. + @param data The response data to be decoded. + @param error The error that occurred while attempting to decode the response data. + + @return The object decoded from the specified response data. + */ +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error; + +@end + +#pragma mark - + +/** + `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. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPResponseSerializer : NSObject + +- (instancetype) init; + +/** + The string encoding used to serialize data received from the server, when no string encoding is specified by the response. `NSUTF8StringEncoding` by default. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +///----------------------------------------- +/// @name Configuring Response Serialization +///----------------------------------------- + +/** + 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. + + See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html + */ +@property (nonatomic, copy) NSIndexSet *acceptableStatusCodes; + +/** + 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. + */ +@property (nonatomic, copy) NSSet *acceptableContentTypes; + +/** + Validates the specified response and data. + + In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks. + + @param response The response to be validated. + @param data The data associated with the response. + @param error The error that occurred while attempting to validate the response. + + @return `YES` if the response is valid, otherwise `NO`. + */ +- (BOOL)validateResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error; + +@end + +#pragma mark - + + +/** + `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses. + + By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types: + + - `application/json` + - `text/json` + - `text/javascript` + */ +@interface AFJSONResponseSerializer : AFHTTPResponseSerializer + +- (instancetype) init; + +/** + Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONReadingOptions readingOptions; + +/** + Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL removesKeysWithNullValues; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param readingOptions The specified JSON reading options. + */ ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions; + +@end + +#pragma mark - + +/** + `AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects. + + By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +/** + `AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer + +- (instancetype) init; + +/** + Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. + */ +@property (nonatomic, assign) NSUInteger options; + +/** + Creates and returns an XML document serializer with the specified options. + + @param mask The XML document options. + */ ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask; + +@end + +#endif + +#pragma mark - + +/** + `AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFPropertyListResponseSerializer` accepts the following MIME types: + + - `application/x-plist` + */ +@interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer + +- (instancetype) init; + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions." + */ +@property (nonatomic, assign) NSPropertyListReadOptions readOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param readOptions The property list reading options. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions; + +@end + +#pragma mark - + +/** + `AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses. + + By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage: + + - `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` + */ +@interface AFImageResponseSerializer : AFHTTPResponseSerializer + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +/** + 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. + */ +@property (nonatomic, assign) CGFloat imageScale; + +/** + 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. + */ +@property (nonatomic, assign) BOOL automaticallyInflatesResponseImage; +#endif + +@end + +#pragma mark - + +/** + `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. + */ +@interface AFCompoundResponseSerializer : AFHTTPResponseSerializer + +/** + The component response serializers. + */ +@property (readonly, nonatomic, copy) NSArray *responseSerializers; + +/** + Creates and returns a compound serializer comprised of the specified response serializers. + + @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`. + */ ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLResponseSerializationErrorDomain` + + ### Constants + + `AFURLResponseSerializationErrorDomain` + AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +extern NSString * const AFURLResponseSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey` + - `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLResponseErrorKey` + The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. + + `AFNetworkingOperationFailingURLResponseDataErrorKey` + 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`. + */ +extern NSString * const AFNetworkingOperationFailingURLResponseErrorKey; + +extern NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey; + + diff --git a/AFNetworking-master/AFNetworking/AFURLResponseSerialization.m b/AFNetworking-master/AFNetworking/AFURLResponseSerialization.m new file mode 100755 index 0000000..a672d20 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFURLResponseSerialization.m @@ -0,0 +1,797 @@ +// AFURLResponseSerialization.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLResponseSerialization.h" + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +#import +#endif + +NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response"; +NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response"; +NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data"; + +static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) { + if (!error) { + return underlyingError; + } + + if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) { + return error; + } + + NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy]; + mutableUserInfo[NSUnderlyingErrorKey] = underlyingError; + + return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo]; +} + +static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) { + if ([error.domain isEqualToString:domain] && error.code == code) { + return YES; + } else if (error.userInfo[NSUnderlyingErrorKey]) { + return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain); + } + + return NO; +} + +static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) { + if ([JSONObject isKindOfClass:[NSArray class]]) { + NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]]; + for (id value in (NSArray *)JSONObject) { + [mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)]; + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray]; + } else if ([JSONObject isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONObject]; + for (id key in [(NSDictionary *)JSONObject allKeys]) { + id value = [(NSDictionary *)JSONObject objectForKey:key]; + if (!value || [value isEqual:[NSNull null]]) { + [mutableDictionary removeObjectForKey:key]; + } else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) { + [mutableDictionary setObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions) forKey:key]; + } + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableDictionary : [NSDictionary dictionaryWithDictionary:mutableDictionary]; + } + + return JSONObject; +} + +@implementation AFHTTPResponseSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = NSUTF8StringEncoding; + + self.acceptableStatusCodes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)]; + self.acceptableContentTypes = nil; + + return self; +} + +#pragma mark - + +- (BOOL)validateResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError * __autoreleasing *)error +{ + BOOL responseIsValid = YES; + NSError *validationError = nil; + + if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) { + if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]]) { + if ([data length] > 0 && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError); + } + + responseIsValid = NO; + } + + if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError); + + responseIsValid = NO; + } + } + + if (error && !responseIsValid) { + *error = validationError; + } + + return responseIsValid; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + [self validateResponse:(NSHTTPURLResponse *)response data:data error:error]; + + return data; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.acceptableStatusCodes forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + [coder encodeObject:self.acceptableContentTypes forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone]; + serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone]; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFJSONResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithReadingOptions:(NSJSONReadingOptions)0]; +} + ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions { + AFJSONResponseSerializer *serializer = [[self alloc] init]; + serializer.readingOptions = readingOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + // 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. + // See https://github.com/rails/rails/issues/1742 + NSStringEncoding stringEncoding = self.stringEncoding; + if (response.textEncodingName) { + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); + if (encoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); + } + } + + id responseObject = nil; + NSError *serializationError = nil; + @autoreleasepool { + NSString *responseString = [[NSString alloc] initWithData:data encoding:stringEncoding]; + if (responseString && ![responseString isEqualToString:@" "]) { + // Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character + // See http://stackoverflow.com/a/12843465/157142 + data = [responseString dataUsingEncoding:NSUTF8StringEncoding]; + + if (data) { + if ([data length] > 0) { + responseObject = [NSJSONSerialization JSONObjectWithData:data options:self.readingOptions error:&serializationError]; + } else { + return nil; + } + } else { + NSDictionary *userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedStringFromTable(@"Data failed decoding as a UTF-8 string", @"AFNetworking", nil), + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Could not decode string: %@", @"AFNetworking", nil), responseString] + }; + + serializationError = [NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo]; + } + } + } + + if (self.removesKeysWithNullValues && responseObject) { + responseObject = AFJSONObjectByRemovingKeysWithNullValues(responseObject, self.readingOptions); + } + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.readingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readingOptions))] unsignedIntegerValue]; + self.removesKeysWithNullValues = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))] boolValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.readingOptions) forKey:NSStringFromSelector(@selector(readingOptions))]; + [coder encodeObject:@(self.removesKeysWithNullValues) forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFJSONResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.readingOptions = self.readingOptions; + serializer.removesKeysWithNullValues = self.removesKeysWithNullValues; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFXMLParserResponseSerializer + ++ (instancetype)serializer { + AFXMLParserResponseSerializer *serializer = [[self alloc] init]; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + return [[NSXMLParser alloc] initWithData:data]; +} + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +@implementation AFXMLDocumentResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithXMLDocumentOptions:0]; +} + ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask { + AFXMLDocumentResponseSerializer *serializer = [[self alloc] init]; + serializer.options = mask; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + NSError *serializationError = nil; + NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data options:self.options error:&serializationError]; + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return document; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.options = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(options))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.options) forKey:NSStringFromSelector(@selector(options))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFXMLDocumentResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.options = self.options; + + return serializer; +} + +@end + +#endif + +#pragma mark - + +@implementation AFPropertyListResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 readOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions +{ + AFPropertyListResponseSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.readOptions = readOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/x-plist", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + id responseObject; + NSError *serializationError = nil; + + if (data) { + responseObject = [NSPropertyListSerialization propertyListWithData:data options:self.readOptions format:NULL error:&serializationError]; + } + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.readOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.readOptions) forKey:NSStringFromSelector(@selector(readOptions))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFPropertyListResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.format = self.format; + serializer.readOptions = self.readOptions; + + return serializer; +} + +@end + +#pragma mark - + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import + +static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) { + UIImage *image = [[UIImage alloc] initWithData:data]; + if (image.images) { + return image; + } + + return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation]; +} + +static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) { + if (!data || [data length] == 0) { + return nil; + } + + CGImageRef imageRef = NULL; + CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data); + + if ([response.MIMEType isEqualToString:@"image/png"]) { + imageRef = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + } else if ([response.MIMEType isEqualToString:@"image/jpeg"]) { + imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + + if (imageRef) { + CGColorSpaceRef imageColorSpace = CGImageGetColorSpace(imageRef); + CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(imageColorSpace); + + // CGImageCreateWithJPEGDataProvider does not properly handle CMKY, so fall back to AFImageWithDataAtScale + if (imageColorSpaceModel == kCGColorSpaceModelCMYK) { + CGImageRelease(imageRef); + imageRef = NULL; + } + } + } + + CGDataProviderRelease(dataProvider); + + UIImage *image = AFImageWithDataAtScale(data, scale); + if (!imageRef) { + if (image.images || !image) { + return image; + } + + imageRef = CGImageCreateCopy([image CGImage]); + if (!imageRef) { + return nil; + } + } + + size_t width = CGImageGetWidth(imageRef); + size_t height = CGImageGetHeight(imageRef); + size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef); + + if (width * height > 1024 * 1024 || bitsPerComponent > 8) { + CGImageRelease(imageRef); + + return image; + } + + // CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate + size_t bytesPerRow = 0; + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace); + CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); + + if (colorSpaceModel == kCGColorSpaceModelRGB) { + uint32_t alpha = (bitmapInfo & kCGBitmapAlphaInfoMask); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wassign-enum" + if (alpha == kCGImageAlphaNone) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaNoneSkipFirst; + } else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaPremultipliedFirst; + } +#pragma clang diagnostic pop + } + + CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo); + + CGColorSpaceRelease(colorSpace); + + if (!context) { + CGImageRelease(imageRef); + + return image; + } + + CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), imageRef); + CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context); + + CGContextRelease(context); + + UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:image.imageOrientation]; + + CGImageRelease(inflatedImageRef); + CGImageRelease(imageRef); + + return inflatedImage; +} +#endif + + +@implementation AFImageResponseSerializer + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + 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]; + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + self.imageScale = [[UIScreen mainScreen] scale]; + self.automaticallyInflatesResponseImage = YES; +#endif + + return self; +} + +#pragma mark - AFURLResponseSerializer + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + if (self.automaticallyInflatesResponseImage) { + return AFInflatedImageFromResponseWithDataAtScale((NSHTTPURLResponse *)response, data, self.imageScale); + } else { + return AFImageWithDataAtScale(data, self.imageScale); + } +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + // Ensure that the image is set to it's correct pixel width and height + NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:data]; + NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])]; + [image addRepresentation:bitimage]; + + return image; +#endif + + return nil; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + NSNumber *imageScale = [decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(imageScale))]; +#if CGFLOAT_IS_DOUBLE + self.imageScale = [imageScale doubleValue]; +#else + self.imageScale = [imageScale floatValue]; +#endif + + self.automaticallyInflatesResponseImage = [decoder decodeBoolForKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + [coder encodeObject:@(self.imageScale) forKey:NSStringFromSelector(@selector(imageScale))]; + [coder encodeBool:self.automaticallyInflatesResponseImage forKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFImageResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + serializer.imageScale = self.imageScale; + serializer.automaticallyInflatesResponseImage = self.automaticallyInflatesResponseImage; +#endif + + return serializer; +} + +@end + +#pragma mark - + +@interface AFCompoundResponseSerializer () +@property (readwrite, nonatomic, copy) NSArray *responseSerializers; +@end + +@implementation AFCompoundResponseSerializer + ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers { + AFCompoundResponseSerializer *serializer = [[self alloc] init]; + serializer.responseSerializers = responseSerializers; + + return serializer; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + for (id serializer in self.responseSerializers) { + if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) { + continue; + } + + NSError *serializerError = nil; + id responseObject = [serializer responseObjectForResponse:response data:data error:&serializerError]; + if (responseObject) { + if (error) { + *error = AFErrorWithUnderlyingError(serializerError, *error); + } + + return responseObject; + } + } + + return [super responseObjectForResponse:response data:data error:error]; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.responseSerializers = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(responseSerializers))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.responseSerializers forKey:NSStringFromSelector(@selector(responseSerializers))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFCompoundResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.responseSerializers = self.responseSerializers; + + return serializer; +} + +@end diff --git a/AFNetworking-master/AFNetworking/AFURLSessionManager.h b/AFNetworking-master/AFNetworking/AFURLSessionManager.h new file mode 100755 index 0000000..21d9d64 --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFURLSessionManager.h @@ -0,0 +1,546 @@ +// AFURLSessionManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" +#import "AFSecurityPolicy.h" +#import "AFNetworkReachabilityManager.h" + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +/** + `AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. + + ## Subclassing Notes + + 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. + + ## NSURLSession & NSURLSessionTask Delegate Methods + + `AFURLSessionManager` implements the following delegate methods: + + ### `NSURLSessionDelegate` + + - `URLSession:didBecomeInvalidWithError:` + - `URLSession:didReceiveChallenge:completionHandler:` + - `URLSessionDidFinishEventsForBackgroundURLSession:` + + ### `NSURLSessionTaskDelegate` + + - `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:` + - `URLSession:task:didReceiveChallenge:completionHandler:` + - `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:` + - `URLSession:task:didCompleteWithError:` + + ### `NSURLSessionDataDelegate` + + - `URLSession:dataTask:didReceiveResponse:completionHandler:` + - `URLSession:dataTask:didBecomeDownloadTask:` + - `URLSession:dataTask:didReceiveData:` + - `URLSession:dataTask:willCacheResponse:completionHandler:` + + ### `NSURLSessionDownloadDelegate` + + - `URLSession:downloadTask:didFinishDownloadingToURL:` + - `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:` + - `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:` + + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. + + ## Network Reachability Monitoring + + 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. + + ## NSCoding Caveats + + - Encoded managers do not include any block properties. Be sure to set delegate callback blocks when using `-initWithCoder:` or `NSKeyedUnarchiver`. + + ## NSCopying Caveats + + - `-copy` and `-copyWithZone:` return a new manager with a new `NSURLSession` created from the configuration of the original. + - 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. + + @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. + */ + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) + +@interface AFURLSessionManager : NSObject + +/** + The managed session. + */ +@property (readonly, nonatomic, strong) NSURLSession *session; + +/** + The operation queue on which delegate callbacks are run. + */ +@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue; + +/** + 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`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) id responseSerializer; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used by created request operations to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +///-------------------------------------- +/// @name Monitoring Network Reachability +///-------------------------------------- + +/** + The network reachability manager. `AFURLSessionManager` uses the `sharedManager` by default. + */ +@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager; + +///---------------------------- +/// @name Getting Session Tasks +///---------------------------- + +/** + The data, upload, and download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *tasks; + +/** + The data tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *dataTasks; + +/** + The upload tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *uploadTasks; + +/** + The download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *downloadTasks; + +///------------------------------- +/// @name Managing Callback Queues +///------------------------------- + +/** + The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used. + */ +#if OS_OBJECT_HAVE_OBJC_SUPPORT +@property (nonatomic, strong) dispatch_queue_t completionQueue; +#else +@property (nonatomic, assign) dispatch_queue_t completionQueue; +#endif + +/** + The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used. + */ +#if OS_OBJECT_HAVE_OBJC_SUPPORT +@property (nonatomic, strong) dispatch_group_t completionGroup; +#else +@property (nonatomic, assign) dispatch_group_t completionGroup; +#endif + +///--------------------------------- +/// @name Working Around System Bugs +///--------------------------------- + +/** + Whether to attempt to retry creation of upload tasks for background sessions when initial call returns `nil`. `NO` by default. + + @bug As of iOS 7.0, there is a bug where upload tasks created for background tasks are sometimes `nil`. As a workaround, if this property is `YES`, AFNetworking will follow Apple's recommendation to try creating the task again. + + @see https://github.com/AFNetworking/AFNetworking/issues/1675 + */ +@property (nonatomic, assign) BOOL attemptsToRecreateUploadTasksForBackgroundSessions; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a manager for a session created with the specified configuration. This is the designated initializer. + + @param configuration The configuration used to create the managed session. + + @return A manager for a newly-created session. + */ +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; + +/** + Invalidates the managed session, optionally canceling pending tasks. + + @param cancelPendingTasks Whether or not to cancel pending tasks. + */ +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks; + +///------------------------- +/// @name Running Data Tasks +///------------------------- + +/** + Creates an `NSURLSessionDataTask` with the specified request. + + @param request The HTTP request for the request. + @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. + */ +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler; + +///--------------------------- +/// @name Running Upload Tasks +///--------------------------- + +/** + Creates an `NSURLSessionUploadTask` with the specified request for a local file. + + @param request The HTTP request for the request. + @param fileURL A URL to the local file to be uploaded. + @param progress A progress object monitoring the current upload progress. + @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. + + @see `attemptsToRecreateUploadTasksForBackgroundSessions` + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified request for an HTTP body. + + @param request The HTTP request for the request. + @param bodyData A data object containing the HTTP body to be uploaded. + @param progress A progress object monitoring the current upload progress. + @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. + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(NSData *)bodyData + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified streaming request. + + @param request The HTTP request for the request. + @param progress A progress object monitoring the current upload progress. + @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. + */ +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler; + +///----------------------------- +/// @name Running Download Tasks +///----------------------------- + +/** + Creates an `NSURLSessionDownloadTask` with the specified request. + + @param request The HTTP request for the request. + @param progress A progress object monitoring the current download progress. + @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. + @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. + + @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. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler; + +/** + Creates an `NSURLSessionDownloadTask` with the specified resume data. + + @param resumeData The data used to resume downloading. + @param progress A progress object monitoring the current download progress. + @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. + @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. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler; + +///--------------------------------- +/// @name Getting Progress for Tasks +///--------------------------------- + +/** + Returns the upload progress of the specified task. + + @param uploadTask The session upload task. Must not be `nil`. + + @return An `NSProgress` object reporting the upload progress of a task, or `nil` if the progress is unavailable. + */ +- (NSProgress *)uploadProgressForTask:(NSURLSessionUploadTask *)uploadTask; + +/** + Returns the download progress of the specified task. + + @param downloadTask The session download task. Must not be `nil`. + + @return An `NSProgress` object reporting the download progress of a task, or `nil` if the progress is unavailable. + */ +- (NSProgress *)downloadProgressForTask:(NSURLSessionDownloadTask *)downloadTask; + +///----------------------------------------- +/// @name Setting Session Delegate Callbacks +///----------------------------------------- + +/** + Sets a block to be executed when the managed session becomes invalid, as handled by the `NSURLSessionDelegate` method `URLSession:didBecomeInvalidWithError:`. + + @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. + */ +- (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block; + +/** + Sets a block to be executed when a connection level authentication challenge has occurred, as handled by the `NSURLSessionDelegate` method `URLSession:didReceiveChallenge:completionHandler:`. + + @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. + */ +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block; + +///-------------------------------------- +/// @name Setting Task Delegate Callbacks +///-------------------------------------- + +/** + 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:`. + + @param block A block object to be executed when a task requires a new request body stream. + */ +- (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block; + +/** + 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:`. + + @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. + */ +- (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block; + +/** + 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:`. + + @param block A block object to be executed when a session task has received a request specific authentication challenge. The block returns the disposition of the authentication challenge, and takes four arguments: the session, the task, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. + */ +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block; + +/** + Sets a block to be executed periodically to track upload progress, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`. + + @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. + */ +- (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block; + +/** + Sets a block to be executed as the last message related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didCompleteWithError:`. + + @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. + */ +- (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block; + +///------------------------------------------- +/// @name Setting Data Task Delegate Callbacks +///------------------------------------------- + +/** + Sets a block to be executed when a data task has received a response, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveResponse:completionHandler:`. + + @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. + */ +- (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block; + +/** + Sets a block to be executed when a data task has become a download task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didBecomeDownloadTask:`. + + @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. + */ +- (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block; + +/** + Sets a block to be executed when a data task receives data, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveData:`. + + @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. + */ +- (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block; + +/** + 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:`. + + @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. + */ +- (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block; + +/** + Sets a block to be executed once all messages enqueued for a session have been delivered, as handled by the `NSURLSessionDataDelegate` method `URLSessionDidFinishEventsForBackgroundURLSession:`. + + @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. + */ +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block; + +///----------------------------------------------- +/// @name Setting Download Task Delegate Callbacks +///----------------------------------------------- + +/** + Sets a block to be executed when a download task has completed a download, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didFinishDownloadingToURL:`. + + @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. + */ +- (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block; + +/** + Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`. + + @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. + */ +- (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block; + +/** + Sets a block to be executed when a download task has been resumed, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`. + + @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. + */ +- (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block; + +@end + +#endif + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when a task begins executing. + + @deprecated Use `AFNetworkingTaskDidResumeNotification` instead. + */ +extern NSString * const AFNetworkingTaskDidStartNotification DEPRECATED_ATTRIBUTE; + +/** + Posted when a task resumes. + */ +extern NSString * const AFNetworkingTaskDidResumeNotification; + +/** + Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task. + + @deprecated Use `AFNetworkingTaskDidCompleteNotification` instead. + */ +extern NSString * const AFNetworkingTaskDidFinishNotification DEPRECATED_ATTRIBUTE; + +/** + Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task. + */ +extern NSString * const AFNetworkingTaskDidCompleteNotification; + +/** + Posted when a task suspends its execution. + */ +extern NSString * const AFNetworkingTaskDidSuspendNotification; + +/** + Posted when a session is invalidated. + */ +extern NSString * const AFURLSessionDidInvalidateNotification; + +/** + Posted when a session download task encountered an error when moving the temporary download file to a specified destination. + */ +extern NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification; + +/** + The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if response data exists for the task. + + @deprecated Use `AFNetworkingTaskDidCompleteResponseDataKey` instead. + */ +extern NSString * const AFNetworkingTaskDidFinishResponseDataKey DEPRECATED_ATTRIBUTE; + +/** + The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if response data exists for the task. + */ +extern NSString * const AFNetworkingTaskDidCompleteResponseDataKey; + +/** + The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the response was serialized. + + @deprecated Use `AFNetworkingTaskDidCompleteSerializedResponseKey` instead. + */ +extern NSString * const AFNetworkingTaskDidFinishSerializedResponseKey DEPRECATED_ATTRIBUTE; + +/** + The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the response was serialized. + */ +extern NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey; + +/** + The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the task has an associated response serializer. + + @deprecated Use `AFNetworkingTaskDidCompleteResponseSerializerKey` instead. + */ +extern NSString * const AFNetworkingTaskDidFinishResponseSerializerKey DEPRECATED_ATTRIBUTE; + +/** + The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the task has an associated response serializer. + */ +extern NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey; + +/** + The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an the response data has been stored directly to disk. + + @deprecated Use `AFNetworkingTaskDidCompleteAssetPathKey` instead. + */ +extern NSString * const AFNetworkingTaskDidFinishAssetPathKey DEPRECATED_ATTRIBUTE; + +/** + The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an the response data has been stored directly to disk. + */ +extern NSString * const AFNetworkingTaskDidCompleteAssetPathKey; + +/** + Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an error exists. + + @deprecated Use `AFNetworkingTaskDidCompleteErrorKey` instead. + */ +extern NSString * const AFNetworkingTaskDidFinishErrorKey DEPRECATED_ATTRIBUTE; + +/** + Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an error exists. + */ +extern NSString * const AFNetworkingTaskDidCompleteErrorKey; diff --git a/AFNetworking-master/AFNetworking/AFURLSessionManager.m b/AFNetworking-master/AFNetworking/AFURLSessionManager.m new file mode 100755 index 0000000..837ea1c --- /dev/null +++ b/AFNetworking-master/AFNetworking/AFURLSessionManager.m @@ -0,0 +1,1103 @@ +// AFURLSessionManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLSessionManager.h" +#import + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) + +static dispatch_queue_t url_session_manager_creation_queue() { + static dispatch_queue_t af_url_session_manager_creation_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_creation_queue = dispatch_queue_create("com.alamofire.networking.session.manager.creation", DISPATCH_QUEUE_SERIAL); + }); + + return af_url_session_manager_creation_queue; +} + +static dispatch_queue_t url_session_manager_processing_queue() { + static dispatch_queue_t af_url_session_manager_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_processing_queue = dispatch_queue_create("com.alamofire.networking.session.manager.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_url_session_manager_processing_queue; +} + +static dispatch_group_t url_session_manager_completion_group() { + static dispatch_group_t af_url_session_manager_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_completion_group = dispatch_group_create(); + }); + + return af_url_session_manager_completion_group; +} + +NSString * const AFNetworkingTaskDidResumeNotification = @"com.alamofire.networking.task.resume"; +NSString * const AFNetworkingTaskDidCompleteNotification = @"com.alamofire.networking.task.complete"; +NSString * const AFNetworkingTaskDidSuspendNotification = @"com.alamofire.networking.task.suspend"; +NSString * const AFURLSessionDidInvalidateNotification = @"com.alamofire.networking.session.invalidate"; +NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification = @"com.alamofire.networking.session.download.file-manager-error"; + +NSString * const AFNetworkingTaskDidStartNotification = @"com.alamofire.networking.task.resume"; // Deprecated +NSString * const AFNetworkingTaskDidFinishNotification = @"com.alamofire.networking.task.complete"; // Deprecated + +NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse"; +NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer"; +NSString * const AFNetworkingTaskDidCompleteResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata"; +NSString * const AFNetworkingTaskDidCompleteErrorKey = @"com.alamofire.networking.task.complete.error"; +NSString * const AFNetworkingTaskDidCompleteAssetPathKey = @"com.alamofire.networking.task.complete.assetpath"; + +NSString * const AFNetworkingTaskDidFinishSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse"; // Deprecated +NSString * const AFNetworkingTaskDidFinishResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer"; // Deprecated +NSString * const AFNetworkingTaskDidFinishResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata"; // Deprecated +NSString * const AFNetworkingTaskDidFinishErrorKey = @"com.alamofire.networking.task.complete.error"; // Deprecated +NSString * const AFNetworkingTaskDidFinishAssetPathKey = @"com.alamofire.networking.task.complete.assetpath"; // Deprecated + +static NSString * const AFURLSessionManagerLockName = @"com.alamofire.networking.session.manager.lock"; + +static NSUInteger const AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask = 3; + +static void * AFTaskStateChangedContext = &AFTaskStateChangedContext; + +typedef void (^AFURLSessionDidBecomeInvalidBlock)(NSURLSession *session, NSError *error); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); + +typedef NSURLRequest * (^AFURLSessionTaskWillPerformHTTPRedirectionBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionTaskDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); +typedef void (^AFURLSessionDidFinishEventsForBackgroundURLSessionBlock)(NSURLSession *session); + +typedef NSInputStream * (^AFURLSessionTaskNeedNewBodyStreamBlock)(NSURLSession *session, NSURLSessionTask *task); +typedef void (^AFURLSessionTaskDidSendBodyDataBlock)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend); +typedef void (^AFURLSessionTaskDidCompleteBlock)(NSURLSession *session, NSURLSessionTask *task, NSError *error); + +typedef NSURLSessionResponseDisposition (^AFURLSessionDataTaskDidReceiveResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response); +typedef void (^AFURLSessionDataTaskDidBecomeDownloadTaskBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask); +typedef void (^AFURLSessionDataTaskDidReceiveDataBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data); +typedef NSCachedURLResponse * (^AFURLSessionDataTaskWillCacheResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse); + +typedef NSURL * (^AFURLSessionDownloadTaskDidFinishDownloadingBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location); +typedef void (^AFURLSessionDownloadTaskDidWriteDataBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite); +typedef void (^AFURLSessionDownloadTaskDidResumeBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes); + +typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id responseObject, NSError *error); + +#pragma mark - + +@interface AFURLSessionManagerTaskDelegate : NSObject +@property (nonatomic, weak) AFURLSessionManager *manager; +@property (nonatomic, strong) NSMutableData *mutableData; +@property (nonatomic, strong) NSProgress *progress; +@property (nonatomic, copy) NSURL *downloadFileURL; +@property (nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (nonatomic, copy) AFURLSessionTaskCompletionHandler completionHandler; +@end + +@implementation AFURLSessionManagerTaskDelegate + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.mutableData = [NSMutableData data]; + + self.progress = [NSProgress progressWithTotalUnitCount:0]; + + return self; +} + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(__unused NSURLSession *)session + task:(__unused NSURLSessionTask *)task + didSendBodyData:(__unused int64_t)bytesSent + totalBytesSent:(int64_t)totalBytesSent +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend +{ + self.progress.totalUnitCount = totalBytesExpectedToSend; + self.progress.completedUnitCount = totalBytesSent; +} + +- (void)URLSession:(__unused NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + __strong AFURLSessionManager *manager = self.manager; + + __block id responseObject = nil; + + __block NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer; + + if (self.downloadFileURL) { + userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL; + } else if (self.mutableData) { + userInfo[AFNetworkingTaskDidCompleteResponseDataKey] = [NSData dataWithData:self.mutableData]; + } + + if (error) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = error; + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, error); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + } else { + dispatch_async(url_session_manager_processing_queue(), ^{ + NSError *serializationError = nil; + responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:[NSData dataWithData:self.mutableData] error:&serializationError]; + + if (self.downloadFileURL) { + responseObject = self.downloadFileURL; + } + + if (responseObject) { + userInfo[AFNetworkingTaskDidCompleteSerializedResponseKey] = responseObject; + } + + if (serializationError) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = serializationError; + } + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, serializationError); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + }); + } +#pragma clang diagnostic pop +} + +#pragma mark - NSURLSessionDataTaskDelegate + +- (void)URLSession:(__unused NSURLSession *)session + dataTask:(__unused NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + [self.mutableData appendData:data]; +} + +#pragma mark - NSURLSessionDownloadTaskDelegate + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + NSError *fileManagerError = nil; + self.downloadFileURL = nil; + + if (self.downloadTaskDidFinishDownloading) { + self.downloadFileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (self.downloadFileURL) { + [[NSFileManager defaultManager] moveItemAtURL:location toURL:self.downloadFileURL error:&fileManagerError]; + + if (fileManagerError) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:fileManagerError.userInfo]; + } + } + } +} + +- (void)URLSession:(__unused NSURLSession *)session + downloadTask:(__unused NSURLSessionDownloadTask *)downloadTask + didWriteData:(__unused int64_t)bytesWritten + totalBytesWritten:(int64_t)totalBytesWritten +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite +{ + self.progress.totalUnitCount = totalBytesExpectedToWrite; + self.progress.completedUnitCount = totalBytesWritten; +} + +- (void)URLSession:(__unused NSURLSession *)session + downloadTask:(__unused NSURLSessionDownloadTask *)downloadTask + didResumeAtOffset:(int64_t)fileOffset +expectedTotalBytes:(int64_t)expectedTotalBytes { + self.progress.totalUnitCount = expectedTotalBytes; + self.progress.completedUnitCount = fileOffset; +} + +@end + +#pragma mark - + +/* + A workaround for issues related to key-value observing the `state` of an `NSURLSessionTask`. + + See https://github.com/AFNetworking/AFNetworking/issues/1477 + */ + +static inline void af_swizzleSelector(Class class, SEL originalSelector, SEL swizzledSelector) { + Method originalMethod = class_getInstanceMethod(class, originalSelector); + Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); + if (class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))) { + class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); + } else { + method_exchangeImplementations(originalMethod, swizzledMethod); + } +} + +static inline void af_addMethod(Class class, SEL selector, Method method) { + class_addMethod(class, selector, method_getImplementation(method), method_getTypeEncoding(method)); +} + +static NSString * const AFNSURLSessionTaskDidResumeNotification = @"com.alamofire.networking.nsurlsessiontask.resume"; +static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofire.networking.nsurlsessiontask.suspend"; + +@interface NSURLSessionTask (_AFStateObserving) +@end + +@implementation NSURLSessionTask (_AFStateObserving) + ++ (void)initialize { + if ([NSURLSessionTask class]) { + NSURLSessionDataTask *dataTask = [[NSURLSession sessionWithConfiguration:nil] dataTaskWithURL:nil]; + Class taskClass = [dataTask superclass]; + + af_addMethod(taskClass, @selector(af_resume), class_getInstanceMethod(self, @selector(af_resume))); + af_addMethod(taskClass, @selector(af_suspend), class_getInstanceMethod(self, @selector(af_suspend))); + af_swizzleSelector(taskClass, @selector(resume), @selector(af_resume)); + af_swizzleSelector(taskClass, @selector(suspend), @selector(af_suspend)); + + [dataTask cancel]; + } +} + +#pragma mark - + +- (void)af_resume { + NSURLSessionTaskState state = self.state; + [self af_resume]; + + if (state != NSURLSessionTaskStateRunning) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidResumeNotification object:self]; + } +} + +- (void)af_suspend { + NSURLSessionTaskState state = self.state; + [self af_suspend]; + + if (state != NSURLSessionTaskStateSuspended) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidSuspendNotification object:self]; + } +} + +@end + +#pragma mark - + +@interface AFURLSessionManager () +@property (readwrite, nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration; +@property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue; +@property (readwrite, nonatomic, strong) NSURLSession *session; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableTaskDelegatesKeyedByTaskIdentifier; +@property (readonly, nonatomic, copy) NSString *taskDescriptionForSessionTasks; +@property (readwrite, nonatomic, strong) NSLock *lock; +@property (readwrite, nonatomic, copy) AFURLSessionDidBecomeInvalidBlock sessionDidBecomeInvalid; +@property (readwrite, nonatomic, copy) AFURLSessionDidReceiveAuthenticationChallengeBlock sessionDidReceiveAuthenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLSessionDidFinishEventsForBackgroundURLSessionBlock didFinishEventsForBackgroundURLSession; +@property (readwrite, nonatomic, copy) AFURLSessionTaskWillPerformHTTPRedirectionBlock taskWillPerformHTTPRedirection; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidReceiveAuthenticationChallengeBlock taskDidReceiveAuthenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLSessionTaskNeedNewBodyStreamBlock taskNeedNewBodyStream; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidSendBodyDataBlock taskDidSendBodyData; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidCompleteBlock taskDidComplete; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveResponseBlock dataTaskDidReceiveResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidBecomeDownloadTaskBlock dataTaskDidBecomeDownloadTask; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveDataBlock dataTaskDidReceiveData; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskWillCacheResponseBlock dataTaskWillCacheResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidWriteDataBlock downloadTaskDidWriteData; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidResumeBlock downloadTaskDidResume; +@end + +@implementation AFURLSessionManager + +- (instancetype)init { + return [self initWithSessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + self = [super init]; + if (!self) { + return nil; + } + + if (!configuration) { + configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; + } + + self.sessionConfiguration = configuration; + + self.operationQueue = [[NSOperationQueue alloc] init]; + self.operationQueue.maxConcurrentOperationCount = 1; + + self.session = [NSURLSession sessionWithConfiguration:self.sessionConfiguration delegate:self delegateQueue:self.operationQueue]; + + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + + self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; + + self.mutableTaskDelegatesKeyedByTaskIdentifier = [[NSMutableDictionary alloc] init]; + + self.lock = [[NSLock alloc] init]; + self.lock.name = AFURLSessionManagerLockName; + + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + for (NSURLSessionDataTask *task in dataTasks) { + [self addDelegateForDataTask:task completionHandler:nil]; + } + + for (NSURLSessionUploadTask *uploadTask in uploadTasks) { + [self addDelegateForUploadTask:uploadTask progress:nil completionHandler:nil]; + } + + for (NSURLSessionDownloadTask *downloadTask in downloadTasks) { + [self addDelegateForDownloadTask:downloadTask progress:nil destination:nil completionHandler:nil]; + } + }]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidResume:) name:AFNSURLSessionTaskDidResumeNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidSuspend:) name:AFNSURLSessionTaskDidSuspendNotification object:nil]; + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +#pragma mark - + +- (NSString *)taskDescriptionForSessionTasks { + return [NSString stringWithFormat:@"%p", self]; +} + +- (void)taskDidResume:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task respondsToSelector:@selector(taskDescription)]) { + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidResumeNotification object:task]; + }); + } + } +} + +- (void)taskDidSuspend:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task respondsToSelector:@selector(taskDescription)]) { + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidSuspendNotification object:task]; + }); + } + } +} + +#pragma mark - + +- (AFURLSessionManagerTaskDelegate *)delegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + AFURLSessionManagerTaskDelegate *delegate = nil; + [self.lock lock]; + delegate = self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)]; + [self.lock unlock]; + + return delegate; +} + +- (void)setDelegate:(AFURLSessionManagerTaskDelegate *)delegate + forTask:(NSURLSessionTask *)task +{ + NSParameterAssert(task); + NSParameterAssert(delegate); + + [self.lock lock]; + self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)] = delegate; + [self.lock unlock]; +} + +- (void)addDelegateForDataTask:(NSURLSessionDataTask *)dataTask + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + dataTask.taskDescription = self.taskDescriptionForSessionTasks; + [self setDelegate:delegate forTask:dataTask]; +} + +- (void)addDelegateForUploadTask:(NSURLSessionUploadTask *)uploadTask + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + int64_t totalUnitCount = uploadTask.countOfBytesExpectedToSend; + if(totalUnitCount == NSURLSessionTransferSizeUnknown) { + NSString *contentLength = [uploadTask.originalRequest valueForHTTPHeaderField:@"Content-Length"]; + if(contentLength) { + totalUnitCount = (int64_t)[contentLength longLongValue]; + } + } + + if (delegate.progress) { + delegate.progress.totalUnitCount = totalUnitCount; + } else { + delegate.progress = [NSProgress progressWithTotalUnitCount:totalUnitCount]; + } + + delegate.progress.pausingHandler = ^{ + [uploadTask suspend]; + }; + delegate.progress.cancellationHandler = ^{ + [uploadTask cancel]; + }; + + if (progress) { + *progress = delegate.progress; + } + + uploadTask.taskDescription = self.taskDescriptionForSessionTasks; + + [self setDelegate:delegate forTask:uploadTask]; +} + +- (void)addDelegateForDownloadTask:(NSURLSessionDownloadTask *)downloadTask + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + if (destination) { + delegate.downloadTaskDidFinishDownloading = ^NSURL * (NSURLSession * __unused session, NSURLSessionDownloadTask *task, NSURL *location) { + return destination(location, task.response); + }; + } + + if (progress) { + *progress = delegate.progress; + } + + downloadTask.taskDescription = self.taskDescriptionForSessionTasks; + + [self setDelegate:delegate forTask:downloadTask]; +} + +- (void)removeDelegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + [self.lock lock]; + [self.mutableTaskDelegatesKeyedByTaskIdentifier removeObjectForKey:@(task.taskIdentifier)]; + [self.lock unlock]; +} + +- (void)removeAllDelegates { + [self.lock lock]; + [self.mutableTaskDelegatesKeyedByTaskIdentifier removeAllObjects]; + [self.lock unlock]; +} + +#pragma mark - + +- (NSArray *)tasksForKeyPath:(NSString *)keyPath { + __block NSArray *tasks = nil; + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(dataTasks))]) { + tasks = dataTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(uploadTasks))]) { + tasks = uploadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(downloadTasks))]) { + tasks = downloadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(tasks))]) { + tasks = [@[dataTasks, uploadTasks, downloadTasks] valueForKeyPath:@"@unionOfArrays.self"]; + } + + dispatch_semaphore_signal(semaphore); + }]; + + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); + + return tasks; +} + +- (NSArray *)tasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)dataTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)uploadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)downloadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +#pragma mark - + +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks { + dispatch_async(dispatch_get_main_queue(), ^{ + if (cancelPendingTasks) { + [self.session invalidateAndCancel]; + } else { + [self.session finishTasksAndInvalidate]; + } + }); +} + +#pragma mark - + +- (void)setResponseSerializer:(id )responseSerializer { + NSParameterAssert(responseSerializer); + + _responseSerializer = responseSerializer; +} + +#pragma mark - + +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionDataTask *dataTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + dataTask = [self.session dataTaskWithRequest:request]; + }); + + [self addDelegateForDataTask:dataTask completionHandler:completionHandler]; + + return dataTask; +} + +#pragma mark - + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; + }); + + if (!uploadTask && self.attemptsToRecreateUploadTasksForBackgroundSessions && self.session.configuration.identifier) { + for (NSUInteger attempts = 0; !uploadTask && attempts < AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask; attempts++) { + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; + } + } + + [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(NSData *)bodyData + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + uploadTask = [self.session uploadTaskWithRequest:request fromData:bodyData]; + }); + + [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + uploadTask = [self.session uploadTaskWithStreamedRequest:request]; + }); + + [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; + + return uploadTask; +} + +#pragma mark - + +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + __block NSURLSessionDownloadTask *downloadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + downloadTask = [self.session downloadTaskWithRequest:request]; + }); + + [self addDelegateForDownloadTask:downloadTask progress:progress destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + __block NSURLSessionDownloadTask *downloadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + downloadTask = [self.session downloadTaskWithResumeData:resumeData]; + }); + + [self addDelegateForDownloadTask:downloadTask progress:progress destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +#pragma mark - + +- (NSProgress *)uploadProgressForTask:(NSURLSessionUploadTask *)uploadTask { + return [[self delegateForTask:uploadTask] progress]; +} + +- (NSProgress *)downloadProgressForTask:(NSURLSessionDownloadTask *)downloadTask { + return [[self delegateForTask:downloadTask] progress]; +} + +#pragma mark - + +- (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block { + self.sessionDidBecomeInvalid = block; +} + +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { + self.sessionDidReceiveAuthenticationChallenge = block; +} + +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block { + self.didFinishEventsForBackgroundURLSession = block; +} + +#pragma mark - + +- (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block { + self.taskNeedNewBodyStream = block; +} + +- (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block { + self.taskWillPerformHTTPRedirection = block; +} + +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { + self.taskDidReceiveAuthenticationChallenge = block; +} + +- (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block { + self.taskDidSendBodyData = block; +} + +- (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block { + self.taskDidComplete = block; +} + +#pragma mark - + +- (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block { + self.dataTaskDidReceiveResponse = block; +} + +- (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block { + self.dataTaskDidBecomeDownloadTask = block; +} + +- (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block { + self.dataTaskDidReceiveData = block; +} + +- (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block { + self.dataTaskWillCacheResponse = block; +} + +#pragma mark - + +- (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block { + self.downloadTaskDidFinishDownloading = block; +} + +- (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block { + self.downloadTaskDidWriteData = block; +} + +- (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block { + self.downloadTaskDidResume = block; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, self.session, self.operationQueue]; +} + +- (BOOL)respondsToSelector:(SEL)selector { + if (selector == @selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)) { + return self.taskWillPerformHTTPRedirection != nil; + } else if (selector == @selector(URLSession:dataTask:didReceiveResponse:completionHandler:)) { + return self.dataTaskDidReceiveResponse != nil; + } else if (selector == @selector(URLSession:dataTask:willCacheResponse:completionHandler:)) { + return self.dataTaskWillCacheResponse != nil; + } else if (selector == @selector(URLSessionDidFinishEventsForBackgroundURLSession:)) { + return self.didFinishEventsForBackgroundURLSession != nil; + } + + return [[self class] instancesRespondToSelector:selector]; +} + +#pragma mark - NSURLSessionDelegate + +- (void)URLSession:(NSURLSession *)session +didBecomeInvalidWithError:(NSError *)error +{ + if (self.sessionDidBecomeInvalid) { + self.sessionDidBecomeInvalid(session, error); + } + + [self removeAllDelegates]; + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDidInvalidateNotification object:session]; +} + +- (void)URLSession:(NSURLSession *)session +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; + __block NSURLCredential *credential = nil; + + if (self.sessionDidReceiveAuthenticationChallenge) { + disposition = self.sessionDidReceiveAuthenticationChallenge(session, challenge, &credential); + } else { + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + if (credential) { + disposition = NSURLSessionAuthChallengeUseCredential; + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } else { + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; + } + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +willPerformHTTPRedirection:(NSHTTPURLResponse *)response + newRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLRequest *))completionHandler +{ + NSURLRequest *redirectRequest = request; + + if (self.taskWillPerformHTTPRedirection) { + redirectRequest = self.taskWillPerformHTTPRedirection(session, task, response, request); + } + + if (completionHandler) { + completionHandler(redirectRequest); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; + __block NSURLCredential *credential = nil; + + if (self.taskDidReceiveAuthenticationChallenge) { + disposition = self.taskDidReceiveAuthenticationChallenge(session, task, challenge, &credential); + } else { + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + disposition = NSURLSessionAuthChallengeUseCredential; + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + } else { + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; + } + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + needNewBodyStream:(void (^)(NSInputStream *bodyStream))completionHandler +{ + NSInputStream *inputStream = nil; + + if (self.taskNeedNewBodyStream) { + inputStream = self.taskNeedNewBodyStream(session, task); + } else if (task.originalRequest.HTTPBodyStream && [task.originalRequest.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { + inputStream = [task.originalRequest.HTTPBodyStream copy]; + } + + if (completionHandler) { + completionHandler(inputStream); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + didSendBodyData:(int64_t)bytesSent + totalBytesSent:(int64_t)totalBytesSent +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend +{ + + int64_t totalUnitCount = totalBytesExpectedToSend; + if(totalUnitCount == NSURLSessionTransferSizeUnknown) { + NSString *contentLength = [task.originalRequest valueForHTTPHeaderField:@"Content-Length"]; + if(contentLength) { + totalUnitCount = (int64_t) [contentLength longLongValue]; + } + } + + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + [delegate URLSession:session task:task didSendBodyData:bytesSent totalBytesSent:totalBytesSent totalBytesExpectedToSend:totalUnitCount]; + + if (self.taskDidSendBodyData) { + self.taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalUnitCount); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + + // delegate may be nil when completing a task in the background + if (delegate) { + [delegate URLSession:session task:task didCompleteWithError:error]; + + [self removeDelegateForTask:task]; + } + + if (self.taskDidComplete) { + self.taskDidComplete(session, task, error); + } + +} + +#pragma mark - NSURLSessionDataDelegate + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didReceiveResponse:(NSURLResponse *)response + completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler +{ + NSURLSessionResponseDisposition disposition = NSURLSessionResponseAllow; + + if (self.dataTaskDidReceiveResponse) { + disposition = self.dataTaskDidReceiveResponse(session, dataTask, response); + } + + if (completionHandler) { + completionHandler(disposition); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + if (delegate) { + [self removeDelegateForTask:dataTask]; + [self setDelegate:delegate forTask:downloadTask]; + } + + if (self.dataTaskDidBecomeDownloadTask) { + self.dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + [delegate URLSession:session dataTask:dataTask didReceiveData:data]; + + if (self.dataTaskDidReceiveData) { + self.dataTaskDidReceiveData(session, dataTask, data); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + willCacheResponse:(NSCachedURLResponse *)proposedResponse + completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler +{ + NSCachedURLResponse *cachedResponse = proposedResponse; + + if (self.dataTaskWillCacheResponse) { + cachedResponse = self.dataTaskWillCacheResponse(session, dataTask, proposedResponse); + } + + if (completionHandler) { + completionHandler(cachedResponse); + } +} + +- (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session { + if (self.didFinishEventsForBackgroundURLSession) { + dispatch_async(dispatch_get_main_queue(), ^{ + self.didFinishEventsForBackgroundURLSession(session); + }); + } +} + +#pragma mark - NSURLSessionDownloadDelegate + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + if (self.downloadTaskDidFinishDownloading) { + NSURL *fileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (fileURL) { + delegate.downloadFileURL = fileURL; + NSError *error = nil; + [[NSFileManager defaultManager] moveItemAtURL:location toURL:fileURL error:&error]; + if (error) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:error.userInfo]; + } + + return; + } + } + + if (delegate) { + [delegate URLSession:session downloadTask:downloadTask didFinishDownloadingToURL:location]; + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didWriteData:(int64_t)bytesWritten + totalBytesWritten:(int64_t)totalBytesWritten +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + [delegate URLSession:session downloadTask:downloadTask didWriteData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite]; + + if (self.downloadTaskDidWriteData) { + self.downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didResumeAtOffset:(int64_t)fileOffset +expectedTotalBytes:(int64_t)expectedTotalBytes +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + [delegate URLSession:session downloadTask:downloadTask didResumeAtOffset:fileOffset expectedTotalBytes:expectedTotalBytes]; + + if (self.downloadTaskDidResume) { + self.downloadTaskDidResume(session, downloadTask, fileOffset, expectedTotalBytes); + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + + self = [self initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + return [[[self class] allocWithZone:zone] initWithSessionConfiguration:self.session.configuration]; +} + +@end + +#endif diff --git a/AFNetworking-master/CHANGES b/AFNetworking-master/CHANGES new file mode 100755 index 0000000..571b83f --- /dev/null +++ b/AFNetworking-master/CHANGES @@ -0,0 +1,1673 @@ += 2.5.3 (2015-04-20) + +(See https://github.com/AFNetworking/AFNetworking/releases/tag/2.5.3) + += 2.5.2 (2015-03-26) + +(See https://github.com/AFNetworking/AFNetworking/releases/tag/2.5.2) + += 2.5.1 (2015-02-09) + + * Add `NS_DESIGNATED_INITIALIZER` macros. (Samir Guerdah) + + * Fix and clarify documentation for `stringEncoding` property. (Mattt +Thompson) + + * Fix for NSProgress bug where two child NSProgress instances are added to a +parent NSProgress. (Edward Povazan) + + * Fix incorrect file names in headers. (Steven Fisher) + + * Fix KVO issue when running testing target caused by lack of +`automaticallyNotifiesObserversForKey:` implementation. (Mattt Thompson) + + * Fix use of variable arguments for UIAlertView category. (Kenta Tokumoto) + + * Fix `genstrings` warning for `NSLocalizedString` usage in +`UIAlertView+AFNetworking`. (Adar Porat) + + * Fix `NSURLSessionManager` task observation for network activity indicator +manager. (Phil Tang) + + * Fix `UIButton` category method caching of background image (Fernanda G. +Geraissate) + + * Fix `UIButton` category method failure handling. (Maxim Zabelin) + + * Update multipart upload method requirements to ensure `request.HTTPBody` +is non-nil. (Mattt Thompson) + + * Update to use builtin `__Require` macros from AssertMacros.h. (Cédric +Luthi) + + * Update `parameters` parameter to accept `id` for custom serialization +block. (@mooosu) + += 2.5.0 (2014-11-17) + + * Add documentation for expected background session manager usage (Aaron +Brager) + + * Add missing documentation for `AFJSONRequestSerializer` and +`AFPropertyListSerializer` (Mattt Thompson) + + * Add tests for requesting HTTPS endpoints (Mattt Thompson) + + * Add `init` method declarations of `AFURLResponseSerialization` classes for +Swift compatibility (Allen Rohner) + + * Change default User-Agent to use the version number instead of the build +number (Tim Watson) + + * Change `validatesDomainName` to readonly property (Mattt Thompson, Brian +King) + + * Fix checks when observing `AFHTTPRequestSerializerObservedKeyPaths` (Jacek +Suliga) + + * Fix crash caused by attempting to set nil `NSURLResponse -URL` as key for +`userInfo` dictionary (Elvis Nuñez) + + * Fix crash for multipart streaming requests in XPC services (Mattt Thompson) + + * Fix minor aspects of response serializer documentation (Mattt Thompson) + + * Fix potential race condition for `AFURLConnectionOperation -description` + + * Fix widespread crash related to key-value observing of `NSURLSessionTask +-state` (Phil Tang) + + * Fix `UIButton` category associated object keys (Kristian Bauer, Mattt +Thompson) + + * Remove `charset` parameter from Content-Type HTTP header field values for +`AFJSONRequestSerializer` and `AFPropertyListSerializer` (Mattt Thompson) + + * Update CocoaDocs color scheme (@Orta) + + * Update Podfile to explicitly define sources (Kyle Fuller) + + * Update to relay `downloadFileURL` to the delegate if the manager picks a +`fileURL` (Brian King) + + * Update `AFSSLPinningModeNone` to not validate domain name (Brian King) + + * Update `UIButton` category to cache images in `sharedImageCache` (John +Bushnell) + + * Update `UIRefreshControl` category to set control state to current state +of request (Elvis Nuñez) + += 2.4.1 (2014-09-04) + + * Fix compiler warning generated on 32-bit architectures (John C. Daub) + + * Fix potential crash caused by failed validation with nil responseData + (Mattt Thompson) + + * Fix to suppress compiler warnings for out-of-range enumerated type + value assignment (Mattt Thompson) + += 2.4.0 (2014-09-03) + + * Add CocoaDocs color scheme (Orta) + + * Add image cache to `UIButton` category (Kristian Bauer, Mattt Thompson) + + * Add test for success block on 204 response (Mattt Thompson) + + * Add tests for encodable and re-encodable query string parameters (Mattt +Thompson) + + * Add `AFHTTPRequestSerializer -valueForHTTPHeaderField:` (Kyle Fuller) + + * Add `AFNetworkingOperationFailingURLResponseDataErrorKey` key to user info +of serialization error (Yannick Heinrich) + + * Add `imageResponseSerializer` property to `UIButton` category (Kristian +Bauer, Mattt Thompson) + + * Add `removesKeysWithNullValues` setting to serialization and copying (Jon +Shier) + + * Change request and response serialization tests to be factored out into +separate files (Mattt Thompson) + + * Change signature of success parameters in `UIButton` category methods to +match those in `UIImageView` (Mattt Thompson) + + * Change to remove charset parameter from +`application/x-www-form-urlencoded` content type (Mattt Thompson) + + * Change `AFImageCache` to conform to `NSObject` protocol ( Marcelo Fabri) + + * Change `AFMaximumNumberOfToRecreateBackgroundSessionUploadTask` to +`AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask` (Mattt +Thompson) + + * Fix documentation error for NSSecureCoding (Robert Ryan) + + * Fix documentation for `URLSessionDidFinishEventsForBackgroundURLSession` +delegate method (Mattt Thompson) + + * Fix expired ADN certificate in example project (Carson McDonald) + + * Fix for interoperability within Swift project (Stephan Krusche) + + * Fix for potential deadlock due to KVO subscriptions within a lock +(Alexander Skvortsov) + + * Fix iOS 7 bug where session tasks can have duplicate identifiers if +created from different threads (Mattt Thompson) + + * Fix iOS 8 bug by adding explicit synthesis for `delegate` of +`AFMultipartBodyStream` (Mattt Thompson) + + * Fix issue caused by passing `nil` as body of multipart form part (Mattt +Thompson) + + * Fix issue caused by passing `nil` as destination in download task method +(Mattt Thompson) + + * Fix issue with `AFHTTPRequestSerializer` returning a request and silently +handling an error from a `queryStringSerialization` block (Kyle Fuller, Mattt +Thompson) + + * Fix potential issues by ensuring `invalidateSessionCancelingTasks` only +executes on main thread (Mattt Thompson) + + * Fix potential memory leak caused by deferred opening of output stream +(James Tomson) + + * Fix properties on session managers such that default values will not trump +values set in the session configuration (Mattt Thompson) + + * Fix README to include explicit call to start reachability manager (Mattt +Thompson) + + * Fix request serialization error handling in `AFHTTPSessionManager` +convenience methods (Kyle Fuller, Lars Anderson, Mattt Thompson) + + * Fix stray localization macro (Devin McKaskle) + + * Fix to ensure connection operation `-copyWithZone:` calls super +implementation (Chris Streeter) + + * Fix `UIButton` category to only cancel request for specified state +(@xuzhe, Mattt Thompson) + += 2.3.1 (2014-06-13) + + * Fix issue with unsynthesized `streamStatus` & `streamError` properties +on `AFMultipartBodyStream` (Mattt Thompson) + += 2.3.0 (2014-06-11) + + * Add check for `AF_APP_EXTENSIONS` macro to conditionally compile +background method that makes API call unavailable to App Extensions in iOS 8 +/ OS X 10.10 + + * Add further explanation for network reachability in documentation (Steven +Fisher) + + * Add notification for initial change from +`AFNetworkReachabilityStatusUnknown` to any other state (Jason Pepas, +Sebastian S.A., Mattt Thompson) + + * Add tests for AFNetworkActivityIndicatorManager (Dave Weston, Mattt +Thompson) + + * Add tests for AFURLSessionManager task progress (Ullrich Schäfer) + + * Add `attemptsToRecreateUploadTasksForBackgroundSessions` property, which +attempts Apple's recommendation of retrying a failed upload task if initial +creation did not succeed (Mattt Thompson) + + * Add `completionQueue` and `completionGroup` properties to +`AFHTTPRequestOperationManager` (Robert Ryan) + + * Change deprecating `AFErrorDomain` in favor of +`AFRequestSerializerErrorDomain` & `AFResponseSerializerErrorDomain` (Mattt +Thompson) + + * Change serialization tests to be split over two different files (Mattt +Thompson) + + * Change to make NSURLSession subspec not depend on NSURLConnection subspec +(Mattt Thompson) + + * Change to make Serialization subspec not depend on NSURLConnection subspec +(Nolan Waite, Mattt Thompson) + + * Change `completionHandler` of +`application:handleEventsForBackgroundURLSession:completion:` to be run on +main thread (Padraig Kennedy) + + * Change `UIImageView` category to accept any object conforming to +`AFURLResponseSerialization`, rather than just `AFImageResponseSerializer` +(Romans Karpelcevs) + + * Fix calculation and behavior of `NSProgress` (Padraig Kennedy, Ullrich +Schäfer) + + * Fix deprecation warning for `backgroundSessionConfiguration:` in iOS 8 / +OS X 10.10 (Mattt Thompson) + + * Fix implementation of `copyWithZone:` in serializer subclasses (Chris +Streeter) + + * Fix issue in Xcode 6 caused by implicit synthesis of overridden `NSStream` +properties (Clay Bridges, Johan Attali) + + * Fix KVO handling for `NSURLSessionTask` on iOS 8 / OS X 10.10 (Mattt +Thompson) + + * Fix KVO leak for `NSURLSessionTask` (@Zyphrax) + + * Fix potential crash caused by attempting to use non-existent error of +failing requests due to URLs exceeding a certain length (Boris Bügling) + + * Fix to check existence of `uploadProgress` block inside a referencing +`dispatch_async` to avoid potential race condition (Kyungkoo Kang) + + * Fix `UIImageView` category race conditions (Sunny) + + * Remove unnecessary default operation response serializer setters (Mattt +Thompson) + += 2.2.4 (2014-05-13) + + * Add NSSecureCoding support to all AFNetworking classes (Kyle Fuller, Mattt +Thompson) + + * Change behavior of request operation `NSOutputStream` property to only nil +out if `responseData` is non-nil, meaning that no custom object was set +(Mattt Thompson) + + * Fix data tasks to not attempt to track progress, and rare related crash +(Padraig Kennedy) + + * Fix issue with `-downloadTaskDidFinishDownloading:` not being called +(Andrej Mihajlov) + + * Fix KVO leak on invalidated session tasks (Mattt Thompson) + + * Fix missing import of `UIRefreshControl+AFNetworking" (@BB9z) + + * Fix potential compilation errors on Mac OS X, caused by import order of +``, which signaled an incorrect deprecation warning (Mattt +Thompson) + + * Fix race condition in UIImageView+AFNetworking when making several image +requests in quick succession (Alexander Crettenand) + + * Update documentation for `-downloadTaskWithRequest:` to warn about blocks +being disassociated on app termination and backgrounding (Robert Ryan) + += 2.2.3 (2014-04-18) + + * Fix `AFErrorOrUnderlyingErrorHasCodeInDomain` function declaration for +AFXMLDocumentResponseSerializer (Mattt Thompson) + + * Fix error domain check in `AFErrorOrUnderlyingErrorHasCodeInDomain` +(Mattt Thompson) + + * Fix `UIImageView` category to only `nil` out request operation properties +belonging to completed request (Mattt Thompson) + + * Fix `removesKeysWithNullValues` to respect +`NSJSONReadingMutableContainers` option (Mattt Thompson) + + * Change `removesKeysWithNullValues` property to recursively remove null +values from dictionaries nested in arrays (@jldagon) + + * Change to not override `Content-Type` header field values set by +`HTTPRequestHeaders` property (Aaron Brager, Mattt Thompson) + += 2.2.2 (2014-04-15) + + * Add `removesKeysWithNullValues` property to `AFJSONResponsSerializer` to +automatically remove `NSNull` values in dictionaries serialized from JSON +(Mattt Thompson) + + * Add unit test for checking content type (Diego Torres) + + * Add `boundary` property to `AFHTTPBodyPart -copyWithZone:` + + * Change to accept `id` parameter type in HTTP manager convenience methods +(Mattt Thompson) + + * Change to deprecate `setAuthorizationHeaderFieldWithToken:`, in favor of +users specifying an `Authorization` header field value themselves (Mattt +Thompson) + + * Change to use `long long` type to prevent a difference in stream size +caps on 32-bit and 64-bit architectures (Yung-Luen Lan, Cédric Luthi) + + * Fix calculation of Content-Length in `taskDidSendBodyData` (Christos +Vasilakis) + + * Fix for comparison of image view request operations (Mattt Thompson) + + * Fix for SSL certificate validation to check status codes at runtime (Dave +Anderson) + + * Fix to add missing call to delegate in +`URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:` + + * Fix to call `taskDidComplete` if delegate is missing (Jeff Ward) + + * Fix to implement `respondsToSelector:` for `NSURLSession` delegate +methods to conditionally respond to conditionally respond to optional +selectors if and only if a custom block has been set (Mattt Thompson) + + * Fix to prevent illegal state values from being assigned for +`AFURLConnectionOperation` (Kyle Fuller) + + * Fix to re-establish `AFNetworkingURLSessionTaskDelegate` objects after +restoring from a background configuration (Jeff Ward) + + * Fix to reduce memory footprint by `nil`-ing out request operation +`outputStream` after closing, as well as image view request operation after +setting image (Teun van Run, Mattt Thompson) + + * Remove unnecessary call in class constructor (Bernhard Loibl) + + * Remove unnecessary check for `respondsToSelector:` for `UIScreen scale` +in User-Agent string (Samuel Goodwin) + + * Update App.net certificate and API base URL (Cédric Luthi) + + * Update examples in README (@petard, @orta, Mattt Thompson) + + * Update Travis CI icon to use SVG format (Maximilian Tagher) + += 2.2.1 (2014-03-14) + + * Fix `-Wsign-conversion` warning in AFURLConnectionOperation (Jesse Collis) + + * Fix `-Wshorten-64-to-32` warning (Jesse Collis) + + * Remove unnecessary #imports in `UIImageView` & `UIWebView` categories +(Jesse Collis) + + * Fix call to `CFStringTransform()` by checking return value before setting +as `User-Agent` (Kevin Cassidy Jr) + + * Update `AFJSONResponseSerializer` adding `@autorelease` to relieve memory +pressure (Mattt Thompson, Michal Pietras) + + * Update `AFJSONRequestSerializer` to accept `id` (Daren Desjardins) + + * Fix small documentation bug (@jkoepcke) + + * Fix behavior of SSL pinning. In case of `validatesDomainName == YES`, it +now explicitly uses `SecPolicyCreateSSL`, which also validates the domain +name. Otherwise, `SecPolicyCreateBasicX509` is used. +`AFSSLPinningModeCertificate` now uses `SecTrustSetAnchorCertificates`, which +allows explicit specification of all trusted certificates. For +`AFSSLPinningModePublicKey`, the number of trusted public keys determines if +the server should be trusted. (Oliver Letterer, Eric Allam) + += 2.2.0 (2014-02-25) + + * Add default initializer to make `AFHTTPRequestOperationManager` +consistent with `AFHTTPSessionManager` (Marcelo Fabri) + + * Add documentation about `UIWebView` category and implementing +`UIWebViewDelegate` (Mattt Thompson) + + * Add missing `NSCoding` and `NSCopying` implementations for +`AFJSONRequestSerializer` (Mattt Thompson) + + * Add note about use of `-startMonitoring` in +`AFNetworkReachabilityManager` (Mattt Thompson) + + * Add setter for needsNewBodyStream block (Carmen Cerino) + + * Add support for specifying a response serializer on a per-instance of +`AFURLSessionManagerTaskDelegate` (Blake Watters) + + * Add `AFHTTPRequestSerializer +-requestWithMultipartFormRequest:writingStreamContentsToFile:completionHandler +:` as a workaround for a bug in NSURLSession that removes the Content-Length +header from streamed requests (Mattt Thompson) + + * Add `NSURLRequest` factory properties on `AFHTTPRequestSerializer` (Mattt +Thompson) + + * Add `UIRefreshControl+AFNetworking` (Mattt Thompson) + + * Change example project to enable certificate pinning (JP Simard) + + * Change to allow self-signed certificates (Frederic Jacobs) + + * Change to make `reachabilityManager` property readwrite (Mattt Thompson) + + * Change to sort `NSSet` members during query string parameter +serialization (Mattt Thompson) + + * Change to use case sensitive compare when sorting keys in query string +serialization (Mattt Thompson) + + * Change to use xcpretty instead of xctool for automated testing (Kyle +Fuller, Marin Usalj, Carson McDonald) + + * Change to use `@selector` values as keys for associated objects (Mattt +Thompson) + + * Change `setImageWithURL:placeholder:`, et al. to only set placeholder +image if not `nil` (Alejandro Martinez) + + * Fix auto property synthesis warnings (Oliver Letterer) + + * Fix domain name validation for SSL certificates (Oliver Letterer) + + * Fix issue with session task delegate KVO observation (Kyle Fuller) + + * Fix placement of `baseURL` method declaration (Oliver Letterer) + + * Fix podspec linting error (Ari Braginsky) + + * Fix potential concurrency issues by adding lock around setting +`isFinished` state in `AFURLConnectionOperation` (Mattt Thompson) + + * Fix potential vulnerability caused by hard-coded multipart form data +boundary (Mathias Bynens, Tom Van Goethem, Mattt Thompson) + + * Fix protocol name in #pragma mark declaration (@sevntine) + + * Fix regression causing inflated images to have incorrect orientation +(Mattt Thompson) + + * Fix to `AFURLSessionManager` `NSCoding` implementation, to accommodate +`NSURLSessionConfiguration` no longer conforming to `NSCoding`. + + * Fix Travis CI integration (Kyle Fuller, Marin Usalj, Carson McDonald) + + * Fix various static analyzer warnings (Philippe Casgrain, Jim Young, +Steven Fisher, Mattt Thompson) + + * Fix with download progress calculation of completion units (Kyle Fuller) + + * Fix Xcode 5.1 compiler warnings (Nick Banks) + + * Fix `AFHTTPRequestOperationManager` to default +`shouldUseCredentialStorage` to `YES`, as documented (Mattt Thompson) + + * Remove Unused format property in `AFJSONRequestSerializer` (Mattt +Thompson) + + * Remove unused `acceptablePathExtensions` class method in +`AFJSONRequestSerializer` (Mattt Thompson) + + * Update #ifdef declarations in UIKit categories to be simpler (Mattt +Thompson) + + * Update podspec to includ social_media_url (Kyle Fuller) + + * Update types for 64 bit architecture (Bruno Tortato Furtado, Mattt +Thompson) + += 2.1.0 (2014-01-16) + + * Add CONTRIBUTING (Kyle Fuller) + + * Add domain name verification for SSL certificates (Oliver Letterer) + + * Add leaf certificate checking (Alex Leverington, Carson McDonald, Mattt +Thompson) + + * Add test case for stream failure handling (Kyle Fuller) + + * Add underlying error properties to response serializers to forward errors +to subsequent validation steps (Mattt Thompson) + + * Add `AFImageCache` protocol, to allow for custom image caches to be +specified for `UIImageView` (Mattt Thompson) + + * Add `error` out parameter for request serializer, deprecating existing +request constructor methods (Adam Becevello) + + * Change request serializer protocol to take id type for parameters (Mattt +Thompson) + + * Change to add validation of download task responses (Mattt Thompson) + + * Change to force upload progress, by using original request Content-Length +(Mateusz Malczak) + + * Change to use `NSDictionary` object literals for `NSError` `userInfo` +construction (Mattt Thompson) + + * Fix #pragma declaration to be NSURLConnectionDataDelegate, rather than +NSURLConnectionDelegate (David Paschich) + + * Fix a bug when appending a file part to multipart request from a URL +(Kyle Fuller) + + * Fix analyzer warning about weak receiver being set to nil, capture strong +reference (Stewart Gleadow) + + * Fix appending file part to multipart request to use suggested file name, +rather than temporary one (Kyle Fuller) + + * Fix availability macros for network activity indicator (Mattt Thompson) + + * Fix crash in iOS 6.1 caused by KVO on `isCancelled` property of +`AFURLConnectionOperation` (Sam Page) + + * Fix dead store issues in `AFSecurityPolicy` (Andrew Hershberger) + + * Fix incorrect documentation for `-HTTPRequestOperationWithRequest:...` +(Kyle Fuller) + + * Fix issue in reachability callbacks, where reachability managers created +for a particular domain would initially report no reachability (Mattt +Thompson) + + * Fix logic for handling data task turning into download task (Kyle Fuller) + + * Fix property list response serializer to handle 204 response (Kyle Fuller) + + * Fix README multipart example (Johan Forssell) + + * Fix to add check for non-nil delegate in +`URLSession:didCompleteWithError:` (Kaom Te) + + * Fix to dramatically improve creation of images in +`AFInflatedImageFromResponseWithDataAtScale`, including handling of CMYK, 16 +/ 32 bpc images, and colorspace alpha settings (Robert Ryan) + + * Fix Travis CI integration and unit testing (Kyle Fuller, Carson McDonald) + + * Fix typo in comments (@palringo) + + * Fix UIWebView category to use supplied success callback (Mattt Thompson) + + * Fix various static analyzer warnings (Kyle Fuller, Jesse Collis, Mattt +Thompson) + + * Fix `+batchOfRequestOperations:...` completion block to execute in +`dispatch_async` (Mattt Thompson) + + * Remove synchronous `SCNetworkReachabilityGetFlags` call when initializing +managers, which had the potential to block in certain network conditions +(Yury Korolev, Mattt Thompson) + + * Remove unnecessary check for completionHandler in HTTP manager (Mattt +Thompson) + + * Remove unused conditional clauses (Luka Bratos) + + * Update documentation for `AFCompoundResponseSerializer` (Mattt Thompson) + + * Update httpbin certificates (Carson McDonald) + + * Update notification constant names to be consistent with `NSURLSession` +terminology (Mattt Thompson) + += 2.0.3 (2013-11-18) + + * Fix a bug where `AFURLConnectionOperation -pause` did not correctly reset +the state of `AFURLConnectionOperation`, causing the Network Thread to enter +an infinite loop (Erik Chen) + + * Fix a bug where `AFURLConnectionOperation -cancel` does not set the +appropriate error on the `NSOperation` (Erik Chen) + + * Fix to post `AFNetworkingTaskDidFinishNotification` only on main queue +(Jakub Hladik) + + * Fix issue where the query string serialization block was not used (Kevin +Harwood) + + * Fix project file and repository directory items (Andrew Newdigate) + + * Fix `NSURLSession` subspec (Mattt Thompson) + + * Fix to session task delegate KVO by moving observer removal to +`-didCompleteWithError:` (Mattt Thompson) + + * Add AFNetworking 1.x behavior for image construction in inflation to +ensure correct orientation (Mattt Thompson) + + * Add `NSParameterAssert` for internal task constructors in order to catch +invalid constructions early (Mattt Thompson) + + * Update replacing `NSParameterAssert` with early `nil` return if session +was unable to create a task (Mattt Thompson) + + * Update `AFHTTPRequestOperationManager` and `AFHTTPSessionManager` to use +relative `self class` to create class constructor instances (Bogdan +Poplauschi) + + * Update to break out of loop if output stream does not have space to write +bytes (Mattt Thompson) + + * Update documentation and README with various fixes (Max Goedjen, Mattt +Thompson) + + * Remove unnecessary willChangeValueForKey and didChangeValueForKey method +calls (Mindaugas Vaičiūnas) + + * Remove deletion of all task delegates in +`URLSessionDidFinishEventsForBackgroundURLSession:` (Jeremy Mailen) + + * Remove empty, unused `else` branch (Luka Bratos) + += 2.0.2 (2013-10-29) + + * Add `UIWebView + -loadRequest:MIMEType:textEncodingName:progress:success:failure:` (Mattt + Thompson) + + * Fix iOS 6 compatibility in `AFHTTPSessionManager` & + `UIProgressView+AFNetworking` (Olivier Halligon, Mattt Thompson) + + * Fix issue writing partial data to output stream (Kyle Fuller) + + * Fix behavior for `nil` response in request operations (Marcelo Fabri) + + * Fix implementation of + batchOfRequestOperations:progressBlock:completionBlock: for nil when passed + empty operations parameter (Mattt Thompson) + + * Update `AFHTTPSessionManager` to allow `-init` and `initWithConfig:` to + work (Ben Scheirman) + + * Update `AFRequestOperation` to default to `AFHTTPResponseSerializer` (Jiri + Techet) + + * Update `AFHTTPResponseSerializer` to remove check for nonzero responseData + length (Mattt Thompson) + + * Update `NSCoding` methods to use NSStringFromSelector(@selector()) pattern + instead of `NSString` literals (Mattt Thompson) + + * Update multipart form stream to set Content-Length after setting request + stream (Mattt Thompson) + + * Update documentation with outdated references to `AFHTTPSerializer` (Bruno + Koga) + + * Update documentation and README with various fixes (Jon Chambers, Mattt + Thompson) + + * Update files to remove executable privilege (Kyle Fuller) + += 2.0.1 (2013-10-10) + + * Fix iOS 6 compatibility (Matt Baker, Mattt Thompson) + + * Fix example applications (Sam Soffes, Kyle Fuller) + + * Fix usage of `NSSearchPathForDirectoriesInDomains` in README (Leo Lou) + + * Fix names of exposed private methods `downloadProgress` and +`uploadProgress` (Hermes Pique) + + * Fix initial upload/download task progress updates (Vlas Voloshin) + + * Fix podspec to include `AFNetworking.h` `#import` (@haikusw) + + * Fix request serializers to not override existing header field values with +defaults (Mattt Thompson) + + * Fix unused format string placeholder (Thorsten Lockert) + + * Fix `AFHTTPRequestOperation -initWithCoder:` to call `super` (Josh Avant) + + * Fix `UIProgressView` selector name (Allen Tu) + + * Fix `UIButton` response serializer (Sam Grossberg) + + * Fix `setPinnedCertificates:` and pinned public keys (Kyle Fuller) + + * Fix timing of batched operation completion block (Denys Telezhkin) + + * Fix `GCC_WARN_ABOUT_MISSING_NEWLINE` compiler warning (Chuck Shnider) + + * Fix a format string missing argument issue in tests (Kyle Fuller) + + * Fix location of certificate chain bundle location (Kyle Fuller) + + * Fix memory leaks in AFSecurityPolicyTests (Kyle Fuller) + + * Fix potential concurrency issues in `AFURLSessionManager` by adding locks +around access to mutiple delegates dictionary (Mattt Thompson) + + * Fix unused variable compiler warnings by wrapping `OSStatus` and +`NSCAssert` with NS_BLOCK_ASSERTIONS macro (Mattt Thompson) + + * Fix compound serializer error handling (Mattt Thompson) + + * Fix string encoding for responseString (Juan Enrique) + + * Fix `UIImageView -setBackgroundImageWithRequest:` (Taichiro Yoshida) + + * Fix regressions nested multipart parameters (Mattt Thompson) + + * Add `responseObject` property to `AFHTTPRequestOperation` (Mattt Thompson) + + * Add support for automatic network reachability monitoring for request +operation and session managers (Mattt Thompson) + + * Update documentation and README with various corrections and fixes +(@haikusw, Chris Hellmuth, Dave Caunt, Mattt Thompson) + + * Update default User-Agent such that only ASCII character set is used +(Maximillian Dornseif) + + * Update SSL pinning mode to have default pinned certificates by default +(Kevin Harwood) + + * Update `AFSecurityPolicy` to use default authentication handling unless a +credential exists for the server trust (Mattt Thompson) + + * Update Prefix.pch (Steven Fisher) + + * Update minimum iOS test target to iOS 6 + + * Remove unused protection space block type (Kyle Fuller) + + * Remove unnecessary Podfile.lock (Kyle Fuller) + += 2.0.0 (2013-09-27) + +==================== + += 1.3.4 (2014-04-15) + + * Fix `AFHTTPMultipartBodyStream` to randomly generate form boundary, to +prevent attack based on a known value (Mathias Bynens, Tom Van Goethem, Mattt +Thompson) + + * Fix potential non-terminating loop in `connection:didReceiveData:` (Mattt +Thompson) + + * Fix SSL certificate validation to provide a human readable Warning when +SSL Pinning fails (Maximillian Dornseif) + + * Fix SSL certificate validation to assert that no impossible pinning +configuration exists (Maximillian Dornseif) + + * Fix to check `CFStringTransform()` call for success before using result +(Kevin Cassidy Jr) + + * Fix to prevent unused assertion results with macros (Indragie Karunaratne) + + * Fix to call call `SecTrustEvaluate` before calling +`SecTrustGetCertificateCount` in SSL certificate validation (Josh Chung) + + * Fix to add explicit cast to `NSUInteger` in format string (Alexander +Kempgen) + + * Remove unused variable `kAFStreamToStreamBufferSize` (Alexander Kempgen) + += 1.3.3 (2013-09-25) + + * Add stream error handling to `AFMultipartBodyStream` (Nicolas Bachschmidt, +Mattt Thompson) + + * Add stream error handling to `AFURLConnectionOperation +-connection:didReceiveData:` (Ian Duggan, Mattt Thompson) + + * Fix parameter query string encoding of square brackets according to RFC +3986 (Kra Larivain) + + * Fix AFHTTPBodyPart determination of end of input stream data (Brian Croom) + + * Fix unit test timeouts (Carson McDonald) + + * Fix truncated `User-Agent` header field when app contained non-ASCII +characters (Diego Torres) + + * Fix outdated link in documentation (Jonas Schmid) + + * Fix `AFHTTPRequestOperation` `HTTPError` property to be thread-safe +(Oliver Letterer, Mattt Thompson) + + * Fix API compatibility with iOS 5 (Blake Watters, Mattt Thompson) + + * Fix potential race condition in `AFURLConnectionOperation +-cancelConnection` (@mm-jkolb, Mattt Thompson) + + * Remove implementation of `connection:needNewBodyStream:` delegate method +in `AFURLConnectionOperation`, which fixes stream errors on authentication +challenges (Mattt Thompson) + + * Fix calculation of network reachability from flags (Tracy Pesin, Mattt +Thompson) + + * Update AFHTTPClient documentation to clarify scope of `parameterEncoding` +property (Thomas Catterall) + + * Update `UIImageView` category to allow for nested calls to +`setImageWithURLRequest:` (Philippe Converset) + + * Change `UIImageView` category to accept invalid SSL certificates when +`_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is defined (Flávio Caetano) + + * Change to replace #pragma clang with cast (Cédric Luthi) + += 1.3.2 (2013-08-08) + + * Add return status checks when building list of pinned public keys (Sylvain +Guillope) + + * Add return status checks when handling connection authentication challenges +(Sylvain Guillope) + + * Add tests around `AFHTTPClient initWithBaseURL:` (Kyle Fuller) + + * Change to remove all `_AFNETWORKING_PIN_SSL_CERTIFICATES_` conditional +compilation (Dustin Barker) + + * Change to allow fallback to generic image loading when PNG/JPEG data +provider methods fail (Darryl H. Thomas) + + * Change to only set placeholder image if not `nil` (Mattt Thompson) + + * Change to use `response.MIMEType` rather than (potentially nonexistent) +Content-Type headers to determine image data provider (Mattt Thompson) + + * Fix image request test endpoint (Carson McDonald) + + * Fix compiler warning caused by `size_t` value defaulted to `NULL` (Darryl H. +Thomas) + + * Fix mutable headers property in `AFHTTPClient -copyWithZone:` (Oliver +Letterer) + + * Fix documentation and asset references in README (Romain Pouclet, Peter +Goldsmith) + + * Fix bug in examples always using `AFSSLPinningModeNone` (Dustin Barker) + + * Fix execution of tests under Travis (Blake Watters) + + * Fix static analyzer warnings about CFRelease calls to NULL pointer (Mattt +Thompson) + + * Change to return early in `AFGetMediaTypeAndSubtypeWithString` if string is +`nil` (Mattt Thompson) + + * Change to opimize network thread creation (Mattt Thompson) + += 1.3.1 (2013-06-18) + + * Add `automaticallyInflatesResponseImage` property to +`AFImageRequestOperation`, which when enabled, offers significant performance +improvements for drawing images loaded through `UIImageView+AFNetworking` by +inflating compressed image data in the background (Mattt Thompson, Peter +Steinberger) + + * Add `NSParameterAssert` check for `nil` `urlRequest` parameter in +`AFURLConnectionOperation` initializer (Kyle Fuller) + + * Fix reachability to detect the case where a connection is required but can +be automatically established (Joshua Vickery) + + * Fix to Test target Podfile (Kyle Fuller) + += 1.3.0 (2013-06-01) + + * Change in `AFURLConnectionOperation` `NSURLConnection` authentication +delegate methods and associated block setters. If +`_AFNETWORKING_PIN_SSL_CERTIFICATES_` is defined, +`-setWillSendRequestForAuthenticationChallengeBlock:` will be available, and +`-connection:willSendRequestForAuthenticationChallenge:` will be implemented. +Otherwise, `-setAuthenticationAgainstProtectionSpaceBlock:` & +`-setAuthenticationChallengeBlock:` will be available, and +`-connection:canAuthenticateAgainstProtectionSpace:` & +`-connection:didReceiveAuthenticationChallenge:` will be implemented instead +(Oliver Letterer) + + * Change in AFNetworking podspec to include Security framework (Kevin Harwood, +Oliver Letterer, Sam Soffes) + + * Change in AFHTTPClient to @throw exception when non-designated intializer is +used (Kyle Fuller) + + * Change in behavior of connection:didReceiveAuthenticationChallenge: to not +use URL-encoded credentials, which should already have been applied (@xjdrew) + + * Change to set AFJSONRequestOperation error when unable to decode response +string (Chris Pickslay, Geoff Nix) + + * Change AFURLConnectionOperation to lazily initialize outputStream property +(@fumoboy007) + + * Change instances of (CFStringRef)NSRunLoopCommonModes to +kCFRunLoopCommonModes + + * Change #warning to #pragma message for dynamic framework linking warnings +(@michael_r_may) + + * Add unit testing and continuous integration system (Blake Watters, Oliver +Letterer, Kevin Harwood, Cédric Luthi, Adam Fraser, Carson McDonald, Mattt +Thompson) + + * Fix multipart input stream implementation (Blake Watters, OliverLetterer, +Aleksey Kononov, @mattyohe, @mythodeia, @JD-) + + * Fix implementation of authentication delegate methods (Oliver Letterer, +Kevin Harwood) + + * Fix implementation of AFSSLPinningModePublicKey on Mac OS X (Oliver Letterer) + + * Fix error caused by loading file:// requests with AFHTTPRequestOperation +subclasses (Dave Anderson, Oliver Letterer) + + * Fix threading-related crash in AFNetworkActivityIndicatorManager (Dave Keck) + + * Fix to suppress GNU expression and enum assignment warnings from Clang +(Henrik Hartz) + + * Fix leak caused by CFStringConvertEncodingToIANACharSetName in AFHTTPClient +-requestWithMethod:path:parameters: (Daniel Demiss) + + * Fix missing __bridge casts in AFHTTPClient (@apouche, Mattt Thompson) + + * Fix Objective-C++ compatibility (Audun Holm Ellertsen) + + * Fix to not escape tildes (@joein3d) + + * Fix warnings caused by unsynthesized properties (Jeff Hunter) + + * Fix to network reachability calls to provide correct status on +initialization (@djmadcat, Mattt Thompson) + + * Fix to suppress warnings about implicit signedness conversion (Matt Rubin) + + * Fix AFJSONRequestOperation -responseJSON failing cases (Andrew Vyazovoy, +Mattt Thompson) + + * Fix use of object subscripting to avoid incompatibility with iOS < 6 and OS +X < 10.8 (Paul Melnikow) + + * Various fixes to reverted multipart stream provider implementation (Yaron +Inger, Alex Burgel) + += 1.2.1 (2013-04-18) + + * Add `allowsInvalidSSLCertificate` property to `AFURLConnectionOperation` and +`AFHTTPClient`, replacing `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` macro +(Kevin Harwood) + + * Add SSL pinning mode to example project (Kevin Harwood) + + * Add name to AFNetworking network thread (Peter Steinberger) + + * Change pinned certificates to trust all derived certificates (Oliver +Letterer) + + * Fix documentation about SSL pinning (Kevin Harwood, Mattt Thompson) + + * Fix certain enumerated loops to use fast enumeration, resulting in better +performance (Oliver Letterer) + + * Fix macro to work correctly under Mac OS X 10.7 and iOS 4 SDK (Paul Melnikow) + + * Fix documentation, removing unsupported `@discussion` tags (Michele Titolo) + + * Fix `SecTrustCreateWithCertificates` expecting an array as first argument +(Oliver Letterer) + + * Fix to use `errSecSuccess` instead of `noErr` for Security frameworks +OSStatus (Oliver Letterer) + + * Fix `AFImageRequestOperation` to use `[self alloc]` instead of explicit +class, which allows for subclassing (James Clarke) + + * Fix for `numberOfFinishedOperations` calculations (Rune Madsen) + + * Fix calculation of data length in `-connection:didReceiveData:` +(Jean-Francois Morin) + + * Fix to encode JSON only with UTF-8, following recommendation of +`NSJSONSerialiation` (Sebastian Utz) + += 1.2.0 (2013-03-24) + + * Add `SSLPinningMode` property to `AFHTTPClient` (Oliver Letterer, Kevin +Harwood, Adam Becevello, Dustin Barker, Mattt Thompson) + + * Add single quote ("'"), comma (","), and asterix ("*") to escaped URL +encoding characters (Eric Florenzano, Marc Nijdam, Garrett Murray) + + * Add `credential` property to `AFURLConnectionOperation` (Mattt Thompson) + + * Add `-setDefaultCredential:` to `AFHTTPClient` + + * Add `shouldUseCredentialStorage` property to `AFURLConnectionOperation` +(Mattt Thompson) + + * Add support for repeated key value pairs in `AFHTTPClient` URL query string +(Nick Dawson) + + * Add `AFMultipartFormData - +appendPartWithFileURL:name:fileName:mimeType:error` (Daniel Rodríguez Troitiño) + + * Add `AFMultipartFormData - +appendPartWithInputStream:name:fileName:mimeType:` (@joein3d) + + * Change SSL pinning to be runtime property on `AFURLConnectionOperation` +rather than defined by macro (Oliver Letterer) + + * Change `AFMultipartBodyStream` to `AFMultipartBodyStreamProvider`, vending +one side of a bound CFStream pair rather than subclassing `NSInputStream` (Mike +Ash) + + * Change default `Accept-Language` header in `AFHTTPClient` (@therigu, Mattt +Thompson) + + * Change `AFHTTPClient` operation cancellation to be based on request URL path +rather than absolute URL string (Mattt Thompson) + + * Change request operation subclass processing queues to use +`DISPATCH_QUEUE_CONCURRENT` (Mattt Thompson) + + * Change `UIImageView+AFNetworking` to resolve asymmetry in cached image case +between success block provided and not provided (@Eveets, Mattt Thompson) + + * Change `UIImageView+AFNetworking` to compare `NSURLRequest` instead of +`NSURL` to determine if previous request was equivalent (Cédric Luthi) + + * Change `UIImageView+AFNetworking` to only set image if non-`nil` (Sean +Kovacs) + + * Change indentation settings to four spaces at the project level (Cédric +Luthi) + + * Change `AFNetworkActivityIndicatorManager` to only update if requests have a +non-`nil` URL (Cédric Luthi) + + * Change `UIImageView+AFNetworking` to not do `setHTTPShouldHandleCookies` +(Konstantinos Vaggelakos) + + * Fix request stream exhaustion error on authentication challenges (Alex +Burgel) + + * Fix implementation to use `NSURL` methods instead of `CFURL` functions where +applicable (Cédric Luthi) + + * Fix race condition in `UIImageView+AFNetworking` (Peyman) + + * Fix `responseJSON`, `responseString`, and `responseStringEncoding` to be +threadsafe (Jon Parise, Mattt Thompson) + + * Fix `AFContentTypeForPathExtension` to ensure non-`NULL` content return +value (Zach Waugh) + + * Fix documentation for `appendPartWithFileURL:name:error:` + (Daniel Rodríguez Troitiño) + + * Fix request operation subclass processing queues to initialize with +`dispatch_once` (Sasmito Adibowo) + + * Fix posting of `AFNetworkingOperationDidStartNotification` and +`AFNetworkingOperationDidFinishNotification` to avoid crashes when logging in +response to notifications (Blake Watters) + + * Fix ordering of registered operation consultation in `AFHTTPClient` (Joel +Parsons) + + * Fix warning: multiple methods named 'postNotificationName:object:' found +[-Wstrict-selector-match] (Oliver Jones) + + * Fix warning: multiple methods named 'objectForKey:' found +[-Wstrict-selector-match] (Oliver Jones) + + * Fix warning: weak receiver may be unpredictably set to nil +[-Wreceiver-is-weak] (Oliver Jones) + + * Fix missing #pragma clang diagnostic pop (Steven Fisher) + += 1.1.0 (2012-12-27) + + * Add optional SSL certificate pinning with `#define +_AFNETWORKING_PIN_SSL_CERTIFICATES_` (Dustin Barker) + + * Add `responseStringEncoding` property to `AFURLConnectionOperation` (Mattt +Thompson) + + * Add `userInfo` property to `AFURLConnectionOperation` (Mattt Thompson, +Steven Fisher) + + * Change behavior to cause a failure when an operation is cancelled (Daniel +Tull) + + * Change return type of class constructors to `instancetype` (@guykogus) + + * Change notifications to always being posted on an asynchronously-dispatched +block run on the main queue (Evadne Wu, Mattt Thompson) + + * Change from NSLocalizedString to NSLocalizedStringFromTable with +AFNetworking.strings table for localized strings (Cédric Luthi) + + * Change `-appendPartWithHeaders:body:` to add assertion handler for existence +of body data parameter (Jonathan Beilin) + + * Change `AFHTTPRequestOperation -responseString` to follow guidelines from +RFC 2616 regarding the use of string encoding when none is specified in the +response (Jorge Bernal) + + * Change AFHTTPClient parameter serialization dictionary keys with +`caseInsensitiveCompare:` to ensure + deterministic ordering of query string parameters, which may otherwise + cause ambiguous representations of nested parameters (James Coleman, + Mattt Thompson) + + * Fix -Wstrict-selector-match warnings raised by Xcode 4.6DP3 (Jesse Collis, +Cédric Luthi) + + * Fix NSJSONSerialization crash with Unicode character escapes in JSON +response (Mathijs Kadijk) + + * Fix issue with early return in -startMonitoringNetworkReachability if +network reachability object could not be created (i.e. invalid hostnames) +(Basil Shkara) + + * Fix retain cycles in AFImageRequestOperation.m and AFHTTPClient.m caused by +strong references within blocks (Nick Forge) + + * Fix issue caused by Rails behavior of returning a single space in head :ok +responses, which is interpreted as invalid (Sebastian Ludwig) + + * Fix issue in streaming multipart upload, where final encapsulation boundary +would not be appended if it was larger than the available buffer, causing a +potential timeout (Tomohisa Takaoka, David Kasper) + + * Fix memory leak of network reachability callback block (Mattt Thompson) + + * Fix `-initWithCoder:` for `AFURLConnectionOperation` and `AFHTTPClient` to +cast scalar types (Mattt Thompson) + + * Fix bug in `-enqueueBatchOfHTTPRequestOperations:...` to by using +`addOperations:waitUntilFinished:` instead of adding each operation +individually. (Mattt Thompson) + + * Change `#warning` messages of checks for `CoreServices` and +`MobileCoreServices` to message according to the build target platform (Mattt +Thompson) + + * Change `AFQueryStringFromParametersWithEncoding` to create keys string +representations using the description method as specified in documentation +(Cédric Luthi) + + * Fix __unused keywords for better Xcode indexing (Christian Rasmussen) + + * Fix warning: unused parameter 'x' [-Werror,-Wunused-parameter] (Oliver Jones) + + * Fix warning: property is assumed atomic by default +[-Werror,-Wimplicit-atomic-properties] (Oliver Jones) + + * Fix warning: weak receiver may be unpredictably null in ARC mode +[-Werror,-Wreceiver-is-weak] (Oliver Jones) + + * Fix warning: multiple methods named 'selector' found +[-Werror,-Wstrict-selector-match] (Oliver Jones) + + * Fix warning: 'macro' is not defined, evaluates to 0 (Oliver Jones) + + * Fix warning: atomic by default property 'X' has a user (Oliver Jones)defined +getter (property should be marked 'atomic' if this is intended) [-Werror, +-Wcustom-atomic-properties] (Oliver Jones) + + * Fix warning: 'response' was marked unused but was used +[-Werror,-Wused-but-marked-unused] (Oliver Jones) + + * Fix warning: enumeration value 'AFFinalBoundaryPhase' not explicitly handled +in switch [-Werror,-Wswitch-enum] (Oliver Jones) + += 1.0.1 / 2012-11-01 + + * Fix error in multipart upload streaming, where byte range at boundaries +was not correctly calculated (Stan Chang Khin Boon) + + * If a success block is specified to `UIImageView -setImageWithURLRequest: +placeholderImage:success:failure`:, it is now the responsibility of the +block to set the image of the image view (Mattt Thompson) + + * Add `JSONReadingOptions` property to `AFJSONRequestOperation` (Jeremy + Foo, Mattt Thompson) + + * Using __weak self / __strong self pattern to break retain cycles in + background task and network reachability blocks (Jerry Beers, Dan Weeks) + + * Fix parameter encoding to leave period (`.`) unescaped (Diego Torres) + + * Fixing last file component in multipart form part creation (Sylver + Bruneau) + + * Remove executable permission on AFHTTPClient source files (Andrew + Sardone) + + * Fix warning (error with -Werror) on implicit 64 to 32 conversion (Dan + Weeks) + + * Add GitHub's .gitignore file (Nate Stedman) + + * Updates to README (@ckmcc) + += 1.0 / 2012-10-15 + + * AFNetworking now requires iOS 5 / Mac OSX 10.7 or higher (Mattt Thompson) + + * AFNetworking now uses Automatic Reference Counting (ARC) (Mattt Thompson) + + * AFNetworking raises compiler warnings for missing features when +SystemConfiguration or CoreServices / MobileCoreServices frameworks are not +included in the project and imported in the precompiled headers (Mattt +Thompson) + + * AFNetworking now raises compiler error when not compiled with ARC (Steven +Fisher) + + * Add `NSCoding` and `NSCopying` protocol conformance to +`AFURLConnectionOperation` and `AFHTTPClient` (Mattt Thompson) + + * Add substantial improvements HTTP multipart streaming support, having +files streamed directly from disk and read sequentially from a custom input +stream (Max Lansing, Stan Chang Khin Boon, Mattt Thompson) + + * Add `AFMultipartFormData -throttleBandwidthWithPacketSize:delay:` as +workaround to issues when uploading over 3G (Mattt Thompson) + + * Add request and response to `userInfo` of errors returned from failing +`AFHTTPRequestOperation` (Mattt Thompson) + + * Add `userInfo` dictionary with current status in reachability changes +(Mattt Thompson) + + * Add `Accept` header for image requests in `UIImageView` category (Bratley +Lower) + + * Add explicit declaration of `NSURLConnection` delegate methods so that +they can be overridden in subclasses (Mattt Thompson, Evan Grim) + + * Add parameter validation to match conditions specified in documentation +(Jason Brennan, Mattt Thompson) + + * Add import to `UIKit` to avoid build errors from `UIDevice` references in +`User-Agent` default header (Blake Watters) + + * Remove `AFJSONUtilities` in favor of `NSJSONSerialization` (Mattt Thompson) + + * Remove `extern` declaration of `AFURLEncodedStringFromStringWithEncoding` +function (`CFURLCreateStringByAddingPercentEscapes` should be used instead) +(Mattt Thompson) + + * Remove `setHTTPShouldHandleCookies:NO` from `AFHTTPClient` (@phamsonha, +Mattt Thompson) + + * Remove `dispatch_retain` / `dispatch_release` with ARC in iOS 6 (Benoit +Bourdon) + + * Fix threading issue with `AFNetworkActivityIndicatorManager` (Eric Patey) + + * Fix issue where `AFNetworkActivityIndicatorManager` count could become +negative (@ap4y) + + * Fix properties to explicitly set options to suppress warnings (Wen-Hao +Lue, Mattt Thompson) + + * Fix compiler warning caused by mismatched types in upload / download +progress blocks (Gareth du Plooy, tomas.a) + + * Fix weak / strong variable relationships in `completionBlock` (Peter +Steinberger) + + * Fix string formatting syntax warnings caused by type mismatch (David +Keegan, Steven Fisher, George Cox) + + * Fix minor potential security vulnerability by explicitly using string +format in NSError localizedDescription value in userInfo (Steven Fisher) + + * Fix `AFURLConnectionOperation -pause` by adding state checks to prevent +likely memory issues when resuming (Mattt Thompson) + + * Fix warning caused by miscast of type when +`CLANG_WARN_IMPLICIT_SIGN_CONVERSION` is set (Steven Fisher) + + * Fix incomplete implementation warning in example code (Steven Fisher) + + * Fix warning caused by using `==` comparator on floats (Steven Fisher) + + * Fix iOS 4 bug where file URLs return `NSURLResponse` rather than +`NSHTTPURLResponse` objects (Leo Lobato) + + * Fix calculation of finished operations in batch operation progress +callback (Mattt Thompson) + + * Fix documentation typos (Steven Fisher, Matthias Wessendorf, +jorge@miv.uk.com) + + * Fix `hasAcceptableStatusCode` to return true after a network failure (Tony +Million) + + * Fix warning about missing prototype for private static method (Stephan +Diederich) + + * Fix issue where `nil` content type resulted in unacceptable content type +(Mattt Thompson) + + * Fix bug related to setup and scheduling of output stream (Stephen Tramer) + + * Fix AFContentTypesFromHTTPHeader to correctly handle comma-delimited +content types (Peyman, Mattt Thompson, @jsm174) + + * Fix crash caused by `_networkReachability` not being set to `NULL` after +releasing (Blake Watters) + + * Fix Podspec to correctly import required headers and use ARC (Eloy Durán, +Blake Watters) + + * Fix query string parameter escaping to leave square brackets unescaped +(Mattt Thompson) + + * Fix query string parameter encoding of `NSNull` values (Daniel Rinser) + + * Fix error caused by referencing `__IPHONE_OS_VERSION_MIN_REQUIRED` without +importing `Availability.h` (Blake Watters) + + * Update example to use App.net API, as Twitter shut off its unauthorized +access to the public timeline (Mattt Thompson) + + * Update `AFURLConnectionOperation` to replace `NSAutoReleasePool` with +`@autoreleasepool` (Mattt Thompson) + + * Update `AFHTTPClient` operation queue to specify +`NSOperationQueueDefaultMaxConcurrentOperationCount` rather than +previously-defined constant (Mattt Thompson) + + * Update `AFHTTPClient -initWithBaseURL` to automatically append trailing +slash, so as to fix common issue where default path is not respected without +trailing slash (Steven Fisher) + + * Update default `AFHTTPClient` `User-Agent` header strings (Mattt Thompson, +Steven Fisher) + + * Update icons for iOS example application (Mattt Thompson) + + * Update `numberOfCompletedOperations` variable in progress block to be +renamed to `numberOfFinishedOperations` (Mattt Thompson) + + += 0.10.0 / 2012-06-26 + + * Add Twitter Mac Example application (Mattt Thompson) + + * Add note in README about how to set `-fno-objc-arc` flag for multiple files + at once (Pål Brattberg) + + * Add note in README about 64-bit architecture requirement (@rmuginov, Mattt + Thompson) + + * Add note in `AFNetworkActivityIndicatorManager` about not having to manually + manage animation state (Mattt Thompson) + + * Add missing block parameter name for `imageProcessingBlock` (Francois + Lambert) + + * Add NextiveJson to list of supported JSON libraries (Mattt Thompson) + + * Restore iOS 4.0 compatibility with `addAcceptableStatusCodes:` and + `addAcceptableContentTypes:` (Zachary Waldowski) + + * Update `AFHTTPClient` to use HTTP pipelining for `GET` and `HEAD` requests by + default (Mattt Thompson) + + * Remove @private ivar declaration in headers (Peter Steinberger, Mattt + Thompson) + + * Fix potential premature deallocation of _skippedCharacterSet (Tom Wanielista, + Mattt Thompson) + + * Fix potential issue in `setOutputStream` by closing any existing + `outputStream` (Mattt Thompson) + + * Fix filename in AFHTTPClient header (Steven Fisher) + + * Fix documentation for UIImageView+AFNetworking (Mattt Thompson) + + * Fix HTTP multipart form format, which caused issues with Tornado web server + (Matt Chen) + + * Fix `AFHTTPClient` to not append empty data into multipart form data (Jon + Parise) + + * Fix URL encoding normalization to not conditionally escape percent-encoded + strings (João Prado Maia, Kendall Helmstetter Gelner, @cysp, Mattt Thompson) + + * Fix `AFHTTPClient` documentation reference of + `HTTPRequestOperationWithRequest:success:failure` (Shane Vitarana) + + * Add `AFURLRequestOperation -setRedirectResponseBlock:` (Kevin Harwood) + + * Fix `AFURLConnectionOperation` compilation error by conditionally importing + UIKit framework (Steven Fisher) + + * Fix issue where image processing block is not called correctly with success + block in `AFImageRequestOperation` (Sergey Gavrilyuk) + + * Fix leaked dispatch group in batch operations (@andyegorov, Mattt Thompson) + + * Fix support for non-LLVM compilers in `AFNetworkActivityIndicatorManager` + (Abraham Vegh, Bill Williams, Mattt Thompson) + + * Fix AFHTTPClient to not add unnecessary data when constructing multipart form + request with nil parameters (Taeho Kim) + += 1.0RC1 / 2012-04-25 + + * Add `AFHTTPRequestOperation +addAcceptableStatusCodes / ++addAcceptableContentTypes` to dynamically add acceptable status codes and +content types on the class level (Mattt Thompson) + + * Add support for compound and complex `Accept` headers that include multiple +content types and / or specify a particular character encoding (Mattt Thompson) + + * Add `AFURLConnectionOperation +-setShouldExecuteAsBackgroundTaskWithExpirationHandler:` to have operations +finish once an app becomes inactive (Mattt Thompson) + + * Add support for pausing / resuming request operations (Peter Steinberger, +Mattt Thompson) + + * Improve network reachability functionality in `AFHTTPClient`, including a +distinction between WWan and WiFi reachability (Kevin Harwood, Mattt Thompson) + + += 0.9.2 / 2012-04-25 + + * Add thread safety to `AFNetworkActivityIndicator` (Peter Steinberger, Mattt +Thompson) + + * Document requirement of available JSON libraries for decoding responses in +`AFJSONRequestOperation` and parameter encoding in `AFHTTPClient` (Mattt +Thompson) + + * Fix `AFHTTPClient` parameter encoding (Mattt Thompson) + + * Fix `AFJSONEncode` and `AFJSONDecode` to use `SBJsonWriter` and +`SBJsonParser` instead of `NSObject+SBJson` (Oliver Eikemeier) + + * Fix bug where `AFJSONDecode` does not return errors (Alex Michaud) + + * Fix compiler warning for undeclared +`AFQueryStringComponentFromKeyAndValueWithEncoding` function (Mattt Thompson) + + * Fix cache policy for URL requests (Peter Steinberger) + + * Fix race condition bug in `UIImageView+AFNetworking` caused by incorrectly +nil-ing request operations (John Wu) + + * Fix reload button in Twitter example (Peter Steinberger) + + * Improve batched operation by deferring execution of batch completion block +until all component request completion blocks have finished (Patrick Hernandez, +Kevin Harwood, Mattt Thompson) + + * Improve performance of image request decoding by dispatching to background + queue (Mattt Thompson) + + * Revert `AFImageCache` to cache image objects rather than `NSPurgeableData` +(Tony Million, Peter Steinberger, Mattt Thompson) + + * Remove unnecessary KVO `willChangeValueForKey:` / `didChangeValueForKey:` +calls (Peter Steinberger) + + * Remove unnecessary @private ivar declarations in headers (Peter Steinberger, +Mattt Thompson) + + * Remove @try-@catch block wrapping network thread entry point (Charles T. Ahn) + + += 0.9.1 / 2012-03-19 + + * Create Twitter example application (Mattt Thompson) + + * Add support for nested array and dictionary parameters for query string and +form-encoded requests (Mathieu Hausherr, Josh Chung, Mattt Thompson) + + * Add `AFURLConnectionOperation -setCacheResponseBlock:`, which allows the +behavior of the `NSURLConnectionDelegate` method +`-connection:willCacheResponse:` to be overridden without subclassing (Mattt +Thompson) + + * Add `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` macros for +NSURLConnection authentication delegate methods (Mattt Thompson) + + * Add properties for custom success / failure callback queues (Peter +Steinberger) + + * Add notifications for network reachability changes to `AFHTTPClient` (Mattt +Thompson) + + * Add `AFHTTPClient -patchPath:` convenience method (Mattt Thompson) + + * Add support for NextiveJson (Adrian Kosmaczewski) + + * Improve network reachability checks (C. Bess) + + * Improve NSIndexSet formatting in error strings (Jon Parise) + + * Document crashing behavior in iOS 4 loading a file:// URL (Mattt Thompson) + + * Fix crash caused by `AFHTTPClient -cancelAllHTTPOperationsWithMethod:` not +checking operation to be instance of `AFHTTPRequestOperation` (Mattt Thompson) + + * Fix crash caused by passing `nil` URL in requests (Sam Soffes) + + * Fix errors caused by connection property not being nil'd out after an +operation finishes (Kevin Harwood, @zdzisiekpu) + + * Fix crash caused by passing `NULL` error pointer when setting `NSInvocation` +in `AFJSONEncode` and `AFJSONDecode` (Tyler Stromberg) + + * Fix batch operation completion block returning on background thread (Patrick +Hernandez) + + * Fix documentation for UIImageView+AFNetworking (Dominic Dagradi) + + * Fix race condition caused by `AFURLConnectionOperation` being cancelled on +main thread, rather than network thread (Erik Olsson) + + * Fix `AFURLEncodedStringFromStringWithEncoding` to correctly handle cases +where % is used as a literal rather than as part of a percent escape code +(Mattt Thompson) + + * Fix missing comma in `+defaultAcceptableContentTypes` for +`AFImageRequestOperation` (Michael Schneider) + + += 0.9.0 / 2012-01-23 + + * Add thread-safe behavior to `AFURLConnectionOperation` (Mattt Thompson) + + * Add batching of operations for `AFHTTPClient` (Mattt Thompson) + + * Add authentication challenge callback block to override default + implementation of `connection:didReceiveAuthenticationChallenge:` in + `AFURLConnectionOperation` (Mattt Thompson) + + * Add `_AFNETWORKING_PREFER_NSJSONSERIALIZATION_`, which, when defined, + short-circuits the standard preference ordering used in `AFJSONEncode` and + `AFJSONDecode` to use `NSJSONSerialization` when available, falling back on + third-party-libraries. (Mattt Thompson, Shane Vitarana) + + * Add custom `description` for `AFURLConnectionOperation` and `AFHTTPClient` + (Mattt Thompson) + + * Add `text/javascript` to default acceptable content types for + `AFJSONRequestOperation` (Jake Boxer) + + * Add `imageScale` property to change resolution of images constructed from + cached data (Štěpán Petrů) + + * Add note about third party JSON libraries in README (David Keegan) + + * `AFQueryStringFromParametersWithEncoding` formats `NSArray` values in the + form `key[]=value1&key[]=value2` instead of `key=(value1,value2)` (Dan Thorpe) + + * `AFImageRequestOperation -responseImage` on OS X uses `NSBitmapImageRep` to + determine the correct pixel dimensions of the image (David Keegan) + + * `AFURLConnectionOperation` `connection` has memory management policy `assign` + to avoid retain cycles caused by `NSURLConnection` retaining its delegate + (Mattt Thompson) + + * `AFURLConnectionOperation` calls super implementation for `-isReady`, + following the guidelines for `NSOperation` subclasses (Mattt Thompson) + + * `UIImageView -setImageWithURL:` and related methods call success callback + after setting image (Cameron Boehmer) + + * Cancel request if an authentication challenge has no suitable credentials in + `AFURLConnectionOperation -connection:didReceiveAuthenticationChallenge:` + (Jorge Bernal) + + * Remove exception from + `multipartFormRequestWithMethod:path:parameters:constructing BodyWithBlock:` + raised when certain HTTP methods are used. (Mattt Thompson) + + * Remove `AFImageCache` from public API, moving it into private implementation + of `UIImageView+AFNetworking` (Mattt Thompson) + + * Mac example application makes better use of AppKit technologies and + conventions (Mattt Thompson) + + * Fix issue with multipart form boundaries in `AFHTTPClient + -multipartFormRequestWithMethod:path:parameters:constructing BodyWithBlock:` + (Ray Morgan, Mattt Thompson, Sam Soffes) + + * Fix "File Upload with Progress Callback" code snippet in README (Larry +Legend) + + * Fix to SBJSON invocations in `AFJSONEncode` and `AFJSONDecode` (Matthias + Tretter, James Frye) + + * Fix documentation for `AFHTTPClient requestWithMethod:path:parameters:` + (Michael Parker) + + * Fix `Content-Disposition` headers used for multipart form construction + (Michael Parker) + + * Add network reachability status change callback property to `AFHTTPClient`. + (Mattt Thompson, Kevin Harwood) + + * Fix exception handling in `AFJSONEncode` and `AFJSONDecode` (David Keegan) + + * Fix `NSData` initialization with string in `AFBase64EncodedStringFromString` + (Adam Ernst, Mattt Thompson) + + * Fix error check in `appendPartWithFileURL:name:error:` (Warren Moore, + Baldoph, Mattt Thompson) + + * Fix compiler warnings for certain configurations (Charlie Williams) + + * Fix bug caused by passing zero-length `responseData` to response object + initializers (Mattt Thompson, Serge Paquet) diff --git a/AFNetworking-master/CONTRIBUTING.md b/AFNetworking-master/CONTRIBUTING.md new file mode 100755 index 0000000..5de3be7 --- /dev/null +++ b/AFNetworking-master/CONTRIBUTING.md @@ -0,0 +1,91 @@ +# Contributing Guidelines + +This document contains information and guidelines about contributing to this project. +Please read it before you start participating. + +**Topics** + +* [Asking Questions](#asking-questions) +* [Reporting Security Issues](#reporting-security-issues) +* [Reporting Issues](#reporting-other-issues) +* [Developers Certificate of Origin](#developers-certificate-of-origin) +* [Code of Conduct](#code-of-conduct) + +## Asking Questions + +We don't use GitHub as a support forum. +For any usage questions that are not specific to the project itself, +please ask on [Stack Overflow](https://stackoverflow.com) instead. +By doing so, you'll be more likely to quickly solve your problem, +and you'll allow anyone else with the same question to find the answer. +This also allows maintainers to focus on improving the project for others. + +## Reporting Security Issues + +The Alamofire Software Foundation takes security seriously. +If you discover a security issue, please bring it to our attention right away! + +Please **DO NOT** file a public issue, +instead send your report privately to . +This will help ensure that any vulnerabilities that _are_ found +can be [disclosed responsibly](http://en.wikipedia.org/wiki/Responsible_disclosure) +to any affected parties. + +## Reporting Other Issues + +A great way to contribute to the project +is to send a detailed issue when you encounter an problem. +We always appreciate a well-written, thorough bug report. + +Check that the project issues database +doesn't already include that problem or suggestion before submitting an issue. +If you find a match, add a quick "+1" or "I have this problem too." +Doing this helps prioritize the most common problems and requests. + +When reporting issues, please include the following: + +* The version of Xcode you're using +* The version of iOS or OS X you're targeting +* The full output of any stack trace or compiler error +* A code snippet that reproduces the described behavior, if applicable +* Any other details that would be useful in understanding the problem + +This information will help us review and fix your issue faster. + +## Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +- (a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +- (b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +- (c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +- (d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. + +## Code of Conduct + +The Code of Conduct governs how we behave in public or in private +whenever the project will be judged by our actions. +We expect it to be honored by everyone who contributes to this project. + +See [CONDUCT.md](https://github.com/Alamofire/Foundation/blob/master/CONDUCT.md) for details. + +--- + +*Some of the ideas and wording for the statements above were based on work by the [Docker](https://github.com/docker/docker/blob/master/CONTRIBUTING.md) and [Linux](http://elinux.org/Developer_Certificate_Of_Origin) communities. We commend them for their efforts to facilitate collaboration in their projects.* diff --git a/AFNetworking-master/Example/AFNetworking Example.entitlements b/AFNetworking-master/Example/AFNetworking Example.entitlements new file mode 100755 index 0000000..7a2230d --- /dev/null +++ b/AFNetworking-master/Example/AFNetworking Example.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + com.apple.security.network.server + + + diff --git a/AFNetworking-master/Example/AFNetworking OS X Example.xcodeproj/project.pbxproj b/AFNetworking-master/Example/AFNetworking OS X Example.xcodeproj/project.pbxproj new file mode 100755 index 0000000..0d4635f --- /dev/null +++ b/AFNetworking-master/Example/AFNetworking OS X Example.xcodeproj/project.pbxproj @@ -0,0 +1,403 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 7756506D18037FAB00A437A8 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 7756505918037FAB00A437A8 /* AFHTTPRequestOperation.m */; }; + 7756506E18037FAB00A437A8 /* AFHTTPRequestOperationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7756505B18037FAB00A437A8 /* AFHTTPRequestOperationManager.m */; }; + 7756506F18037FAB00A437A8 /* AFHTTPSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7756505D18037FAB00A437A8 /* AFHTTPSessionManager.m */; }; + 7756507018037FAB00A437A8 /* AFNetworkReachabilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7756506018037FAB00A437A8 /* AFNetworkReachabilityManager.m */; }; + 7756507118037FAB00A437A8 /* AFSecurityPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = 7756506218037FAB00A437A8 /* AFSecurityPolicy.m */; }; + 7756507218037FAB00A437A8 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 7756506418037FAB00A437A8 /* AFURLConnectionOperation.m */; }; + 7756507318037FAB00A437A8 /* AFURLRequestSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 7756506618037FAB00A437A8 /* AFURLRequestSerialization.m */; }; + 7756507418037FAB00A437A8 /* AFURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 7756506818037FAB00A437A8 /* AFURLResponseSerialization.m */; }; + 7756507518037FAB00A437A8 /* AFURLSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7756506A18037FAB00A437A8 /* AFURLSessionManager.m */; }; + B304CCE8177D58DD00F4FC85 /* adn.cer in Resources */ = {isa = PBXBuildFile; fileRef = B304CCE7177D58DD00F4FC85 /* adn.cer */; }; + F8129C001591061B009BFE23 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8129BFF1591061B009BFE23 /* Cocoa.framework */; }; + F8129C321591073C009BFE23 /* AFAppDotNetAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C251591073C009BFE23 /* AFAppDotNetAPIClient.m */; }; + F8129C341591073C009BFE23 /* Post.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C2B1591073C009BFE23 /* Post.m */; }; + F8129C351591073C009BFE23 /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C2D1591073C009BFE23 /* User.m */; }; + F8129C6F15910B15009BFE23 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C6E15910B15009BFE23 /* main.m */; }; + F8129C7115910B3E009BFE23 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F8129C7015910B3E009BFE23 /* MainMenu.xib */; }; + F8129C7715910C40009BFE23 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C7515910C40009BFE23 /* AppDelegate.m */; }; + F88812F216C533E9003C8B8C /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F88812F116C533E9003C8B8C /* Security.framework */; }; + F8A847CF161F55A500940F39 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8A847CE161F55A500940F39 /* CoreServices.framework */; }; + F8A847D2161F55AC00940F39 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8A847D1161F55AC00940F39 /* SystemConfiguration.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 7756505818037FAB00A437A8 /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = ""; }; + 7756505918037FAB00A437A8 /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = ""; }; + 7756505A18037FAB00A437A8 /* AFHTTPRequestOperationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperationManager.h; sourceTree = ""; }; + 7756505B18037FAB00A437A8 /* AFHTTPRequestOperationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperationManager.m; sourceTree = ""; }; + 7756505C18037FAB00A437A8 /* AFHTTPSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPSessionManager.h; sourceTree = ""; }; + 7756505D18037FAB00A437A8 /* AFHTTPSessionManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPSessionManager.m; sourceTree = ""; }; + 7756505E18037FAB00A437A8 /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworking.h; sourceTree = ""; }; + 7756505F18037FAB00A437A8 /* AFNetworkReachabilityManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkReachabilityManager.h; sourceTree = ""; }; + 7756506018037FAB00A437A8 /* AFNetworkReachabilityManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkReachabilityManager.m; sourceTree = ""; }; + 7756506118037FAB00A437A8 /* AFSecurityPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFSecurityPolicy.h; sourceTree = ""; }; + 7756506218037FAB00A437A8 /* AFSecurityPolicy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFSecurityPolicy.m; sourceTree = ""; }; + 7756506318037FAB00A437A8 /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLConnectionOperation.h; sourceTree = ""; }; + 7756506418037FAB00A437A8 /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLConnectionOperation.m; sourceTree = ""; }; + 7756506518037FAB00A437A8 /* AFURLRequestSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLRequestSerialization.h; sourceTree = ""; }; + 7756506618037FAB00A437A8 /* AFURLRequestSerialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLRequestSerialization.m; sourceTree = ""; }; + 7756506718037FAB00A437A8 /* AFURLResponseSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLResponseSerialization.h; sourceTree = ""; }; + 7756506818037FAB00A437A8 /* AFURLResponseSerialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLResponseSerialization.m; sourceTree = ""; }; + 7756506918037FAB00A437A8 /* AFURLSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLSessionManager.h; sourceTree = ""; }; + 7756506A18037FAB00A437A8 /* AFURLSessionManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLSessionManager.m; sourceTree = ""; }; + B304CCE7177D58DD00F4FC85 /* adn.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = adn.cer; sourceTree = SOURCE_ROOT; }; + F8129BFB1591061B009BFE23 /* AFNetworking Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "AFNetworking Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + F8129BFF1591061B009BFE23 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + F8129C021591061B009BFE23 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; + F8129C031591061B009BFE23 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; + F8129C041591061B009BFE23 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + F8129C251591073C009BFE23 /* AFAppDotNetAPIClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFAppDotNetAPIClient.m; path = Classes/AFAppDotNetAPIClient.m; sourceTree = SOURCE_ROOT; }; + F8129C2A1591073C009BFE23 /* Post.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Post.h; sourceTree = ""; }; + F8129C2B1591073C009BFE23 /* Post.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Post.m; sourceTree = ""; }; + F8129C2C1591073C009BFE23 /* User.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = User.h; sourceTree = ""; }; + F8129C2D1591073C009BFE23 /* User.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = User.m; sourceTree = ""; }; + F8129C311591073C009BFE23 /* AFAppDotNetAPIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFAppDotNetAPIClient.h; path = Classes/AFAppDotNetAPIClient.h; sourceTree = SOURCE_ROOT; }; + F8129C6E15910B15009BFE23 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; }; + F8129C7015910B3E009BFE23 /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = SOURCE_ROOT; }; + F8129C7515910C40009BFE23 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; }; + F8129C7615910C40009BFE23 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; }; + F877018B159A1CE700B45C0D /* AFNetworking Example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "AFNetworking Example.entitlements"; sourceTree = ""; }; + F88812F116C533E9003C8B8C /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + F8A847CE161F55A500940F39 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; + F8A847D1161F55AC00940F39 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + F8129BF81591061B009BFE23 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + F88812F216C533E9003C8B8C /* Security.framework in Frameworks */, + F8A847D2161F55AC00940F39 /* SystemConfiguration.framework in Frameworks */, + F8A847CF161F55A500940F39 /* CoreServices.framework in Frameworks */, + F8129C001591061B009BFE23 /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 7756505518037FAB00A437A8 /* AFNetworking */ = { + isa = PBXGroup; + children = ( + 7756505818037FAB00A437A8 /* AFHTTPRequestOperation.h */, + 7756505918037FAB00A437A8 /* AFHTTPRequestOperation.m */, + 7756505A18037FAB00A437A8 /* AFHTTPRequestOperationManager.h */, + 7756505B18037FAB00A437A8 /* AFHTTPRequestOperationManager.m */, + 7756505C18037FAB00A437A8 /* AFHTTPSessionManager.h */, + 7756505D18037FAB00A437A8 /* AFHTTPSessionManager.m */, + 7756505E18037FAB00A437A8 /* AFNetworking.h */, + 7756505F18037FAB00A437A8 /* AFNetworkReachabilityManager.h */, + 7756506018037FAB00A437A8 /* AFNetworkReachabilityManager.m */, + 7756506118037FAB00A437A8 /* AFSecurityPolicy.h */, + 7756506218037FAB00A437A8 /* AFSecurityPolicy.m */, + 7756506318037FAB00A437A8 /* AFURLConnectionOperation.h */, + 7756506418037FAB00A437A8 /* AFURLConnectionOperation.m */, + 7756506518037FAB00A437A8 /* AFURLRequestSerialization.h */, + 7756506618037FAB00A437A8 /* AFURLRequestSerialization.m */, + 7756506718037FAB00A437A8 /* AFURLResponseSerialization.h */, + 7756506818037FAB00A437A8 /* AFURLResponseSerialization.m */, + 7756506918037FAB00A437A8 /* AFURLSessionManager.h */, + 7756506A18037FAB00A437A8 /* AFURLSessionManager.m */, + ); + name = AFNetworking; + path = ../AFNetworking; + sourceTree = ""; + }; + F8129BF01591061B009BFE23 = { + isa = PBXGroup; + children = ( + F88812F116C533E9003C8B8C /* Security.framework */, + F8A847D1161F55AC00940F39 /* SystemConfiguration.framework */, + F8A847CE161F55A500940F39 /* CoreServices.framework */, + F877018B159A1CE700B45C0D /* AFNetworking Example.entitlements */, + F8129C051591061B009BFE23 /* Classes */, + F8129C4C15910901009BFE23 /* Vendor */, + F8129BFE1591061B009BFE23 /* Frameworks */, + F8129BFC1591061B009BFE23 /* Products */, + ); + indentWidth = 4; + sourceTree = ""; + tabWidth = 4; + usesTabs = 0; + }; + F8129BFC1591061B009BFE23 /* Products */ = { + isa = PBXGroup; + children = ( + F8129BFB1591061B009BFE23 /* AFNetworking Example.app */, + ); + name = Products; + sourceTree = ""; + }; + F8129BFE1591061B009BFE23 /* Frameworks */ = { + isa = PBXGroup; + children = ( + F8129BFF1591061B009BFE23 /* Cocoa.framework */, + F8129C011591061B009BFE23 /* Other Frameworks */, + ); + name = Frameworks; + sourceTree = ""; + }; + F8129C011591061B009BFE23 /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + F8129C021591061B009BFE23 /* AppKit.framework */, + F8129C031591061B009BFE23 /* CoreData.framework */, + F8129C041591061B009BFE23 /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + F8129C051591061B009BFE23 /* Classes */ = { + isa = PBXGroup; + children = ( + F8129C311591073C009BFE23 /* AFAppDotNetAPIClient.h */, + F8129C251591073C009BFE23 /* AFAppDotNetAPIClient.m */, + F8129C7615910C40009BFE23 /* AppDelegate.h */, + F8129C7515910C40009BFE23 /* AppDelegate.m */, + F8129C291591073C009BFE23 /* Models */, + F8129C061591061B009BFE23 /* Supporting Files */, + ); + name = Classes; + path = "AFNetworking-Mac-Example"; + sourceTree = ""; + }; + F8129C061591061B009BFE23 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + B304CCE7177D58DD00F4FC85 /* adn.cer */, + F8129C6E15910B15009BFE23 /* main.m */, + F8129C7015910B3E009BFE23 /* MainMenu.xib */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + F8129C291591073C009BFE23 /* Models */ = { + isa = PBXGroup; + children = ( + F8129C2A1591073C009BFE23 /* Post.h */, + F8129C2B1591073C009BFE23 /* Post.m */, + F8129C2C1591073C009BFE23 /* User.h */, + F8129C2D1591073C009BFE23 /* User.m */, + ); + name = Models; + path = Classes/Models; + sourceTree = SOURCE_ROOT; + }; + F8129C4C15910901009BFE23 /* Vendor */ = { + isa = PBXGroup; + children = ( + 7756505518037FAB00A437A8 /* AFNetworking */, + ); + name = Vendor; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + F8129BFA1591061B009BFE23 /* AFNetworking Example */ = { + isa = PBXNativeTarget; + buildConfigurationList = F8129C191591061B009BFE23 /* Build configuration list for PBXNativeTarget "AFNetworking Example" */; + buildPhases = ( + F8129BF71591061B009BFE23 /* Sources */, + F8129BF81591061B009BFE23 /* Frameworks */, + F8129BF91591061B009BFE23 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "AFNetworking Example"; + productName = "AFNetworking-Mac-Example"; + productReference = F8129BFB1591061B009BFE23 /* AFNetworking Example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + F8129BF21591061B009BFE23 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0610; + }; + buildConfigurationList = F8129BF51591061B009BFE23 /* Build configuration list for PBXProject "AFNetworking OS X Example" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = F8129BF01591061B009BFE23; + productRefGroup = F8129BFC1591061B009BFE23 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + F8129BFA1591061B009BFE23 /* AFNetworking Example */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + F8129BF91591061B009BFE23 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F8129C7115910B3E009BFE23 /* MainMenu.xib in Resources */, + B304CCE8177D58DD00F4FC85 /* adn.cer in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + F8129BF71591061B009BFE23 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 7756507218037FAB00A437A8 /* AFURLConnectionOperation.m in Sources */, + 7756506D18037FAB00A437A8 /* AFHTTPRequestOperation.m in Sources */, + 7756507018037FAB00A437A8 /* AFNetworkReachabilityManager.m in Sources */, + 7756507518037FAB00A437A8 /* AFURLSessionManager.m in Sources */, + 7756507318037FAB00A437A8 /* AFURLRequestSerialization.m in Sources */, + F8129C341591073C009BFE23 /* Post.m in Sources */, + 7756507418037FAB00A437A8 /* AFURLResponseSerialization.m in Sources */, + F8129C351591073C009BFE23 /* User.m in Sources */, + F8129C321591073C009BFE23 /* AFAppDotNetAPIClient.m in Sources */, + 7756506E18037FAB00A437A8 /* AFHTTPRequestOperationManager.m in Sources */, + 7756507118037FAB00A437A8 /* AFSecurityPolicy.m in Sources */, + F8129C6F15910B15009BFE23 /* main.m in Sources */, + F8129C7715910C40009BFE23 /* AppDelegate.m in Sources */, + 7756506F18037FAB00A437A8 /* AFHTTPSessionManager.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + F8129C171591061B009BFE23 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + F8129C181591061B009BFE23 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + SDKROOT = macosx; + }; + name = Release; + }; + F8129C1A1591061B009BFE23 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = "AFNetworking Example.entitlements"; + CODE_SIGN_IDENTITY = ""; + COMBINE_HIDPI_IMAGES = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Prefix.pch; + INFOPLIST_FILE = "Mac-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + F8129C1B1591061B009BFE23 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = "AFNetworking Example.entitlements"; + CODE_SIGN_IDENTITY = ""; + COMBINE_HIDPI_IMAGES = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Prefix.pch; + INFOPLIST_FILE = "Mac-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + F8129BF51591061B009BFE23 /* Build configuration list for PBXProject "AFNetworking OS X Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F8129C171591061B009BFE23 /* Debug */, + F8129C181591061B009BFE23 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F8129C191591061B009BFE23 /* Build configuration list for PBXNativeTarget "AFNetworking Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F8129C1A1591061B009BFE23 /* Debug */, + F8129C1B1591061B009BFE23 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = F8129BF21591061B009BFE23 /* Project object */; +} diff --git a/AFNetworking-master/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj b/AFNetworking-master/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj new file mode 100755 index 0000000..9a982d7 --- /dev/null +++ b/AFNetworking-master/Example/AFNetworking iOS Example.xcodeproj/project.pbxproj @@ -0,0 +1,637 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 297F56CA17A9B1AB0014D95C /* AFSecurityPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = 297F56C917A9B1AB0014D95C /* AFSecurityPolicy.m */; }; + 2982AD3217107C0000FFF048 /* adn.cer in Resources */ = {isa = PBXBuildFile; fileRef = 2982AD3117107C0000FFF048 /* adn.cer */; }; + E8C2E7A618970EE40097DCC8 /* root_ca.cer in Resources */ = {isa = PBXBuildFile; fileRef = E8C2E7A418970EE00097DCC8 /* root_ca.cer */; }; + E8C2E7A718970EE40097DCC8 /* digicert_ca_3.cer in Resources */ = {isa = PBXBuildFile; fileRef = E8C2E7A518970EE00097DCC8 /* digicert_ca_3.cer */; }; + F8129C7415910C37009BFE23 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F8129C7215910C37009BFE23 /* AppDelegate.m */; }; + F818101615E6A0C600EF93C2 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ABD6EC159FC2CE001BE42C /* MobileCoreServices.framework */; }; + F8664A2018AA99F5007D8554 /* UIRefreshControl+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8664A1F18AA99F5007D8554 /* UIRefreshControl+AFNetworking.m */; }; + F86A37E0177397D900407E52 /* AFURLSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F86A37DF177397D900407E52 /* AFURLSessionManager.m */; }; + F88812F016C533D6003C8B8C /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469E013957DF100DB05C8 /* Security.framework */; }; + F8A847C1161F51A300940F39 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8A847C0161F51A300940F39 /* Default-568h@2x.png */; }; + F8A847C3161F523E00940F39 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = F8A847C2161F523E00940F39 /* Default.png */; }; + F8A847C5161F524200940F39 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8A847C4161F524200940F39 /* Default@2x.png */; }; + F8B3944D17DBF9B900430F25 /* AFHTTPRequestOperationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F8B3944C17DBF9B900430F25 /* AFHTTPRequestOperationManager.m */; }; + F8CBED2317D595320088ADC0 /* UIAlertView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8CBED2217D595320088ADC0 /* UIAlertView+AFNetworking.m */; }; + F8D0701B14310F4A00653FD3 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469E213957DF700DB05C8 /* SystemConfiguration.framework */; }; + F8D5499A17DB0EF300BFF314 /* AFURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = F8D5499917DB0EF300BFF314 /* AFURLResponseSerialization.m */; }; + F8D5499D17DB0EFE00BFF314 /* AFURLRequestSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = F8D5499C17DB0EFE00BFF314 /* AFURLRequestSerialization.m */; }; + F8D549A017DB1C9100BFF314 /* AFNetworkReachabilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F8D5499F17DB1C9100BFF314 /* AFNetworkReachabilityManager.m */; }; + F8DA09E41396AC040057D0CC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F8DA09E31396AC040057D0CC /* main.m */; }; + F8E02CF7177A8B710087BB23 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E02CEC177A8B710087BB23 /* AFNetworkActivityIndicatorManager.m */; }; + F8E02CF8177A8B710087BB23 /* UIActivityIndicatorView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E02CEE177A8B710087BB23 /* UIActivityIndicatorView+AFNetworking.m */; }; + F8E02CF9177A8B710087BB23 /* UIButton+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E02CF0177A8B710087BB23 /* UIButton+AFNetworking.m */; }; + F8E02CFA177A8B710087BB23 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E02CF2177A8B710087BB23 /* UIImageView+AFNetworking.m */; }; + F8E02CFB177A8B710087BB23 /* UIProgressView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E02CF4177A8B710087BB23 /* UIProgressView+AFNetworking.m */; }; + F8E02CFC177A8B710087BB23 /* UIWebView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E02CF6177A8B710087BB23 /* UIWebView+AFNetworking.m */; }; + F8E469651395739D00DB05C8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469641395739D00DB05C8 /* UIKit.framework */; }; + F8E469671395739D00DB05C8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469661395739D00DB05C8 /* Foundation.framework */; }; + F8E469691395739D00DB05C8 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469681395739D00DB05C8 /* CoreGraphics.framework */; }; + F8E469DF13957DD500DB05C8 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469DE13957DD500DB05C8 /* CoreLocation.framework */; }; + F8F6E8DC1463424800AD016F /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = F8F6E8D81463424800AD016F /* Icon.png */; }; + F8F6E8DD1463424800AD016F /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8F6E8D91463424800AD016F /* Icon@2x.png */; }; + F8FA9491150EF8C100ED4EAD /* AFAppDotNetAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9490150EF8C100ED4EAD /* AFAppDotNetAPIClient.m */; }; + F8FA9494150EF97E00ED4EAD /* Post.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9493150EF97E00ED4EAD /* Post.m */; }; + F8FA9497150EF98800ED4EAD /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9496150EF98800ED4EAD /* User.m */; }; + F8FA949A150EF9DA00ED4EAD /* GlobalTimelineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9499150EF9DA00ED4EAD /* GlobalTimelineViewController.m */; }; + F8FA94B1150EFEC100ED4EAD /* AFHTTPSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA949D150EFEC100ED4EAD /* AFHTTPSessionManager.m */; }; + F8FA94B2150EFEC100ED4EAD /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA949F150EFEC100ED4EAD /* AFHTTPRequestOperation.m */; }; + F8FA94B8150EFEC100ED4EAD /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94AC150EFEC100ED4EAD /* AFURLConnectionOperation.m */; }; + F8FA94C1150F019100ED4EAD /* PostTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94C0150F019100ED4EAD /* PostTableViewCell.m */; }; + F8FA94D0150F094D00ED4EAD /* profile-image-placeholder.png in Resources */ = {isa = PBXBuildFile; fileRef = F8FA94CC150F094D00ED4EAD /* profile-image-placeholder.png */; }; + F8FA94D1150F094D00ED4EAD /* profile-image-placeholder@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8FA94CD150F094D00ED4EAD /* profile-image-placeholder@2x.png */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 297F56C817A9B1AB0014D95C /* AFSecurityPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFSecurityPolicy.h; sourceTree = ""; }; + 297F56C917A9B1AB0014D95C /* AFSecurityPolicy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFSecurityPolicy.m; sourceTree = ""; }; + 2982AD3117107C0000FFF048 /* adn.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = adn.cer; sourceTree = SOURCE_ROOT; }; + 50ABD6EC159FC2CE001BE42C /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; + 55BDA27E17F5A434005DB933 /* UIKit+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIKit+AFNetworking.h"; sourceTree = ""; }; + E8C2E7A418970EE00097DCC8 /* root_ca.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = root_ca.cer; sourceTree = SOURCE_ROOT; }; + E8C2E7A518970EE00097DCC8 /* digicert_ca_3.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = digicert_ca_3.cer; sourceTree = SOURCE_ROOT; }; + F8129C3815910830009BFE23 /* Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = SOURCE_ROOT; }; + F8129C7215910C37009BFE23 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; }; + F8129C7315910C37009BFE23 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; }; + F8664A1E18AA99F5007D8554 /* UIRefreshControl+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIRefreshControl+AFNetworking.h"; sourceTree = ""; }; + F8664A1F18AA99F5007D8554 /* UIRefreshControl+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIRefreshControl+AFNetworking.m"; sourceTree = ""; }; + F86A37DE177397D900407E52 /* AFURLSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLSessionManager.h; sourceTree = ""; }; + F86A37DF177397D900407E52 /* AFURLSessionManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLSessionManager.m; sourceTree = ""; }; + F8A847C0161F51A300940F39 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + F8A847C2161F523E00940F39 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; + F8A847C4161F524200940F39 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + F8B3944B17DBF9B900430F25 /* AFHTTPRequestOperationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperationManager.h; sourceTree = ""; }; + F8B3944C17DBF9B900430F25 /* AFHTTPRequestOperationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperationManager.m; sourceTree = ""; }; + F8CBED2117D595320088ADC0 /* UIAlertView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIAlertView+AFNetworking.h"; sourceTree = ""; }; + F8CBED2217D595320088ADC0 /* UIAlertView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIAlertView+AFNetworking.m"; sourceTree = ""; }; + F8D5499817DB0EF300BFF314 /* AFURLResponseSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLResponseSerialization.h; sourceTree = ""; }; + F8D5499917DB0EF300BFF314 /* AFURLResponseSerialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLResponseSerialization.m; sourceTree = ""; }; + F8D5499B17DB0EFE00BFF314 /* AFURLRequestSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLRequestSerialization.h; sourceTree = ""; }; + F8D5499C17DB0EFE00BFF314 /* AFURLRequestSerialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLRequestSerialization.m; sourceTree = ""; }; + F8D5499E17DB1C9100BFF314 /* AFNetworkReachabilityManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkReachabilityManager.h; sourceTree = ""; }; + F8D5499F17DB1C9100BFF314 /* AFNetworkReachabilityManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkReachabilityManager.m; sourceTree = ""; }; + F8DA09E31396AC040057D0CC /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; }; + F8E02CEB177A8B710087BB23 /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkActivityIndicatorManager.h; sourceTree = ""; }; + F8E02CEC177A8B710087BB23 /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkActivityIndicatorManager.m; sourceTree = ""; }; + F8E02CED177A8B710087BB23 /* UIActivityIndicatorView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIActivityIndicatorView+AFNetworking.h"; sourceTree = ""; }; + F8E02CEE177A8B710087BB23 /* UIActivityIndicatorView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIActivityIndicatorView+AFNetworking.m"; sourceTree = ""; }; + F8E02CEF177A8B710087BB23 /* UIButton+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIButton+AFNetworking.h"; sourceTree = ""; }; + F8E02CF0177A8B710087BB23 /* UIButton+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIButton+AFNetworking.m"; sourceTree = ""; }; + F8E02CF1177A8B710087BB23 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+AFNetworking.h"; sourceTree = ""; }; + F8E02CF2177A8B710087BB23 /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+AFNetworking.m"; sourceTree = ""; }; + F8E02CF3177A8B710087BB23 /* UIProgressView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIProgressView+AFNetworking.h"; sourceTree = ""; }; + F8E02CF4177A8B710087BB23 /* UIProgressView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIProgressView+AFNetworking.m"; sourceTree = ""; }; + F8E02CF5177A8B710087BB23 /* UIWebView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIWebView+AFNetworking.h"; sourceTree = ""; }; + F8E02CF6177A8B710087BB23 /* UIWebView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIWebView+AFNetworking.m"; sourceTree = ""; }; + F8E469601395739C00DB05C8 /* AFNetworking iOS Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "AFNetworking iOS Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + F8E469641395739D00DB05C8 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + F8E469661395739D00DB05C8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + F8E469681395739D00DB05C8 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + F8E4696C1395739D00DB05C8 /* iOS-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "iOS-Info.plist"; sourceTree = ""; }; + F8E469DE13957DD500DB05C8 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; + F8E469E013957DF100DB05C8 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + F8E469E213957DF700DB05C8 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; + F8F6E8D81463424800AD016F /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = SOURCE_ROOT; }; + F8F6E8D91463424800AD016F /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = SOURCE_ROOT; }; + F8FA948F150EF8C100ED4EAD /* AFAppDotNetAPIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFAppDotNetAPIClient.h; path = Classes/AFAppDotNetAPIClient.h; sourceTree = ""; }; + F8FA9490150EF8C100ED4EAD /* AFAppDotNetAPIClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFAppDotNetAPIClient.m; path = Classes/AFAppDotNetAPIClient.m; sourceTree = ""; }; + F8FA9492150EF97E00ED4EAD /* Post.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Post.h; sourceTree = ""; }; + F8FA9493150EF97E00ED4EAD /* Post.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Post.m; sourceTree = ""; }; + F8FA9495150EF98800ED4EAD /* User.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = User.h; sourceTree = ""; }; + F8FA9496150EF98800ED4EAD /* User.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = User.m; sourceTree = ""; }; + F8FA9498150EF9DA00ED4EAD /* GlobalTimelineViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlobalTimelineViewController.h; sourceTree = ""; }; + F8FA9499150EF9DA00ED4EAD /* GlobalTimelineViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GlobalTimelineViewController.m; sourceTree = ""; }; + F8FA949C150EFEC100ED4EAD /* AFHTTPSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPSessionManager.h; sourceTree = ""; }; + F8FA949D150EFEC100ED4EAD /* AFHTTPSessionManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPSessionManager.m; sourceTree = ""; }; + F8FA949E150EFEC100ED4EAD /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = ""; }; + F8FA949F150EFEC100ED4EAD /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = ""; }; + F8FA94A8150EFEC100ED4EAD /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworking.h; sourceTree = ""; }; + F8FA94AB150EFEC100ED4EAD /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLConnectionOperation.h; sourceTree = ""; }; + F8FA94AC150EFEC100ED4EAD /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLConnectionOperation.m; sourceTree = ""; }; + F8FA94BF150F019100ED4EAD /* PostTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PostTableViewCell.h; sourceTree = ""; }; + F8FA94C0150F019100ED4EAD /* PostTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PostTableViewCell.m; sourceTree = ""; }; + F8FA94CC150F094D00ED4EAD /* profile-image-placeholder.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "profile-image-placeholder.png"; path = "Images/profile-image-placeholder.png"; sourceTree = SOURCE_ROOT; }; + F8FA94CD150F094D00ED4EAD /* profile-image-placeholder@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "profile-image-placeholder@2x.png"; path = "Images/profile-image-placeholder@2x.png"; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + F8E4695D1395739C00DB05C8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + F88812F016C533D6003C8B8C /* Security.framework in Frameworks */, + F8E469651395739D00DB05C8 /* UIKit.framework in Frameworks */, + F8E469671395739D00DB05C8 /* Foundation.framework in Frameworks */, + F8E469691395739D00DB05C8 /* CoreGraphics.framework in Frameworks */, + F8E469DF13957DD500DB05C8 /* CoreLocation.framework in Frameworks */, + F8D0701B14310F4A00653FD3 /* SystemConfiguration.framework in Frameworks */, + F818101615E6A0C600EF93C2 /* MobileCoreServices.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + F8D549A117DBE52C00BFF314 /* Serialization */ = { + isa = PBXGroup; + children = ( + F8D5499B17DB0EFE00BFF314 /* AFURLRequestSerialization.h */, + F8D5499C17DB0EFE00BFF314 /* AFURLRequestSerialization.m */, + F8D5499817DB0EF300BFF314 /* AFURLResponseSerialization.h */, + F8D5499917DB0EF300BFF314 /* AFURLResponseSerialization.m */, + ); + name = Serialization; + sourceTree = ""; + }; + F8D549A217DBE53B00BFF314 /* NSURLSession */ = { + isa = PBXGroup; + children = ( + F86A37DE177397D900407E52 /* AFURLSessionManager.h */, + F86A37DF177397D900407E52 /* AFURLSessionManager.m */, + F8FA949C150EFEC100ED4EAD /* AFHTTPSessionManager.h */, + F8FA949D150EFEC100ED4EAD /* AFHTTPSessionManager.m */, + ); + name = NSURLSession; + sourceTree = ""; + }; + F8D549A317DBE54700BFF314 /* NSURLConnection */ = { + isa = PBXGroup; + children = ( + F8FA94AB150EFEC100ED4EAD /* AFURLConnectionOperation.h */, + F8FA94AC150EFEC100ED4EAD /* AFURLConnectionOperation.m */, + F8FA949E150EFEC100ED4EAD /* AFHTTPRequestOperation.h */, + F8FA949F150EFEC100ED4EAD /* AFHTTPRequestOperation.m */, + F8B3944B17DBF9B900430F25 /* AFHTTPRequestOperationManager.h */, + F8B3944C17DBF9B900430F25 /* AFHTTPRequestOperationManager.m */, + ); + name = NSURLConnection; + sourceTree = ""; + }; + F8D549A417DBE54F00BFF314 /* Reachability */ = { + isa = PBXGroup; + children = ( + F8D5499E17DB1C9100BFF314 /* AFNetworkReachabilityManager.h */, + F8D5499F17DB1C9100BFF314 /* AFNetworkReachabilityManager.m */, + ); + name = Reachability; + sourceTree = ""; + }; + F8D549A517DBE55400BFF314 /* Security */ = { + isa = PBXGroup; + children = ( + 297F56C817A9B1AB0014D95C /* AFSecurityPolicy.h */, + 297F56C917A9B1AB0014D95C /* AFSecurityPolicy.m */, + ); + name = Security; + sourceTree = ""; + }; + F8DA09C61396AB690057D0CC /* Controllers */ = { + isa = PBXGroup; + children = ( + F8FA9498150EF9DA00ED4EAD /* GlobalTimelineViewController.h */, + F8FA9499150EF9DA00ED4EAD /* GlobalTimelineViewController.m */, + ); + name = Controllers; + path = Classes/Controllers; + sourceTree = SOURCE_ROOT; + }; + F8DA09C91396AB690057D0CC /* Models */ = { + isa = PBXGroup; + children = ( + F8FA9492150EF97E00ED4EAD /* Post.h */, + F8FA9493150EF97E00ED4EAD /* Post.m */, + F8FA9495150EF98800ED4EAD /* User.h */, + F8FA9496150EF98800ED4EAD /* User.m */, + ); + name = Models; + path = Classes/Models; + sourceTree = SOURCE_ROOT; + }; + F8DA09CC1396AB690057D0CC /* Views */ = { + isa = PBXGroup; + children = ( + F8FA94BF150F019100ED4EAD /* PostTableViewCell.h */, + F8FA94C0150F019100ED4EAD /* PostTableViewCell.m */, + ); + name = Views; + path = Classes/Views; + sourceTree = SOURCE_ROOT; + }; + F8E02CEA177A8B710087BB23 /* UIKit+AFNetworking */ = { + isa = PBXGroup; + children = ( + 55BDA27E17F5A434005DB933 /* UIKit+AFNetworking.h */, + F8E02CEB177A8B710087BB23 /* AFNetworkActivityIndicatorManager.h */, + F8E02CEC177A8B710087BB23 /* AFNetworkActivityIndicatorManager.m */, + F8E02CED177A8B710087BB23 /* UIActivityIndicatorView+AFNetworking.h */, + F8E02CEE177A8B710087BB23 /* UIActivityIndicatorView+AFNetworking.m */, + F8CBED2117D595320088ADC0 /* UIAlertView+AFNetworking.h */, + F8CBED2217D595320088ADC0 /* UIAlertView+AFNetworking.m */, + F8E02CEF177A8B710087BB23 /* UIButton+AFNetworking.h */, + F8E02CF0177A8B710087BB23 /* UIButton+AFNetworking.m */, + F8E02CF1177A8B710087BB23 /* UIImageView+AFNetworking.h */, + F8E02CF2177A8B710087BB23 /* UIImageView+AFNetworking.m */, + F8E02CF3177A8B710087BB23 /* UIProgressView+AFNetworking.h */, + F8E02CF4177A8B710087BB23 /* UIProgressView+AFNetworking.m */, + F8664A1E18AA99F5007D8554 /* UIRefreshControl+AFNetworking.h */, + F8664A1F18AA99F5007D8554 /* UIRefreshControl+AFNetworking.m */, + F8E02CF5177A8B710087BB23 /* UIWebView+AFNetworking.h */, + F8E02CF6177A8B710087BB23 /* UIWebView+AFNetworking.m */, + ); + name = "UIKit+AFNetworking"; + path = "../UIKit+AFNetworking"; + sourceTree = ""; + }; + F8E469551395739C00DB05C8 = { + isa = PBXGroup; + children = ( + F8A847C2161F523E00940F39 /* Default.png */, + F8A847C4161F524200940F39 /* Default@2x.png */, + F8A847C0161F51A300940F39 /* Default-568h@2x.png */, + F8E469B71395759C00DB05C8 /* Networking Extensions */, + F8E4696A1395739D00DB05C8 /* Classes */, + F8E469ED1395812A00DB05C8 /* Images */, + F8E469931395743A00DB05C8 /* Vendor */, + F8E469631395739D00DB05C8 /* Frameworks */, + F8E469611395739C00DB05C8 /* Products */, + ); + indentWidth = 4; + sourceTree = ""; + tabWidth = 4; + usesTabs = 0; + }; + F8E469611395739C00DB05C8 /* Products */ = { + isa = PBXGroup; + children = ( + F8E469601395739C00DB05C8 /* AFNetworking iOS Example.app */, + ); + name = Products; + sourceTree = ""; + }; + F8E469631395739D00DB05C8 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 50ABD6EC159FC2CE001BE42C /* MobileCoreServices.framework */, + F8E469E213957DF700DB05C8 /* SystemConfiguration.framework */, + F8E469E013957DF100DB05C8 /* Security.framework */, + F8E469DE13957DD500DB05C8 /* CoreLocation.framework */, + F8E469641395739D00DB05C8 /* UIKit.framework */, + F8E469661395739D00DB05C8 /* Foundation.framework */, + F8E469681395739D00DB05C8 /* CoreGraphics.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + F8E4696A1395739D00DB05C8 /* Classes */ = { + isa = PBXGroup; + children = ( + F8129C7315910C37009BFE23 /* AppDelegate.h */, + F8129C7215910C37009BFE23 /* AppDelegate.m */, + F8DA09C91396AB690057D0CC /* Models */, + F8DA09CC1396AB690057D0CC /* Views */, + F8DA09C61396AB690057D0CC /* Controllers */, + F8E4696B1395739D00DB05C8 /* Supporting Files */, + ); + name = Classes; + path = AFNetworkingExample; + sourceTree = ""; + }; + F8E4696B1395739D00DB05C8 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + E8C2E7A418970EE00097DCC8 /* root_ca.cer */, + E8C2E7A518970EE00097DCC8 /* digicert_ca_3.cer */, + 2982AD3117107C0000FFF048 /* adn.cer */, + F8DA09E31396AC040057D0CC /* main.m */, + F8129C3815910830009BFE23 /* Prefix.pch */, + F8E4696C1395739D00DB05C8 /* iOS-Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + F8E469931395743A00DB05C8 /* Vendor */ = { + isa = PBXGroup; + children = ( + F8FA949B150EFEC100ED4EAD /* AFNetworking */, + F8E02CEA177A8B710087BB23 /* UIKit+AFNetworking */, + ); + name = Vendor; + sourceTree = ""; + }; + F8E469B71395759C00DB05C8 /* Networking Extensions */ = { + isa = PBXGroup; + children = ( + F8FA948F150EF8C100ED4EAD /* AFAppDotNetAPIClient.h */, + F8FA9490150EF8C100ED4EAD /* AFAppDotNetAPIClient.m */, + ); + name = "Networking Extensions"; + sourceTree = ""; + }; + F8E469ED1395812A00DB05C8 /* Images */ = { + isa = PBXGroup; + children = ( + F8F6E8D81463424800AD016F /* Icon.png */, + F8F6E8D91463424800AD016F /* Icon@2x.png */, + F8FA94CC150F094D00ED4EAD /* profile-image-placeholder.png */, + F8FA94CD150F094D00ED4EAD /* profile-image-placeholder@2x.png */, + ); + name = Images; + path = AFNetworkingExample/Images; + sourceTree = ""; + }; + F8FA949B150EFEC100ED4EAD /* AFNetworking */ = { + isa = PBXGroup; + children = ( + F8FA94A8150EFEC100ED4EAD /* AFNetworking.h */, + F8D549A317DBE54700BFF314 /* NSURLConnection */, + F8D549A217DBE53B00BFF314 /* NSURLSession */, + F8D549A117DBE52C00BFF314 /* Serialization */, + F8D549A417DBE54F00BFF314 /* Reachability */, + F8D549A517DBE55400BFF314 /* Security */, + ); + name = AFNetworking; + path = ../AFNetworking; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + F8E4695F1395739C00DB05C8 /* AFNetworking iOS Example */ = { + isa = PBXNativeTarget; + buildConfigurationList = F8E469811395739D00DB05C8 /* Build configuration list for PBXNativeTarget "AFNetworking iOS Example" */; + buildPhases = ( + F8E4695C1395739C00DB05C8 /* Sources */, + F8E4695D1395739C00DB05C8 /* Frameworks */, + F8E4695E1395739C00DB05C8 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "AFNetworking iOS Example"; + productName = AFNetworkingExample; + productReference = F8E469601395739C00DB05C8 /* AFNetworking iOS Example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + F8E469571395739C00DB05C8 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0500; + ORGANIZATIONNAME = Gowalla; + TargetAttributes = { + F8E4695F1395739C00DB05C8 = { + SystemCapabilities = { + com.apple.BackgroundModes = { + enabled = 1; + }; + }; + }; + }; + }; + buildConfigurationList = F8E4695A1395739C00DB05C8 /* Build configuration list for PBXProject "AFNetworking iOS Example" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = F8E469551395739C00DB05C8; + productRefGroup = F8E469611395739C00DB05C8 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + F8E4695F1395739C00DB05C8 /* AFNetworking iOS Example */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + F8E4695E1395739C00DB05C8 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F8F6E8DC1463424800AD016F /* Icon.png in Resources */, + F8F6E8DD1463424800AD016F /* Icon@2x.png in Resources */, + E8C2E7A718970EE40097DCC8 /* digicert_ca_3.cer in Resources */, + F8FA94D0150F094D00ED4EAD /* profile-image-placeholder.png in Resources */, + F8FA94D1150F094D00ED4EAD /* profile-image-placeholder@2x.png in Resources */, + F8A847C1161F51A300940F39 /* Default-568h@2x.png in Resources */, + F8A847C3161F523E00940F39 /* Default.png in Resources */, + E8C2E7A618970EE40097DCC8 /* root_ca.cer in Resources */, + F8A847C5161F524200940F39 /* Default@2x.png in Resources */, + 2982AD3217107C0000FFF048 /* adn.cer in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + F8E4695C1395739C00DB05C8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F86A37E0177397D900407E52 /* AFURLSessionManager.m in Sources */, + F8DA09E41396AC040057D0CC /* main.m in Sources */, + F8664A2018AA99F5007D8554 /* UIRefreshControl+AFNetworking.m in Sources */, + F8B3944D17DBF9B900430F25 /* AFHTTPRequestOperationManager.m in Sources */, + F8CBED2317D595320088ADC0 /* UIAlertView+AFNetworking.m in Sources */, + F8FA9491150EF8C100ED4EAD /* AFAppDotNetAPIClient.m in Sources */, + F8FA9494150EF97E00ED4EAD /* Post.m in Sources */, + F8FA9497150EF98800ED4EAD /* User.m in Sources */, + F8E02CF8177A8B710087BB23 /* UIActivityIndicatorView+AFNetworking.m in Sources */, + F8E02CFB177A8B710087BB23 /* UIProgressView+AFNetworking.m in Sources */, + F8D549A017DB1C9100BFF314 /* AFNetworkReachabilityManager.m in Sources */, + F8E02CF7177A8B710087BB23 /* AFNetworkActivityIndicatorManager.m in Sources */, + 297F56CA17A9B1AB0014D95C /* AFSecurityPolicy.m in Sources */, + F8E02CF9177A8B710087BB23 /* UIButton+AFNetworking.m in Sources */, + F8E02CFA177A8B710087BB23 /* UIImageView+AFNetworking.m in Sources */, + F8FA949A150EF9DA00ED4EAD /* GlobalTimelineViewController.m in Sources */, + F8FA94B1150EFEC100ED4EAD /* AFHTTPSessionManager.m in Sources */, + F8D5499D17DB0EFE00BFF314 /* AFURLRequestSerialization.m in Sources */, + F8D5499A17DB0EF300BFF314 /* AFURLResponseSerialization.m in Sources */, + F8E02CFC177A8B710087BB23 /* UIWebView+AFNetworking.m in Sources */, + F8FA94B2150EFEC100ED4EAD /* AFHTTPRequestOperation.m in Sources */, + F8FA94B8150EFEC100ED4EAD /* AFURLConnectionOperation.m in Sources */, + F8FA94C1150F019100ED4EAD /* PostTableViewCell.m in Sources */, + F8129C7415910C37009BFE23 /* AppDelegate.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + F8E4697F1395739D00DB05C8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = DEBUG; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvmgcc42; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + F8E469801395739D00DB05C8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = com.apple.compilers.llvmgcc42; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; + SDKROOT = iphoneos; + }; + name = Release; + }; + F8E469821395739D00DB05C8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_ASSIGN_ENUM = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; + CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES; + CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_RECEIVER_WEAK = YES; + CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Prefix.pch; + GCC_SHORT_ENUMS = YES; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; + GCC_WARN_PEDANTIC = YES; + GCC_WARN_SHADOW = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_STRICT_SELECTOR_MATCH = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNKNOWN_PRAGMAS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_LABEL = YES; + GCC_WARN_UNUSED_PARAMETER = YES; + INFOPLIST_FILE = "iOS-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + PRODUCT_NAME = "$(TARGET_NAME)"; + WARNING_CFLAGS = "-Wunreachable-code"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + F8E469831395739D00DB05C8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_ASSIGN_ENUM = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; + CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES; + CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_RECEIVER_WEAK = YES; + CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Prefix.pch; + GCC_SHORT_ENUMS = YES; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; + GCC_WARN_PEDANTIC = YES; + GCC_WARN_SHADOW = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_STRICT_SELECTOR_MATCH = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNKNOWN_PRAGMAS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_LABEL = YES; + GCC_WARN_UNUSED_PARAMETER = YES; + INFOPLIST_FILE = "iOS-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + PRODUCT_NAME = "$(TARGET_NAME)"; + VALIDATE_PRODUCT = YES; + WARNING_CFLAGS = "-Wunreachable-code"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + F8E4695A1395739C00DB05C8 /* Build configuration list for PBXProject "AFNetworking iOS Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F8E4697F1395739D00DB05C8 /* Debug */, + F8E469801395739D00DB05C8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F8E469811395739D00DB05C8 /* Build configuration list for PBXNativeTarget "AFNetworking iOS Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F8E469821395739D00DB05C8 /* Debug */, + F8E469831395739D00DB05C8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = F8E469571395739C00DB05C8 /* Project object */; +} diff --git a/AFNetworking-master/Example/AppDelegate.h b/AFNetworking-master/Example/AppDelegate.h new file mode 100755 index 0000000..b3c9e36 --- /dev/null +++ b/AFNetworking-master/Example/AppDelegate.h @@ -0,0 +1,44 @@ +// AppDelegate.h +// +// Copyright (c) 2012 Mattt Thompson (http://mattt.me/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#if __IPHONE_OS_VERSION_MIN_REQUIRED + #import + + @interface AppDelegate : NSObject + + @property (nonatomic, strong) UIWindow *window; + @property (nonatomic, strong) UINavigationController *navigationController; + + @end +#else + #import + + @interface AppDelegate : NSObject + + @property (strong) IBOutlet NSWindow *window; + @property (strong) IBOutlet NSTableView *tableView; + @property (strong) IBOutlet NSArrayController *postsArrayController; + + @end +#endif diff --git a/AFNetworking-master/Example/AppDelegate.m b/AFNetworking-master/Example/AppDelegate.m new file mode 100755 index 0000000..65ea0ad --- /dev/null +++ b/AFNetworking-master/Example/AppDelegate.m @@ -0,0 +1,91 @@ +// AppDelegate.m +// +// Copyright (c) 2012 Mattt Thompson (http://mattt.me/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AppDelegate.h" + +#if __IPHONE_OS_VERSION_MIN_REQUIRED + #import "GlobalTimelineViewController.h" + + #import "AFNetworkActivityIndicatorManager.h" + + @implementation AppDelegate + + - (BOOL)application:(__unused UIApplication *)application + didFinishLaunchingWithOptions:(__unused NSDictionary *)launchOptions + { + NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil]; + [NSURLCache setSharedURLCache:URLCache]; + + [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; + + UITableViewController *viewController = [[GlobalTimelineViewController alloc] initWithStyle:UITableViewStylePlain]; + self.navigationController = [[UINavigationController alloc] initWithRootViewController:viewController]; + self.navigationController.navigationBar.tintColor = [UIColor darkGrayColor]; + + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + self.window.backgroundColor = [UIColor whiteColor]; + self.window.rootViewController = self.navigationController; + [self.window makeKeyAndVisible]; + + return YES; + } + + @end +#else + #import "Post.h" + #import "User.h" + + @implementation AppDelegate + + - (void)applicationDidFinishLaunching:(NSNotification *)notification { + NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil]; + [NSURLCache setSharedURLCache:URLCache]; + + [self.window makeKeyAndOrderFront:self]; + + [Post globalTimelinePostsWithBlock:^(NSArray *posts, NSError *error) { + if (error) { + NSAlert *alert = [[NSAlert alloc] init]; + alert.messageText = NSLocalizedString(@"Error", nil); + alert.informativeText = error.localizedDescription; + [alert addButtonWithTitle:NSLocalizedString(@"OK", nil)]; + [alert runModal]; + } + + self.postsArrayController.content = posts; + }]; + + [[NSNotificationCenter defaultCenter] addObserverForName:kUserProfileImageDidLoadNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { + [self.tableView reloadData]; + }]; + } + + - (BOOL)applicationShouldHandleReopen:(NSApplication *)application + hasVisibleWindows:(BOOL)flag + { + [self.window makeKeyAndOrderFront:self]; + + return YES; + } + + @end +#endif diff --git a/AFNetworking-master/Example/Classes/AFAppDotNetAPIClient.h b/AFNetworking-master/Example/Classes/AFAppDotNetAPIClient.h new file mode 100755 index 0000000..fc80e70 --- /dev/null +++ b/AFNetworking-master/Example/Classes/AFAppDotNetAPIClient.h @@ -0,0 +1,30 @@ +// AFAppDotNetAPIClient.h +// +// Copyright (c) 2012 Mattt Thompson (http://mattt.me/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import "AFHTTPSessionManager.h" + +@interface AFAppDotNetAPIClient : AFHTTPSessionManager + ++ (instancetype)sharedClient; + +@end diff --git a/AFNetworking-master/Example/Classes/AFAppDotNetAPIClient.m b/AFNetworking-master/Example/Classes/AFAppDotNetAPIClient.m new file mode 100755 index 0000000..2908ff7 --- /dev/null +++ b/AFNetworking-master/Example/Classes/AFAppDotNetAPIClient.m @@ -0,0 +1,40 @@ +// AFAppDotNetAPIClient.h +// +// Copyright (c) 2012 Mattt Thompson (http://mattt.me/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFAppDotNetAPIClient.h" + +static NSString * const AFAppDotNetAPIBaseURLString = @"https://api.app.net/"; + +@implementation AFAppDotNetAPIClient + ++ (instancetype)sharedClient { + static AFAppDotNetAPIClient *_sharedClient = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _sharedClient = [[AFAppDotNetAPIClient alloc] initWithBaseURL:[NSURL URLWithString:AFAppDotNetAPIBaseURLString]]; + _sharedClient.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone]; + }); + + return _sharedClient; +} + +@end diff --git a/AFNetworking-master/Example/Classes/Controllers/GlobalTimelineViewController.h b/AFNetworking-master/Example/Classes/Controllers/GlobalTimelineViewController.h new file mode 100755 index 0000000..009cb54 --- /dev/null +++ b/AFNetworking-master/Example/Classes/Controllers/GlobalTimelineViewController.h @@ -0,0 +1,27 @@ +// GlobalTimelineViewController.h +// +// Copyright (c) 2012 Mattt Thompson (http://mattt.me/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +@interface GlobalTimelineViewController : UITableViewController + +@end diff --git a/AFNetworking-master/Example/Classes/Controllers/GlobalTimelineViewController.m b/AFNetworking-master/Example/Classes/Controllers/GlobalTimelineViewController.m new file mode 100755 index 0000000..3529ff4 --- /dev/null +++ b/AFNetworking-master/Example/Classes/Controllers/GlobalTimelineViewController.m @@ -0,0 +1,105 @@ +// GlobalTimelineViewController.m +// +// Copyright (c) 2012 Mattt Thompson (http://mattt.me/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "GlobalTimelineViewController.h" + +#import "Post.h" + +#import "PostTableViewCell.h" + +#import "UIRefreshControl+AFNetworking.h" +#import "UIAlertView+AFNetworking.h" + +@interface GlobalTimelineViewController () +@property (readwrite, nonatomic, strong) NSArray *posts; +@end + +@implementation GlobalTimelineViewController + +- (void)reload:(__unused id)sender { + self.navigationItem.rightBarButtonItem.enabled = NO; + + NSURLSessionTask *task = [Post globalTimelinePostsWithBlock:^(NSArray *posts, NSError *error) { + if (!error) { + self.posts = posts; + [self.tableView reloadData]; + } + }]; + + [UIAlertView showAlertViewForTaskWithErrorOnCompletion:task delegate:nil]; + [self.refreshControl setRefreshingWithStateOfTask:task]; +} + +#pragma mark - UIViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.title = NSLocalizedString(@"AFNetworking", nil); + + self.refreshControl = [[UIRefreshControl alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableView.frame.size.width, 100.0f)]; + [self.refreshControl addTarget:self action:@selector(reload:) forControlEvents:UIControlEventValueChanged]; + [self.tableView.tableHeaderView addSubview:self.refreshControl]; + + self.tableView.rowHeight = 70.0f; + + [self reload:nil]; +} + +#pragma mark - UITableViewDataSource + +- (NSInteger)tableView:(__unused UITableView *)tableView + numberOfRowsInSection:(__unused NSInteger)section +{ + return (NSInteger)[self.posts count]; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView + cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifier = @"Cell"; + + PostTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (!cell) { + cell = [[PostTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; + } + + cell.post = [self.posts objectAtIndex:(NSUInteger)indexPath.row]; + + return cell; +} + +#pragma mark - UITableViewDelegate + +- (CGFloat)tableView:(__unused UITableView *)tableView +heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + return [PostTableViewCell heightForCellWithPost:[self.posts objectAtIndex:(NSUInteger)indexPath.row]]; +} + +- (void)tableView:(UITableView *)tableView +didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + [tableView deselectRowAtIndexPath:indexPath animated:YES]; +} + +@end diff --git a/AFNetworking-master/Example/Classes/Models/Post.h b/AFNetworking-master/Example/Classes/Models/Post.h new file mode 100755 index 0000000..d390e17 --- /dev/null +++ b/AFNetworking-master/Example/Classes/Models/Post.h @@ -0,0 +1,38 @@ +// Post.h +// +// Copyright (c) 2012 Mattt Thompson (http://mattt.me/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +@class User; + +@interface Post : NSObject + +@property (nonatomic, assign) NSUInteger postID; +@property (nonatomic, strong) NSString *text; + +@property (nonatomic, strong) User *user; + +- (instancetype)initWithAttributes:(NSDictionary *)attributes; + ++ (NSURLSessionDataTask *)globalTimelinePostsWithBlock:(void (^)(NSArray *posts, NSError *error))block; + +@end diff --git a/AFNetworking-master/Example/Classes/Models/Post.m b/AFNetworking-master/Example/Classes/Models/Post.m new file mode 100755 index 0000000..8d91095 --- /dev/null +++ b/AFNetworking-master/Example/Classes/Models/Post.m @@ -0,0 +1,65 @@ +// Post.m +// +// Copyright (c) 2012 Mattt Thompson (http://mattt.me/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "Post.h" +#import "User.h" + +#import "AFAppDotNetAPIClient.h" + +@implementation Post + +- (instancetype)initWithAttributes:(NSDictionary *)attributes { + self = [super init]; + if (!self) { + return nil; + } + + self.postID = (NSUInteger)[[attributes valueForKeyPath:@"id"] integerValue]; + self.text = [attributes valueForKeyPath:@"text"]; + + self.user = [[User alloc] initWithAttributes:[attributes valueForKeyPath:@"user"]]; + + return self; +} + +#pragma mark - + ++ (NSURLSessionDataTask *)globalTimelinePostsWithBlock:(void (^)(NSArray *posts, NSError *error))block { + return [[AFAppDotNetAPIClient sharedClient] GET:@"stream/0/posts/stream/global" parameters:nil success:^(NSURLSessionDataTask * __unused task, id JSON) { + NSArray *postsFromResponse = [JSON valueForKeyPath:@"data"]; + NSMutableArray *mutablePosts = [NSMutableArray arrayWithCapacity:[postsFromResponse count]]; + for (NSDictionary *attributes in postsFromResponse) { + Post *post = [[Post alloc] initWithAttributes:attributes]; + [mutablePosts addObject:post]; + } + + if (block) { + block([NSArray arrayWithArray:mutablePosts], nil); + } + } failure:^(NSURLSessionDataTask *__unused task, NSError *error) { + if (block) { + block([NSArray array], error); + } + }]; +} + +@end diff --git a/AFNetworking-master/Example/Classes/Models/User.h b/AFNetworking-master/Example/Classes/Models/User.h new file mode 100755 index 0000000..aeb7641 --- /dev/null +++ b/AFNetworking-master/Example/Classes/Models/User.h @@ -0,0 +1,39 @@ +// User.h +// +// Copyright (c) 2012 Mattt Thompson (http://mattt.me/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +extern NSString * const kUserProfileImageDidLoadNotification; + +@interface User : NSObject + +@property (readonly, nonatomic, assign) NSUInteger userID; +@property (readonly, nonatomic, copy) NSString *username; +@property (readonly, nonatomic, unsafe_unretained) NSURL *avatarImageURL; + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +@property (nonatomic, strong) NSImage *profileImage; +#endif + +- (instancetype)initWithAttributes:(NSDictionary *)attributes; + +@end diff --git a/AFNetworking-master/Example/Classes/Models/User.m b/AFNetworking-master/Example/Classes/Models/User.m new file mode 100755 index 0000000..882535b --- /dev/null +++ b/AFNetworking-master/Example/Classes/Models/User.m @@ -0,0 +1,100 @@ +// User.m +// +// Copyright (c) 2012 Mattt Thompson (http://mattt.me/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "User.h" +#import "AFHTTPRequestOperation.h" + +NSString * const kUserProfileImageDidLoadNotification = @"com.alamofire.user.profile-image.loaded"; + +@interface User () +@property (readwrite, nonatomic, assign) NSUInteger userID; +@property (readwrite, nonatomic, copy) NSString *username; +@property (readwrite, nonatomic, copy) NSString *avatarImageURLString; + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +@property (readwrite, nonatomic, strong) AFHTTPRequestOperation *avatarImageRequestOperation; +#endif +@end + +@implementation User + +- (instancetype)initWithAttributes:(NSDictionary *)attributes { + self = [super init]; + if (!self) { + return nil; + } + + self.userID = (NSUInteger)[[attributes valueForKeyPath:@"id"] integerValue]; + self.username = [attributes valueForKeyPath:@"username"]; + self.avatarImageURLString = [attributes valueForKeyPath:@"avatar_image.url"]; + + return self; +} + +- (NSURL *)avatarImageURL { + return [NSURL URLWithString:self.avatarImageURLString]; +} + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + ++ (NSOperationQueue *)sharedProfileImageRequestOperationQueue { + static NSOperationQueue *_sharedProfileImageRequestOperationQueue = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _sharedProfileImageRequestOperationQueue = [[NSOperationQueue alloc] init]; + [_sharedProfileImageRequestOperationQueue setMaxConcurrentOperationCount:8]; + }); + + return _sharedProfileImageRequestOperationQueue; +} + +- (NSImage *)profileImage { + if (!_profileImage && !_avatarImageRequestOperation) { + NSMutableURLRequest *mutableRequest = [NSMutableURLRequest requestWithURL:self.avatarImageURL]; + [mutableRequest setValue:@"image/*" forHTTPHeaderField:@"Accept"]; + AFHTTPRequestOperation *imageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:mutableRequest]; + imageRequestOperation.responseSerializer = [AFImageResponseSerializer serializer]; + [imageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, NSImage *responseImage) { + self.profileImage = responseImage; + + _avatarImageRequestOperation = nil; + + [[NSNotificationCenter defaultCenter] postNotificationName:kUserProfileImageDidLoadNotification object:self userInfo:nil]; + } failure:nil]; + + [imageRequestOperation setCacheResponseBlock:^NSCachedURLResponse *(NSURLConnection *connection, NSCachedURLResponse *cachedResponse) { + return [[NSCachedURLResponse alloc] initWithResponse:cachedResponse.response data:cachedResponse.data userInfo:cachedResponse.userInfo storagePolicy:NSURLCacheStorageAllowed]; + }]; + + _avatarImageRequestOperation = imageRequestOperation; + + [[[self class] sharedProfileImageRequestOperationQueue] addOperation:_avatarImageRequestOperation]; + } + + return _profileImage; +} + +#endif + +@end diff --git a/AFNetworking-master/Example/Classes/Views/PostTableViewCell.h b/AFNetworking-master/Example/Classes/Views/PostTableViewCell.h new file mode 100755 index 0000000..8336b24 --- /dev/null +++ b/AFNetworking-master/Example/Classes/Views/PostTableViewCell.h @@ -0,0 +1,33 @@ +// TweetTableViewCell.h +// +// Copyright (c) 2012 Mattt Thompson (http://mattt.me/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +@class Post; + +@interface PostTableViewCell : UITableViewCell + +@property (nonatomic, strong) Post *post; + ++ (CGFloat)heightForCellWithPost:(Post *)post; + +@end diff --git a/AFNetworking-master/Example/Classes/Views/PostTableViewCell.m b/AFNetworking-master/Example/Classes/Views/PostTableViewCell.m new file mode 100755 index 0000000..14a31ad --- /dev/null +++ b/AFNetworking-master/Example/Classes/Views/PostTableViewCell.m @@ -0,0 +1,82 @@ +// TweetTableViewCell.m +// +// Copyright (c) 2012 Mattt Thompson (http://mattt.me/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "PostTableViewCell.h" + +#import "Post.h" +#import "User.h" + +#import "UIImageView+AFNetworking.h" + +@implementation PostTableViewCell + +- (id)initWithStyle:(UITableViewCellStyle)style + reuseIdentifier:(NSString *)reuseIdentifier +{ + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if (!self) { + return nil; + } + + self.textLabel.adjustsFontSizeToFitWidth = YES; + self.textLabel.textColor = [UIColor darkGrayColor]; + self.detailTextLabel.font = [UIFont systemFontOfSize:12.0f]; + self.detailTextLabel.numberOfLines = 0; + self.selectionStyle = UITableViewCellSelectionStyleGray; + + return self; +} + +- (void)setPost:(Post *)post { + _post = post; + + self.textLabel.text = _post.user.username; + self.detailTextLabel.text = _post.text; + [self.imageView setImageWithURL:_post.user.avatarImageURL placeholderImage:[UIImage imageNamed:@"profile-image-placeholder"]]; + + [self setNeedsLayout]; +} + ++ (CGFloat)heightForCellWithPost:(Post *)post { + return (CGFloat)fmaxf(70.0f, (float)[self detailTextHeight:post.text] + 45.0f); +} + ++ (CGFloat)detailTextHeight:(NSString *)text { + CGRect rectToFit = [text boundingRectWithSize:CGSizeMake(240.0f, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12.0f]} context:nil]; + return rectToFit.size.height; +} + +#pragma mark - UIView + +- (void)layoutSubviews { + [super layoutSubviews]; + + self.imageView.frame = CGRectMake(10.0f, 10.0f, 50.0f, 50.0f); + self.textLabel.frame = CGRectMake(70.0f, 6.0f, 240.0f, 20.0f); + + CGRect detailTextLabelFrame = CGRectOffset(self.textLabel.frame, 0.0f, 25.0f); + CGFloat calculatedHeight = [[self class] detailTextHeight:self.post.text]; + detailTextLabelFrame.size.height = calculatedHeight; + self.detailTextLabel.frame = detailTextLabelFrame; +} + +@end diff --git a/AFNetworking-master/Example/Default-568h@2x.png b/AFNetworking-master/Example/Default-568h@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..0891b7aabfcf3422423b109c8beed2bab838c607 GIT binary patch literal 18594 zcmeI4X;f257Jx&9fS`ixvS;&$x8J@slQFSel)6zJN=?13FB7H(lQjRkSy8x_-S~tvu2gzn1oS+dLcF#eqtq$ z%tf9TTvX?`)R@}3uBI;jzS-=ZR-Td&MHaS&;!0?Ni*#$#`n*~CcQK)Q9vAQ~TUpnI!j)a2biYK^R)M~A5wUDZhx?ULMX z3x1P&qt=trOY6P2U67L=m=U?F|5#Uj(eCueNTZaHs_ceWiHeET+j+tp3Jt9g(ekqP z2WOvfR{qV+9r+o4J5?qK>7;;^+I7tGv-i)es$X_D=EoKF+S?zsyj^oRFElP}c}JT< zd8SUs-?O?}2YD#ngKbnHgzHBcboxK_2r9l(?eNCl-pEzkJm}fY?WC*jnS?VBE4EpY zO$fEejz6fU;W2Kl>JeQBZBl-%Irg`obSlg*@4QB;Dd1H7^Oi5wvt4d{RZ!8Og?^aE z)k0$1g+V3fd(gdQ3d&q2q-FL*uy#}|bc^=VhFsl0jBgUGJ+-s3U8MK9A!YJJMxpci z5hJ%|{DwV48fZn0{n5l$N_KcSb#NKE4plB`9I6Zt=Z!~-zw0{9tg$L&Ju1F0X)Cy8 zKF;(&lJ>x)Jw(=;p~sF(Sd9VWGwFE2rnyS9!f^DZ8+aCLq zQ};>lcJ1GDLqjm6Hd>|Eabno@P`~Bn(~6^aD_#yoEH(a?Nm1S<;S+hSxI5d16^<1lEM3NPFi zkqPrpL)+ zgnseFikg`gJVBha1&7C4;O6>h=dt~`ND+;Zd?W(4v2JIb7Pt>Td42%M-Ju-XAH#Pns762L}K3 zDhvsRqN0Ni(1UrishD2YvV?4*h2iFj$+&N||Fn$4n|^NSU+o?~jq`0jVQt8T9l{7b zXiwwODFh2V!Q6sqP9S>WH$oOf$N~=d0-bqTlD61!=`&0eAP-F>XN?*|gtOXX{ zQVTWyYo4ZK0GAw!GHf|pz9`D;-bbb*5LBX*{bnz|+)$@&P9|ORM2o?95{;ejvo&r- zq8cBhTN6nn)7~W>54U)%-F_-b?YKdfk5I8MHcuzBD5)!;yv#Z&R&^y=@=>VTIMy#r zX&U<=BsPkdqcMe<_}2+>H%XKyrr5ZR8_KVe>ZqYN z^=^~TFD};;rHJ$U;{~w^hYojl4hRI@SH$^K{YEo=sg)WY87r!*7blQK&qnpDo0`Vn zkl)9u9g=mCh&ZCJS(L4yN3k0kQ zuvg$h2KEEk51T+O0JQ+r0`R>g{jvqM0Mr6d3qUOZwE!?PI7HY@CE|dr sfw?Q;rAv?G4&^^8-z_>&sWXMxvD*gPOU4CBe-*@OtE+wfmVJNyHv)PfH~;_u literal 0 HcmV?d00001 diff --git a/AFNetworking-master/Example/Default.png b/AFNetworking-master/Example/Default.png new file mode 100755 index 0000000000000000000000000000000000000000..44cc3a31c77f95b279d444d93c92a33d2a1e60db GIT binary patch literal 942 zcmeAS@N?(olHy`uVBq!ia0y~yU~~ZD2OLa5Qs<>`D^NnR#5JNMI6tkVJh3R1!7(L2 zDOJHUH!(dmC^a#qvhZZ84FdynfTxRNNX4x;2OEJp7!EJ^87%*hDU=b!VPL2cZiuy* z0OCkI$**l?z9Iw`X0Q-)U?_VygAK@Y2>5?(Ut5DBL;^|{a30W;IRWDEeA;ezkT;7H zMH-behb2Lr&jTdJ^0)qOpF<$3G|{{tUJQ&kT9c(f8XW&d-#*0MMzmh)DE#2fz<6sp z*ad8f$NyBjorvO8@nJGBNJuzv0E8PF8JU}bn3;_Ygn4)*BtRIX0IMP%9p0kU-@DS|s1;wG3$FrPuJBTW&^`w%zbFbTUN(gKo#(8du)sPP6FJMLpoC3VtQ&&YGO)d;mK4R1_t3to-U3d6}R48*vQMEz{Bj=-gt9Aw}{UKp}XGG zV&W&g*}d)ND_P!X4hAL`jsONmCKinbASvPiB)JrTB&z_BWa0plj4T`i3s9Ajq!?@_ zlM4er1L5}GFJ(!Xf6kYIAxVOx=gJu zfqREat|?)Hn@CZJQ=}Qm2}n$63i>B^;3j(ku$hlBjA9U zRLF55b;5>Pt^xXqDv5_WVM8s~0CO@qQG@9Ts)P;ITtnB4^+2JTwV;@NLG+(Z=Vu(Z z+?_UgHiPe;&ClZ-zP-J{lBm&hNW<}m~dy z;=2!y z_YVU@n{dFE@d;OM1`_`(-C|B{Wwty9kj&Py#j8TPb2M~{h-Vb#ZT fyWY%^-TaOF!h{(~Yre&-WB>wBS3j3^P6P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&nehQ1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z000iYNkl?r0mHuwMdP{HW)?!(5d zI78SEXBYy>#1O)g$r*-B2%a!uJ0XFDWz1m-cvx*b0c>m*+mdD3ShB38)qD4Qujd#%z!W~kieKX5?~E3KsaC? zGQ>*zF8g^dBy>In42-6-o}5?_7rMgW>6G)RUxmxNpRMkFaL~hVT+!PF(RTd(I@-I^7AU5?&U$Zp0d( z3IGjRq>zR%VVHu*WH$$2LFuvYTI#N?qIQL>|7+d-8L^>Loe0%IIsibDYERX@JCW@Y zRYz0Z3cYU=L=b8y7+7zoH(_M1WKamJiq76*LmvRdPApy;=5;}@)w=v?fU?5 z-!4!b-21AUu)iS3%`5(r3$N!r9}t;e-bJ#~tkfv= z4LDrL3$ucif@T<|+VYxx`R}Q!5dinK_^oep#*^QqT%M( zF81HvE|)E^|KU9ljbP@vxO3KhgYU??rEcrnR6cEp!nI$t0e!^IPT^|r{pXFQ6R2#G z?rCOd-uIE1eHvr{taJC*7hc^Pylka)!5=`zh-=7G@1|hIkX0u(agMd8!1~}R#!5^0 zK74f~lq3X&tNj0cUPL3#m9GKdmN(&RbR@0o9s-cQx=iiLgztJ-E?WIn^bxEaekupX zK@hyc5GwF}*>7`)aas;oIzt#_mAUV}Ajg#lZvO&80#Ge)vIfmqKtg73t45Z~o{v)? z_O%7!grSH$pT(d}l@_d2(G0$-Gq{jt<+Eb;6_X7%+&{l0XD$rw?}npwuY)5DKtjsz$GlI*h{4opd?uk<0!^wDFhv;}q3?YAim>UiC1ADv#V>l?R_mX=Wx8tW_}#m#mn5Ju+z$i_kcK>+53b z0`v6S3Qt@i8jklrd0lr?@L$%+#uWn(d%5H_H(94e12?=QCe9u030TOo%bE-naw^d- zDyM=KD;Cgt>;IBN%Q+Q8X9ol5!dz6|X|e$zPwDC^|K6YQ0p%8;>*s6J+a1GelxzUM&WAqU`#s^fUp8k1f`)>{~61S zU`&7UiMKgj_S7ah_1NOH_{y5lt>3j){4>7ICM{7JEYdbr&jcCl`>eDqecadq?%3h| zB^`UIRg9ZbqK+5tGOFyrb?fl0H?d$EC%XZNnwb=faw-lhBv>;bDB0z0jK^O5{2);H zuJ_(kWxv^n|Bq%Jy9(I^02rpxxRkpNu%;5f7B;m<9(q#L%p5p}KKq~0jsIObKfisf z$E^}IvrE^@uhdz96&<*(NpAVjI_ZqiEiVm^q>hL$b^GU>Nf-@(1w)SNL@1=m4i_WW zz^GVu=={IXA_AFV|^DKmAHIy-x*==%|}MX21TF%gtSijzV7Z7 z+_^t+#m`^{MyobA7hhJ%yAxK^bZgNpQQ;@fTkUUtVQfs|l&dHd6=Gteb@Jt-UoQXn z4M-@td?6Qn&J{%M9JxfKe|W*z&_ZRcF=M$fn$8*n2hu9D_EBR=x$cd#25aba%BVle z+n!a;8^#81!y+MPEFSGLzMH(bT1ZbsCqpS{6g#_~)fDOb-f~VH7(G^_cAgMZ=8XoW zyZ*QF)63P4UU_U2r<2fh5Gx7=Q8QgutN4-$xwY4EE;TB-)-+H$oeqUUhZ(A|muKan zXRrU+MsM>Q-rFze?HOaX6jSGOs&@qHV5UGsXL`K%+eL+GEj>XV`&~I_sWE9fn*kwh z$ip?iboc(RfmMCBA%5}_IZNuSqO67kF(o8w>fw3pxrgL9W)c#%ja09{dq3jL7Kxbj zw|b#FR|l?r_%N|%5`ABTuEmtOTCk{zQ7{a{0s%_tY_^nmJ7lJrSS#eRFau)tObEc& z#0B2AM@&8H>llHMBRX~ViQ6fYLZ}MR{Ryi8_P3b}9d;tnfO3x{MN^zb1YsMCZ1>%D zobx!F?9W~jw9*G!f>-}LMJm61HjQ8dnS0Jlt$Eh02lJrhy@n_gvS|V5`m^<{hotQf zX#*t~{ny30EXpeU-CNZz4|32h61okd&aV0}3DX*aDxDfZuDW@@i&8UU$1J|v*nnm-wpG1az9HD_Tm6d5sL%sq zBYyLiHY=%55POA9yCZkpZm+zaVkJxBOwxVzx0yR`^tZPMFTFhQ%+K}yHW0+PI!FTm z@;Ug0?AjkvMS0-DJ2`$pXX1%-PatEj^Sw&~fB1#o-$vu>^p1}b-#^8iJB5k*t6Ycp zTsWkW^NBGxL{Uyz33{Z?9W#NuuuBi-fQp9K6rI; zGkaoW!&B(7F_H!_zWdH;bd_d~~ zpnOQtN*=LXs0Z6Cpa8D`z?`
L4yN3k0kQ zuvg$h2KEEk51T+O0JQ+r0`R>g{jvqM0Mr6d3qUOZwE!?PI7HY@CE|dr sfw?Q;rAv?G4&^^8-z_>&sWXMxvD*gPOU4CBe-*@OtE+wfmVJNyHv)PfH~;_u literal 0 HcmV?d00001 diff --git a/AFNetworking-master/Example/Default.png b/AFNetworking-master/Example/Default.png new file mode 100755 index 0000000000000000000000000000000000000000..44cc3a31c77f95b279d444d93c92a33d2a1e60db GIT binary patch literal 942 zcmeAS@N?(olHy`uVBq!ia0y~yU~~ZD2OLa5Qs<>`D^NnR#5JNMI6tkVJh3R1!7(L2 zDOJHUH!(dmC^a#qvhZZ84FdynfTxRNNX4x;2OEJp7!EJ^87%*hDU=b!VPL2cZiuy* z0OCkI$**l?z9Iw`X0Q-)U?_VygAK@Y2>5?(Ut5DBL;^|{a30W;IRWDEeA;ezkT;7H zMH-behb2Lr&jTdJ^0)qOpF<$3G|{{tUJQ&kT9c(f8XW&d-#*0MMzmh)DE#2fz<6sp z*ad8f$NyBjorvO8@nJGBNJuzv0E8PF8JU}bn3;_Ygn4)*BtRIX0IMP%9p0kU-@DS|s1;wG3$FrPuJBTW&^`w%zbFbTUN(gKo#(8du)sPP6FJMLpoC3VtQ&&YGO)d;mK4R1_t3to-U3d6}R48*vQMEz{Bj=-gt9Aw}{UKp}XGG zV&W&g*}d)ND_P!X4hAL`jsONmCKinbASvPiB)JrTB&z_BWa0plj4T`i3s9Ajq!?@_ zlM4er1L5}GFJ(!Xf6kYIAxVOx=gJu zfqREat|?)Hn@CZJQ=}Qm2}n$63i>B^;3j(ku$hlBjA9U zRLF55b;5>Pt^xXqDv5_WVM8s~0CO@qQG@9Ts)P;ITtnB4^+2JTwV;@NLG+(Z=Vu(Z z+?_UgHiPe;&ClZ-zP-J{lBm&hNW<}m~dy z;=2!y z_YVU@n{dFE@d;OM1`_`(-C|B{Wwty9kj&Py#j8TPb2M~{h-Vb#ZT fyWY%^-TaOF!h{(~Yre&-WB>wBS3j3^P6P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&nehQ1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z000iYNkl?r0mHuwMdP{HW)?!(5d zI78SEXBYy>#1O)g$r*-B2%a!uJ0XFDWz1m-cvx*b0c>m*+mdD3ShB38)qD4Qujd#%z!W~kieKX5?~E3KsaC? zGQ>*zF8g^dBy>In42-6-o}5?_7rMgW>6G)RUxmxNpRMkFaL~hVT+!PF(RTd(I@-I^7AU5?&U$Zp0d( z3IGjRq>zR%VVHu*WH$$2LFuvYTI#N?qIQL>|7+d-8L^>Loe0%IIsibDYERX@JCW@Y zRYz0Z3cYU=L=b8y7+7zoH(_M1WKamJiq76*LmvRdPApy;=5;}@)w=v?fU?5 z-!4!b-21AUu)iS3%`5(r3$N!r9}t;e-bJ#~tkfv= z4LDrL3$ucif@T<|+VYxx`R}Q!5dinK_^oep#*^QqT%M( zF81HvE|)E^|KU9ljbP@vxO3KhgYU??rEcrnR6cEp!nI$t0e!^IPT^|r{pXFQ6R2#G z?rCOd-uIE1eHvr{taJC*7hc^Pylka)!5=`zh-=7G@1|hIkX0u(agMd8!1~}R#!5^0 zK74f~lq3X&tNj0cUPL3#m9GKdmN(&RbR@0o9s-cQx=iiLgztJ-E?WIn^bxEaekupX zK@hyc5GwF}*>7`)aas;oIzt#_mAUV}Ajg#lZvO&80#Ge)vIfmqKtg73t45Z~o{v)? z_O%7!grSH$pT(d}l@_d2(G0$-Gq{jt<+Eb;6_X7%+&{l0XD$rw?}npwuY)5DKtjsz$GlI*h{4opd?uk<0!^wDFhv;}q3?YAim>UiC1ADv#V>l?R_mX=Wx8tW_}#m#mn5Ju+z$i_kcK>+53b z0`v6S3Qt@i8jklrd0lr?@L$%+#uWn(d%5H_H(94e12?=QCe9u030TOo%bE-naw^d- zDyM=KD;Cgt>;IBN%Q+Q8X9ol5!dz6|X|e$zPwDC^|K6YQ0p%8;>*s6J+a1GelxzUM&WAqU`#s^fUp8k1f`)>{~61S zU`&7UiMKgj_S7ah_1NOH_{y5lt>3j){4>7ICM{7JEYdbr&jcCl`>eDqecadq?%3h| zB^`UIRg9ZbqK+5tGOFyrb?fl0H?d$EC%XZNnwb=faw-lhBv>;bDB0z0jK^O5{2);H zuJ_(kWxv^n|Bq%Jy9(I^02rpxxRkpNu%;5f7B;m<9(q#L%p5p}KKq~0jsIObKfisf z$E^}IvrE^@uhdz96&<*(NpAVjI_ZqiEiVm^q>hL$b^GU>Nf-@(1w)SNL@1=m4i_WW zz^GVu=={IXA_AFV|^DKmAHIy-x*==%|}MX21TF%gtSijzV7Z7 z+_^t+#m`^{MyobA7hhJ%yAxK^bZgNpQQ;@fTkUUtVQfs|l&dHd6=Gteb@Jt-UoQXn z4M-@td?6Qn&J{%M9JxfKe|W*z&_ZRcF=M$fn$8*n2hu9D_EBR=x$cd#25aba%BVle z+n!a;8^#81!y+MPEFSGLzMH(bT1ZbsCqpS{6g#_~)fDOb-f~VH7(G^_cAgMZ=8XoW zyZ*QF)63P4UU_U2r<2fh5Gx7=Q8QgutN4-$xwY4EE;TB-)-+H$oeqUUhZ(A|muKan zXRrU+MsM>Q-rFze?HOaX6jSGOs&@qHV5UGsXL`K%+eL+GEj>XV`&~I_sWE9fn*kwh z$ip?iboc(RfmMCBA%5}_IZNuSqO67kF(o8w>fw3pxrgL9W)c#%ja09{dq3jL7Kxbj zw|b#FR|l?r_%N|%5`ABTuEmtOTCk{zQ7{a{0s%_tY_^nmJ7lJrSS#eRFau)tObEc& z#0B2AM@&8H>llHMBRX~ViQ6fYLZ}MR{Ryi8_P3b}9d;tnfO3x{MN^zb1YsMCZ1>%D zobx!F?9W~jw9*G!f>-}LMJm61HjQ8dnS0Jlt$Eh02lJrhy@n_gvS|V5`m^<{hotQf zX#*t~{ny30EXpeU-CNZz4|32h61okd&aV0}3DX*aDxDfZuDW@@i&8UU$1J|v*nnm-wpG1az9HD_Tm6d5sL%sq zBYyLiHY=%55POA9yCZkpZm+zaVkJxBOwxVzx0yR`^tZPMFTFhQ%+K}yHW0+PI!FTm z@;Ug0?AjkvMS0-DJ2`$pXX1%-PatEj^Sw&~fB1#o-$vu>^p1}b-#^8iJB5k*t6Ycp zTsWkW^NBGxL{Uyz33{Z?9W#NuuuBi-fQp9K6rI; zGkaoW!&B(7F_H!_zWdH;bd_d~~ zpnOQtN*=LXs0Z6Cpa8D`z?`
zBYyLiHY=%55POA9yCZkpZm+zaVkJxBOwxVzx0yR`^tZPMFTFhQ%+K}yHW0+PI!FTm z@;Ug0?AjkvMS0-DJ2`$pXX1%-PatEj^Sw&~fB1#o-$vu>^p1}b-#^8iJB5k*t6Ycp zTsWkW^NBGxL{Uyz33{Z?9W#NuuuBi-fQp9K6rI; zGkaoW!&B(7F_H!_zWdH;bd_d~~ zpnOQtN*=LXs0Z6Cpa8D`z?`