├── .DS_Store ├── .codecov ├── .swift-version ├── .travis.yml ├── BANetManager.podspec ├── BANetManager ├── .DS_Store ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ ├── BADataEntity.h │ ├── BADataEntity.m │ ├── BANetManager.h │ ├── BANetManager.m │ ├── BANetManagerCache.h │ ├── BANetManagerCache.m │ ├── BANetManager_OC.h │ ├── BANetManager_Version.h │ ├── UIImage+CompressImage.h │ └── UIImage+CompressImage.m ├── Example ├── .DS_Store ├── BANetManager.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── BANetManager-Example.xcscheme ├── BANetManager.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── Alria.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ └── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist ├── BANetManager │ ├── BAAppDelegate.h │ ├── BAAppDelegate.m │ ├── BANetManager-Info.plist │ ├── BANetManager-Prefix.pch │ ├── BAViewController.h │ ├── BAViewController.m │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── IMG_0060.imageset │ │ │ ├── Contents.json │ │ │ └── IMG_0060.JPG │ │ └── bg_label.imageset │ │ │ ├── Contents.json │ │ │ └── bg_label.png │ ├── Main.storyboard │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── main.m │ └── postdynamic.php ├── Podfile ├── Podfile.lock └── Pods │ ├── AFNetworking │ ├── AFNetworking │ │ ├── AFCompatibilityMacros.h │ │ ├── AFHTTPSessionManager.h │ │ ├── AFHTTPSessionManager.m │ │ ├── AFNetworkReachabilityManager.h │ │ ├── AFNetworkReachabilityManager.m │ │ ├── AFNetworking.h │ │ ├── AFSecurityPolicy.h │ │ ├── AFSecurityPolicy.m │ │ ├── AFURLRequestSerialization.h │ │ ├── AFURLRequestSerialization.m │ │ ├── AFURLResponseSerialization.h │ │ ├── AFURLResponseSerialization.m │ │ ├── AFURLSessionManager.h │ │ └── AFURLSessionManager.m │ ├── LICENSE │ ├── README.md │ └── UIKit+AFNetworking │ │ ├── AFAutoPurgingImageCache.h │ │ ├── AFAutoPurgingImageCache.m │ │ ├── AFImageDownloader.h │ │ ├── AFImageDownloader.m │ │ ├── AFNetworkActivityIndicatorManager.h │ │ ├── AFNetworkActivityIndicatorManager.m │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ ├── UIActivityIndicatorView+AFNetworking.m │ │ ├── UIButton+AFNetworking.h │ │ ├── UIButton+AFNetworking.m │ │ ├── UIImageView+AFNetworking.h │ │ ├── UIImageView+AFNetworking.m │ │ ├── UIKit+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.m │ │ ├── UIRefreshControl+AFNetworking.h │ │ ├── UIRefreshControl+AFNetworking.m │ │ ├── WKWebView+AFNetworking.h │ │ └── WKWebView+AFNetworking.m │ ├── Headers │ ├── Private │ │ ├── AFNetworking │ │ │ ├── AFAutoPurgingImageCache.h │ │ │ ├── AFCompatibilityMacros.h │ │ │ ├── AFHTTPSessionManager.h │ │ │ ├── AFImageDownloader.h │ │ │ ├── AFNetworkActivityIndicatorManager.h │ │ │ ├── AFNetworkReachabilityManager.h │ │ │ ├── AFNetworking.h │ │ │ ├── AFSecurityPolicy.h │ │ │ ├── AFURLRequestSerialization.h │ │ │ ├── AFURLResponseSerialization.h │ │ │ ├── AFURLSessionManager.h │ │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ │ ├── UIButton+AFNetworking.h │ │ │ ├── UIImageView+AFNetworking.h │ │ │ ├── UIKit+AFNetworking.h │ │ │ ├── UIProgressView+AFNetworking.h │ │ │ ├── UIRefreshControl+AFNetworking.h │ │ │ └── WKWebView+AFNetworking.h │ │ ├── BANetManager │ │ │ ├── BADataEntity.h │ │ │ ├── BANetManager.h │ │ │ ├── BANetManagerCache.h │ │ │ ├── BANetManager_OC.h │ │ │ ├── BANetManager_Version.h │ │ │ └── UIImage+CompressImage.h │ │ ├── MJExtension │ │ │ ├── MJExtension.h │ │ │ ├── MJExtensionConst.h │ │ │ ├── MJFoundation.h │ │ │ ├── MJProperty.h │ │ │ ├── MJPropertyKey.h │ │ │ ├── MJPropertyType.h │ │ │ ├── NSObject+MJClass.h │ │ │ ├── NSObject+MJCoding.h │ │ │ ├── NSObject+MJKeyValue.h │ │ │ ├── NSObject+MJProperty.h │ │ │ └── NSString+MJExtension.h │ │ └── YYCache │ │ │ ├── YYCache.h │ │ │ ├── YYDiskCache.h │ │ │ ├── YYKVStorage.h │ │ │ └── YYMemoryCache.h │ └── Public │ │ ├── AFNetworking │ │ ├── AFAutoPurgingImageCache.h │ │ ├── AFCompatibilityMacros.h │ │ ├── AFHTTPSessionManager.h │ │ ├── AFImageDownloader.h │ │ ├── AFNetworkActivityIndicatorManager.h │ │ ├── AFNetworkReachabilityManager.h │ │ ├── AFNetworking.h │ │ ├── AFSecurityPolicy.h │ │ ├── AFURLRequestSerialization.h │ │ ├── AFURLResponseSerialization.h │ │ ├── AFURLSessionManager.h │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ ├── UIButton+AFNetworking.h │ │ ├── UIImageView+AFNetworking.h │ │ ├── UIKit+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.h │ │ ├── UIRefreshControl+AFNetworking.h │ │ └── WKWebView+AFNetworking.h │ │ ├── BANetManager │ │ ├── BADataEntity.h │ │ ├── BANetManager.h │ │ ├── BANetManagerCache.h │ │ ├── BANetManager_OC.h │ │ ├── BANetManager_Version.h │ │ └── UIImage+CompressImage.h │ │ ├── MJExtension │ │ ├── MJExtension.h │ │ ├── MJExtensionConst.h │ │ ├── MJFoundation.h │ │ ├── MJProperty.h │ │ ├── MJPropertyKey.h │ │ ├── MJPropertyType.h │ │ ├── NSObject+MJClass.h │ │ ├── NSObject+MJCoding.h │ │ ├── NSObject+MJKeyValue.h │ │ ├── NSObject+MJProperty.h │ │ └── NSString+MJExtension.h │ │ └── YYCache │ │ ├── YYCache.h │ │ ├── YYDiskCache.h │ │ ├── YYKVStorage.h │ │ └── YYMemoryCache.h │ ├── Local Podspecs │ └── BANetManager.podspec.json │ ├── MJExtension │ ├── LICENSE │ ├── MJExtension │ │ ├── MJExtension.h │ │ ├── MJExtensionConst.h │ │ ├── MJExtensionConst.m │ │ ├── MJFoundation.h │ │ ├── MJFoundation.m │ │ ├── MJProperty.h │ │ ├── MJProperty.m │ │ ├── MJPropertyKey.h │ │ ├── MJPropertyKey.m │ │ ├── MJPropertyType.h │ │ ├── MJPropertyType.m │ │ ├── NSObject+MJClass.h │ │ ├── NSObject+MJClass.m │ │ ├── NSObject+MJCoding.h │ │ ├── NSObject+MJCoding.m │ │ ├── NSObject+MJKeyValue.h │ │ ├── NSObject+MJKeyValue.m │ │ ├── NSObject+MJProperty.h │ │ ├── NSObject+MJProperty.m │ │ ├── NSString+MJExtension.h │ │ └── NSString+MJExtension.m │ └── README.md │ ├── Manifest.lock │ ├── Pods.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ └── Alria.xcuserdatad │ │ └── xcschemes │ │ ├── AFNetworking.xcscheme │ │ ├── BANetManager.xcscheme │ │ ├── MJExtension.xcscheme │ │ ├── Pods-BANetManager_Example.xcscheme │ │ ├── YYCache.xcscheme │ │ └── xcschememanagement.plist │ ├── Target Support Files │ ├── AFNetworking │ │ ├── AFNetworking-Info.plist │ │ ├── AFNetworking-dummy.m │ │ ├── AFNetworking-prefix.pch │ │ ├── AFNetworking-umbrella.h │ │ ├── AFNetworking.debug.xcconfig │ │ ├── AFNetworking.modulemap │ │ └── AFNetworking.release.xcconfig │ ├── BANetManager │ │ ├── BANetManager-Info.plist │ │ ├── BANetManager-dummy.m │ │ ├── BANetManager-prefix.pch │ │ ├── BANetManager-umbrella.h │ │ ├── BANetManager.debug.xcconfig │ │ ├── BANetManager.modulemap │ │ └── BANetManager.release.xcconfig │ ├── MJExtension │ │ ├── MJExtension-dummy.m │ │ ├── MJExtension-prefix.pch │ │ ├── MJExtension.debug.xcconfig │ │ └── MJExtension.release.xcconfig │ ├── Pods-BANetManager_Example │ │ ├── Pods-BANetManager_Example-Info.plist │ │ ├── Pods-BANetManager_Example-acknowledgements.markdown │ │ ├── Pods-BANetManager_Example-acknowledgements.plist │ │ ├── Pods-BANetManager_Example-dummy.m │ │ ├── Pods-BANetManager_Example-frameworks.sh │ │ ├── Pods-BANetManager_Example-umbrella.h │ │ ├── Pods-BANetManager_Example.debug.xcconfig │ │ ├── Pods-BANetManager_Example.modulemap │ │ └── Pods-BANetManager_Example.release.xcconfig │ └── YYCache │ │ ├── YYCache-Info.plist │ │ ├── YYCache-dummy.m │ │ ├── YYCache-prefix.pch │ │ ├── YYCache-umbrella.h │ │ ├── YYCache.debug.xcconfig │ │ ├── YYCache.modulemap │ │ └── YYCache.release.xcconfig │ └── YYCache │ ├── LICENSE │ ├── README.md │ └── YYCache │ ├── YYCache.h │ ├── YYCache.m │ ├── YYDiskCache.h │ ├── YYDiskCache.m │ ├── YYKVStorage.h │ ├── YYKVStorage.m │ ├── YYMemoryCache.h │ └── YYMemoryCache.m ├── LICENSE ├── README.md └── _Pods.xcodeproj /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BAHome/BANetManager/a010925401658fa8788da6796a870352eb7143b4/.DS_Store -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 3.0 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | script: 3 | - xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO test | xcpretty 4 | after_success: 5 | - bash <(curl -s https://codecov.io/bash) -------------------------------------------------------------------------------- /BANetManager.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint BANetManager.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |spec| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | spec.name = "BANetManager" 19 | spec.version = "2.4.0" 20 | spec.summary = "基于AFNetworking 最新版本的封装,集成了 get / post / put / delete 方法请求数据,单图/多图上传,视频上传/下载,网络监测 等多种网络请求方式," 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | spec.description = <<-DESC 28 | 2020-05-11,适配最新版 AFN 4.0 29 | DESC 30 | 31 | spec.homepage = "https://github.com/boai/BANetManager" 32 | # spec.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 33 | 34 | 35 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 36 | # 37 | # Licensing your code is important. See https://choosealicense.com for more info. 38 | # CocoaPods will detect a license file if there is a named LICENSE* 39 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 40 | # 41 | 42 | # spec.license = "MIT (example)" 43 | spec.license = { :type => 'MIT', :file => 'LICENSE' } 44 | 45 | 46 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 47 | # 48 | # Specify the authors of the library, with email addresses. Email addresses 49 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 50 | # accepts just a name if you'd rather not provide an email address. 51 | # 52 | # Specify a social_media_url where others can refer to, for example a twitter 53 | # profile URL. 54 | # 55 | 56 | spec.authors = { "boai" => "sunboyan@outlook.com" } 57 | # Or just: spec.author = "孙博岩" 58 | # spec.authors = { "孙博岩" => "email@address.com" } 59 | # spec.social_media_url = "https://twitter.com/孙博岩" 60 | spec.social_media_url = "http://weibo.com/538298123" 61 | 62 | 63 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 64 | # 65 | # If this Pod runs only on iOS or OS X, then specify the platform and 66 | # the deployment target. You can optionally include the target after the platform. 67 | # 68 | 69 | spec.platform = :ios, "9.0" 70 | 71 | # When using multiple platforms 72 | # spec.ios.deployment_target = "5.0" 73 | # spec.osx.deployment_target = "10.7" 74 | # spec.watchos.deployment_target = "2.0" 75 | # spec.tvos.deployment_target = "9.0" 76 | 77 | 78 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 79 | # 80 | # Specify the location from where the source should be retrieved. 81 | # Supports git, hg, bzr, svn and HTTP. 82 | # 83 | 84 | spec.source = { :git => "https://github.com/boai/BANetManager.git", :tag => "#{spec.version}" } 85 | 86 | 87 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 88 | # 89 | # CocoaPods is smart about how it includes source code. For source files 90 | # giving a folder will include any swift, h, m, mm, c & cpp files. 91 | # For header files it will include any header in the folder. 92 | # Not including the public_header_files will make all headers public. 93 | # 94 | 95 | spec.source_files = "BANetManager/Classes", "BANetManager/Classes/**/*.{h,m}" 96 | spec.exclude_files = "Classes/Exclude" 97 | 98 | spec.public_header_files = "BANetManager/Classes/**/*.h" 99 | 100 | 101 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 102 | # 103 | # A list of resources included with the Pod. These are copied into the 104 | # target bundle with a build phase script. Anything else will be cleaned. 105 | # You can preserve files from being cleaned, please don't preserve 106 | # non-essential files like tests, examples and documentation. 107 | # 108 | 109 | # spec.resource = "icon.png" 110 | # spec.resources = "Resources/*.png" 111 | 112 | # spec.preserve_paths = "FilesToSave", "MoreFilesToSave" 113 | 114 | 115 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 116 | # 117 | # Link your library with frameworks, or libraries. Libraries do not include 118 | # the lib prefix of their name. 119 | # 120 | 121 | # spec.framework = "SomeFramework" 122 | # spec.frameworks = "SomeFramework", "AnotherFramework" 123 | 124 | # spec.library = "iconv" 125 | # spec.libraries = "iconv", "xml2" 126 | 127 | 128 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 129 | # 130 | # If your library depends on compiler flags you can set them in the xcconfig hash 131 | # where they will only apply to your library. If you depend on other Podspecs 132 | # you can include multiple dependencies to ensure it works. 133 | 134 | spec.requires_arc = true 135 | 136 | # spec.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 137 | # spec.dependency "JSONKit", "~> 1.4" 138 | 139 | 140 | # spec.source_files = 'BANetManager/Classes/**/*.{h,m}' 141 | # spec.public_header_files = 'Pod/Classes/**/*.h' 142 | # 143 | spec.frameworks = 'UIKit' 144 | spec.dependency "AFNetworking" 145 | spec.dependency "YYCache" 146 | 147 | 148 | 149 | end 150 | -------------------------------------------------------------------------------- /BANetManager/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BAHome/BANetManager/a010925401658fa8788da6796a870352eb7143b4/BANetManager/.DS_Store -------------------------------------------------------------------------------- /BANetManager/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BAHome/BANetManager/a010925401658fa8788da6796a870352eb7143b4/BANetManager/Assets/.gitkeep -------------------------------------------------------------------------------- /BANetManager/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BAHome/BANetManager/a010925401658fa8788da6796a870352eb7143b4/BANetManager/Classes/.gitkeep -------------------------------------------------------------------------------- /BANetManager/Classes/BADataEntity.h: -------------------------------------------------------------------------------- 1 | // 2 | // DataEntity.h 3 | // BANetManager 4 | // 5 | // Created by DK on 2017/11/17. 6 | // Copyright © 2017年 boai. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | /** 请求实体,承载请求参数 */ 13 | @interface BADataEntity : NSObject 14 | 15 | /** 请求路径 */ 16 | @property (nonatomic, copy) NSString *urlString; 17 | /** 请求参数 */ 18 | @property (nonatomic, copy) id parameters; 19 | /** 是否缓存响应 */ 20 | @property (nonatomic, assign, getter=isNeedCache) BOOL needCache; 21 | 22 | #pragma mark - 2020-05-11 新增,适配 AFN 4.0 23 | /** 请求头, 适配新版本 */ 24 | @property(nonatomic, strong) NSDictionary *headers; 25 | 26 | /** 27 | 将传入 的 string 参数序列化,body 请求 28 | */ 29 | @property(nonatomic, assign) BOOL isSetQueryStringSerialization; 30 | 31 | @end 32 | 33 | @interface BAFileDataEntity : BADataEntity 34 | 35 | /** 文件名字 */ 36 | @property (nonatomic, copy) NSString *fileName; 37 | 38 | /** 39 | 1、如果是上传操作,为上传文件的本地沙河路径 40 | 2、如果是下载操作,为下载文件保存路径 41 | */ 42 | @property (nonatomic, copy) NSString *filePath; 43 | 44 | @end 45 | 46 | @interface BAImageDataEntity : BADataEntity 47 | 48 | /** 上传的图片数组 */ 49 | @property (nonatomic, copy) NSArray *imageArray; 50 | /** 图片名称 */ 51 | @property (nonatomic, copy) NSArray *fileNames; 52 | /** 图片类型 png、jpg、gif */ 53 | @property (nonatomic, copy) NSString *imageType; 54 | /** 图片压缩比率(0~1.0)*/ 55 | @property (nonatomic, assign) CGFloat imageScale; 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /BANetManager/Classes/BADataEntity.m: -------------------------------------------------------------------------------- 1 | // 2 | // BADataEntity.m 3 | // BANetManager 4 | // 5 | // Created by DK on 2017/11/17. 6 | // Copyright © 2017年 boai. All rights reserved. 7 | // 8 | 9 | #import "BADataEntity.h" 10 | 11 | @implementation BADataEntity 12 | 13 | - (void)dealloc { 14 | // NSLog(@"\n\n 【dealloc %@:%p】\n", NSStringFromClass([self class]), self); 15 | } 16 | 17 | @end 18 | 19 | @implementation BAFileDataEntity 20 | 21 | @end 22 | 23 | @implementation BAImageDataEntity 24 | 25 | @end 26 | 27 | -------------------------------------------------------------------------------- /BANetManager/Classes/BANetManagerCache.h: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * @header BAKit.h 4 | * BABaseProject 5 | * 6 | * @brief BAKit 7 | * 8 | * @author 博爱 9 | * @copyright Copyright © 2016年 博爱. All rights reserved. 10 | * @version V1.0 11 | */ 12 | 13 | // _ooOoo_ 14 | // o8888888o 15 | // 88" . "88 16 | // (| -_- |) 17 | // O\ = /O 18 | // ____/`---'\____ 19 | // . ' \\| |// `. 20 | // / \\||| : |||// \ 21 | // / _||||| -:- |||||- \ 22 | // | | \\\ - /// | | 23 | // | \_| ''\---/'' | | 24 | // \ .-\__ `-` ___/-. / 25 | // ___`. .' /--.--\ `. . __ 26 | // ."" '< `.___\_<|>_/___.' >'"". 27 | // | | : `- \`.;`\ _ /`;.`/ - ` : | | 28 | // \ \ `-. \_ __\ /__ _/ .-` / / 29 | // ======`-.____`-.___\_____/___.-`____.-'====== 30 | // `=---=' 31 | // 32 | // ............................................. 33 | // 佛祖镇楼 BUG辟易 34 | // 佛曰: 35 | // 写字楼里写字间,写字间里程序员; 36 | // 程序人员写程序,又拿程序换酒钱。 37 | // 酒醒只在网上坐,酒醉还来网下眠; 38 | // 酒醉酒醒日复日,网上网下年复年。 39 | // 但愿老死电脑间,不愿鞠躬老板前; 40 | // 奔驰宝马贵者趣,公交自行程序员。 41 | // 别人笑我忒疯癫,我笑自己命太贱; 42 | // 不见满街漂亮妹,哪个归得程序员? 43 | 44 | /* 45 | 46 | ********************************************************************************* 47 | * 48 | * 在使用BAKit的过程中如果出现bug请及时以以下任意一种方式联系我,我会及时修复bug 49 | * 50 | * QQ : 可以添加ios开发技术群 479663605 在这里找到我(博爱1616【137361770】) 51 | * 微博 : 博爱1616 52 | * Email : 137361770@qq.com 53 | * GitHub : https://github.com/boai 54 | * 博客 : http://boaihome.com 55 | 56 | ********************************************************************************* 57 | 58 | */ // 此缓存框架采用网络开源缓存框架 59 | 60 | 61 | #import 62 | #import 63 | 64 | @interface BANetManagerCache : NSObject 65 | 66 | /** 67 | 异步缓存网络数据,根据请求的 url 与 parameters 68 | 69 | @param httpData 服务器返回的数据 70 | @param urlString 请求的 URL 地址 71 | @param parameters 请求的参数 72 | */ 73 | + (void)ba_setHttpCache:(id)httpData 74 | urlString:(NSString *)urlString 75 | parameters:(NSDictionary *)parameters; 76 | 77 | /** 78 | 根据请求的 URL 与 parameters 异步取出缓存数据 79 | 80 | @param urlString 请求的URL 81 | @param parameters 请求的参数 82 | @return 缓存的服务器数据 83 | */ 84 | + (id)ba_httpCacheWithUrlString:(NSString *)urlString 85 | parameters:(NSDictionary *)parameters; 86 | 87 | /** 88 | 根据请求的 URL 与 parameters 异步取出缓存数据 89 | 90 | @param urlString 请求的URL 91 | @param parameters 请求的参数 92 | @param block 异步回调缓存的数据 93 | */ 94 | + (void)ba_httpCacheWithUrlString:(NSString *)urlString 95 | parameters:(NSDictionary *)parameters block:(void(^)(id responseObject))block; 96 | 97 | + (NSString *)ba_cacheWithUrlString:(NSString *)urlString 98 | parameters:(NSDictionary *)parameters; 99 | 100 | /** 101 | 返回此缓存中对象的总成本(以M为单位)。 102 |   此方法可能阻止调用线程,直到文件读取完成。 103 | 104 | @return 总对象的大小(以M为单位)。 105 | */ 106 | + (CGFloat)ba_getAllHttpCacheSize; 107 | 108 | /** 109 | 清空缓存:此方法可能会阻止调用线程,直到文件删除完成。 110 | */ 111 | + (void)ba_clearAllHttpCache; 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /BANetManager/Classes/BANetManagerCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // BANetManagerCache.m 3 | // BANetManagerDemo 4 | // 5 | // Created by boai on 2017/5/2. 6 | // Copyright © 2017年 博爱之家. All rights reserved. 7 | // 8 | 9 | #import "BANetManagerCache.h" 10 | #import "YYCache.h" 11 | 12 | static NSString * const kBANetManagerCache = @"BANetManagerCache"; 13 | static YYCache *_dataCache; 14 | 15 | @implementation BANetManagerCache 16 | 17 | + (void)initialize { 18 | _dataCache = [YYCache cacheWithName:kBANetManagerCache]; 19 | } 20 | 21 | /** 22 | 异步缓存网络数据,根据请求的 url 与 parameters 23 | 24 | @param httpData 服务器返回的数据 25 | @param urlString 请求的 URL 地址 26 | @param parameters 请求的参数 27 | */ 28 | + (void)ba_setHttpCache:(id)httpData 29 | urlString:(NSString *)urlString 30 | parameters:(NSDictionary *)parameters { 31 | NSString *cacheKey = [self ba_cacheWithUrlString:urlString parameters:parameters]; 32 | [_dataCache setObject:httpData forKey:cacheKey]; 33 | } 34 | 35 | /** 36 | 根据请求的 URL 与 parameters 异步取出缓存数据 37 | 38 | @param urlString 请求的URL 39 | @param parameters 请求的参数 40 | @return 缓存的服务器数据 41 | */ 42 | + (id)ba_httpCacheWithUrlString:(NSString *)urlString 43 | parameters:(NSDictionary *)parameters { 44 | NSString *cacheKey = [self ba_cacheWithUrlString:urlString parameters:parameters]; 45 | return [_dataCache objectForKey:cacheKey]; 46 | } 47 | 48 | /** 49 | 根据请求的 URL 与 parameters 异步取出缓存数据 50 | 51 | @param urlString 请求的URL 52 | @param parameters 请求的参数 53 | @param block 异步回调缓存的数据 54 | */ 55 | + (void)ba_httpCacheWithUrlString:(NSString *)urlString 56 | parameters:(NSDictionary *)parameters block:(void(^)(id responseObject))block { 57 | NSString *cacheKey = [self ba_cacheWithUrlString:urlString parameters:parameters]; 58 | [_dataCache objectForKey:cacheKey withBlock:^(NSString * _Nonnull key, id _Nonnull object) { 59 | 60 | dispatch_async(dispatch_get_main_queue(), ^{ 61 | block(object); 62 | }); 63 | }]; 64 | 65 | } 66 | 67 | + (NSString *)ba_cacheWithUrlString:(NSString *)urlString 68 | parameters:(NSDictionary *)parameters { 69 | if (!parameters) { 70 | return urlString; 71 | } 72 | if ([parameters isKindOfClass:[NSDictionary class]]) { 73 | NSData *cacheData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil]; 74 | NSString *cacheString = [[NSString alloc] initWithData:cacheData encoding:NSUTF8StringEncoding]; 75 | 76 | NSString *cacheKey = [NSString stringWithFormat:@"%@%@", urlString, cacheString]; 77 | return cacheKey; 78 | } 79 | return nil; 80 | } 81 | 82 | /** 83 | 返回此缓存中对象的总大小(以M为单位)。 84 |   此方法可能阻止调用线程,直到文件读取完成。 85 | 86 | @return 总对象的大小(以M为单位)。 87 | */ 88 | + (CGFloat)ba_getAllHttpCacheSize { 89 | return [_dataCache.diskCache totalCost]/1024.0/1024.0; 90 | } 91 | 92 | /** 93 | 清空缓存。 94 |   此方法可能会阻止调用线程,直到文件删除完成。 95 | */ 96 | + (void)ba_clearAllHttpCache { 97 | [_dataCache.diskCache removeAllObjects]; 98 | } 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /BANetManager/Classes/BANetManager_OC.h: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * @header BAKit.h 4 | * 5 | * @brief BAKit 6 | * 7 | * @author 博爱 8 | * @copyright Copyright © 2016年 博爱. All rights reserved. 9 | * @version V1.0 10 | */ 11 | 12 | // _ooOoo_ 13 | // o8888888o 14 | // 88" . "88 15 | // (| -_- |) 16 | // O\ = /O 17 | // ____/`---'\____ 18 | // . ' \\| |// `. 19 | // / \\||| : |||// \ 20 | // / _||||| -:- |||||- \ 21 | // | | \\\ - /// | | 22 | // | \_| ''\---/'' | | 23 | // \ .-\__ `-` ___/-. / 24 | // ___`. .' /--.--\ `. . __ 25 | // ."" '< `.___\_<|>_/___.' >'"". 26 | // | | : `- \`.;`\ _ /`;.`/ - ` : | | 27 | // \ \ `-. \_ __\ /__ _/ .-` / / 28 | // ======`-.____`-.___\_____/___.-`____.-'====== 29 | // `=---=' 30 | // 31 | // ............................................. 32 | // 佛祖镇楼 BUG辟易 33 | // 佛曰: 34 | // 写字楼里写字间,写字间里程序员; 35 | // 程序人员写程序,又拿程序换酒钱。 36 | // 酒醒只在网上坐,酒醉还来网下眠; 37 | // 酒醉酒醒日复日,网上网下年复年。 38 | // 但愿老死电脑间,不愿鞠躬老板前; 39 | // 奔驰宝马贵者趣,公交自行程序员。 40 | // 别人笑我忒疯癫,我笑自己命太贱; 41 | // 不见满街漂亮妹,哪个归得程序员? 42 | 43 | /* 44 | 45 | ********************************************************************************* 46 | * 47 | * 在使用 BAKit 的过程中如果出现 bug 请及时以以下任意一种方式联系我,我会及时修复 bug 48 | * 49 | * QQ : 可以添加ios开发技术群 479663605 在这里找到我(博爱1616【137361770】) 50 | * 微博 : 博爱1616 51 | * Email : 137361770@qq.com 52 | * GitHub : https://github.com/boai 53 | * BAHome : https://github.com/BAHome 54 | * 博客 : http://boaihome.com 55 | 56 | ********************************************************************************* 57 | 58 | */ 59 | 60 | 61 | #ifndef BANetManager_OC_h 62 | #define BANetManager_OC_h 63 | 64 | #import "BANetManager.h" 65 | #import "BADataEntity.h" 66 | 67 | #endif /* BANetManager_OC_h */ 68 | -------------------------------------------------------------------------------- /BANetManager/Classes/BANetManager_Version.h: -------------------------------------------------------------------------------- 1 | // 2 | // BANetManager_Version.h 3 | // BANetManager 4 | // 5 | // Created by boai on 2017/11/20. 6 | // Copyright © 2017年 boai. All rights reserved. 7 | // 8 | 9 | #ifndef BANetManager_Version_h 10 | #define BANetManager_Version_h 11 | 12 | /*! 13 | ********************************************************************************* 14 | ************************************ 更新说明 ************************************ 15 | ********************************************************************************* 16 | 17 | 欢迎使用 BAHome 系列开源代码 ! 18 | 如有更多需求,请前往:https://github.com/BAHome 19 | 20 | 项目源码地址: 21 | OC 版 :https://github.com/BAHome/BANetManager 22 | 23 | 最新更新时间:2020-05-1 【倒叙】
24 | 最新Version:【Version:2.4.0】
25 | 更新内容:
26 | 2.4.0.1、全新适配 AFN 4.0,新增 body 请求传参,单个请求自定义 header 27 | 2.4.0.2、优化部分代码,具体详见 demo 28 | 29 | 最新更新时间:2018-05-22 【倒叙】
30 | 最新Version:【Version:2.3.10】
31 | 更新内容:
32 | 2.3.10.1、新增 属性【isOpenLog】(注意:是否开启 log 打印,默认不开启) 33 | 2.3.10.2、优化部分代码 34 | 35 | 最新更新时间:2018-04-16 【倒叙】
36 | 最新Version:【Version:2.3.9】
37 | 更新内容:
38 | 2.3.9.1、新增 isSetQueryStringSerialization 配置参数,可以将传入 的 string 参数序列化,使用方式:BANetManagerShare.isSetQueryStringSerialization = YES,详见【BANetManager.h】文件; 39 | 2.3.9.1、修复 【BANetManagerCache.m】文件中,【+ (NSString *)ba_cacheWithUrlString:(NSString *)urlString parameters:(NSDictionary *)parameters】方法中 parameters 增加了字典的容错判断。 40 | 41 | 最新更新时间:2017-11-20 【倒叙】
42 | 最新Version:【Version:2.3.8】
43 | 更新内容:
44 | 2.3.8.1、【方法替换】原传参方式为 id 类型,现在统一改为 BADataEntity 类型,具体参考 BADataEntity 类,如果更新发现较多错误,敬请谅解,可以恢复至上一版本【Version:2.3.6】,感谢[@北京-晋登科 大神](http://www.jianshu.com/u/1fc1bd217dc5) 的亲自操刀改版!
45 | 2.3.8.2、【方法替换】原图像上传方法传参 精简为 BADataEntity 类下的 BAImageDataEntity 类,具体参考 BAImageDataEntity 类,如果更新发现较多错误,敬请谅解,可以恢复至上一版本【Version:2.3.6】
46 | 2.3.8.3、【方法替换】原文件上传、下载方法传参 精简为 BADataEntity 类下的 BAFileDataEntity 类,具体参考 BAFileDataEntity 类,如果更新发现较多错误,敬请谅解,可以恢复至上一版本【Version:2.3.6】
47 | 2.3.8.4、【新增文件】新增 BAParameterEntity 文件夹,主要处理所有上传所需的参数等信息
48 | 2.3.8.4、【新增文件】新增 BANetManager_Version.h 文件,主要处理所有版本更新内容等信息
49 | 50 | 最新更新时间:2017-09-09 【倒叙】
51 | 最新Version:【Version:2.3.6】
52 | 更新内容:
53 | 2.3.6.1、更换 传参 类型为 id 类型,传参更自由!
54 | 55 | 最新更新时间:2017-08-18 【倒叙】
56 | 最新Version:【Version:2.3.5】
57 | 更新内容:
58 | 2.3.5.1、新增 删除所有缓存的方法,可以自由删除当前的所有缓存!
59 | 60 | 最新更新时间:2017-08-17 【倒叙】
61 | 最新Version:【Version:2.3.4】
62 | 更新内容:
63 | 2.3.4.1、控制台打印 debug 状态下显示中文
64 | 2.3.4.2、移除默认 requestSerializer 和 responseSerializer
65 | 2.3.4.3、新增 post 请求的进度提示
66 | 2.3.4.4、新增 默认请求头:@"application/x-www-form-urlencoded"
67 | 2.3.4.5、优化部分代码规范,给大家带来的不变,敬请谅解!
68 | 69 | 最新更新时间:2017-07-17 【倒叙】
70 | 最新Version:【Version:2.3.3】
71 | 更新内容:
72 | 2.3.3.1、新增 清除 请求头
73 | 2.3.3.2、新增 文件上传
74 | 2.3.3.3、优化多图上传
75 | 76 | 最新更新时间:2017-05-03 【倒叙】
77 | 最新Version:【Version:2.2】
78 | 更新内容:
79 | 2.2.1、优化方法名命名规范 80 | 2.2.2、优化网络状态实时监测 block 回调,去除多余设置,需要网络判断,直接调用block回调即可 81 | 2.2.3、新增 YYCache 缓存处理 82 | 2.2.4、新增自定义:超时设置 83 | 2.2.5、新增自定义:requestSerializer设置 84 | 2.2.6、新增自定义:responseSerializer设置 85 | 2.2.7、新增自定义:请求头设置 86 | 2.2.8、新增自定义 CA 证书 和 HTTPS 请求配置,只需把证书导入项目目录即可,无需设置 87 | 2.2.9、新增史上最全的 AFN 请求 NSLog 打印,详见 demo 控制台打印结果 88 | 2.2.10、新增 DEBUG 模式下的 NSLog 判断,release 下不会打印,请放心使用 89 | 2.2.11、如果打印数据不完整,是因为 Xcode 8 版本问题,请下断点打印数据 90 | 2.2.12、由于新版本改动较大,原有方法命名可能有所改动,希望老用户见谅! 91 | 2.2.13、目前版本较稳定,稍后奉上 pod 版本!请大家耐心等待 92 | 93 | 最新更新时间:2016-11-24 【倒叙】 94 | 最新Version:【Version:2.1】 95 | 更新内容: 96 | 2.1.1、优化方法名命名规范 97 | 2.1.2、新增网络状态实时监测 block 回调,新增单独网络监测 bool 返回,详见 demo 98 | 2.1.3、新增旧方法更新提示 99 | 2.1.4、优化各种注释 100 | 101 | 最新更新时间:2016-11-17 102 | 最新Version:【Version:2.0】 103 | 更新内容: 104 | 2.0.1、优化方法名命名规范 105 | 2.0.2、新增部分注释 106 | 2.0.3、视频上传方法对接,目前有很多项目对接成功 107 | 108 | */ 109 | 110 | 111 | #endif /* BANetManager_Version_h */ 112 | -------------------------------------------------------------------------------- /BANetManager/Classes/UIImage+CompressImage.h: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * @header BAKit.h 4 | * BABaseProject 5 | * 6 | * @brief BAKit 7 | * 8 | * @author 博爱 9 | * @copyright Copyright © 2016年 博爱. All rights reserved. 10 | * @version V1.0 11 | */ 12 | 13 | // _ooOoo_ 14 | // o8888888o 15 | // 88" . "88 16 | // (| -_- |) 17 | // O\ = /O 18 | // ____/`---'\____ 19 | // . ' \\| |// `. 20 | // / \\||| : |||// \ 21 | // / _||||| -:- |||||- \ 22 | // | | \\\ - /// | | 23 | // | \_| ''\---/'' | | 24 | // \ .-\__ `-` ___/-. / 25 | // ___`. .' /--.--\ `. . __ 26 | // ."" '< `.___\_<|>_/___.' >'"". 27 | // | | : `- \`.;`\ _ /`;.`/ - ` : | | 28 | // \ \ `-. \_ __\ /__ _/ .-` / / 29 | // ======`-.____`-.___\_____/___.-`____.-'====== 30 | // `=---=' 31 | // 32 | // ............................................. 33 | // 佛祖镇楼 BUG辟易 34 | // 佛曰: 35 | // 写字楼里写字间,写字间里程序员; 36 | // 程序人员写程序,又拿程序换酒钱。 37 | // 酒醒只在网上坐,酒醉还来网下眠; 38 | // 酒醉酒醒日复日,网上网下年复年。 39 | // 但愿老死电脑间,不愿鞠躬老板前; 40 | // 奔驰宝马贵者趣,公交自行程序员。 41 | // 别人笑我忒疯癫,我笑自己命太贱; 42 | // 不见满街漂亮妹,哪个归得程序员? 43 | 44 | /* 45 | 46 | ********************************************************************************* 47 | * 48 | * 在使用BAKit的过程中如果出现bug请及时以以下任意一种方式联系我,我会及时修复bug 49 | * 50 | * QQ : 可以添加ios开发技术群 479663605 在这里找到我(博爱1616【137361770】) 51 | * 微博 : 博爱1616 52 | * Email : 137361770@qq.com 53 | * GitHub : https://github.com/boai 54 | * 博客园 : http://www.cnblogs.com/boai/ 55 | * 博客 : http://boai.github.io 56 | * 简书 : http://www.jianshu.com/users/95c9800fdf47/latest_articles 57 | * 简书专题 : http://www.jianshu.com/collection/072d578bf782 58 | 59 | ********************************************************************************* 60 | 61 | */ 62 | 63 | 64 | #import 65 | 66 | typedef UIImage JPEGImage; 67 | typedef UIImage PNGImage; 68 | typedef NSData JPEGData; 69 | typedef NSData PNGData; 70 | 71 | @interface UIImage (CompressImage) 72 | /** 73 | * 传入图片,需要的大小,比例,得到压缩图片大小 74 | * 75 | * @prama image 需要压缩的图片 76 | * @prama size 压缩后图片的大小 77 | * @prama scale 压缩的比例 0.0 - 1.0 78 | * 79 | * @return 返回新的图片 80 | */ 81 | + (JPEGImage *)needCompressImage:(UIImage *)image size:(CGSize )size scale:(CGFloat )scale; 82 | + (JPEGImage *)needCompressImageData:(NSData *)imageData size:(CGSize )size scale:(CGFloat )scale; 83 | 84 | /** 85 | * 传入图片,获取中间部分,需要的大小,压缩比例 86 | * 87 | * @prama image 需要压缩的图片 88 | * @prama size 压缩后图片的大小 89 | * @prama scale 压缩的比例 0.0 - 1.0 90 | * 91 | * @return 返回新的图片 92 | */ 93 | + (JPEGImage *)needCenterImage:(UIImage *)image size:(CGSize )size scale:(CGFloat )scale; 94 | 95 | 96 | /** 97 | * png图片转为jpeg(jpg)图片 98 | * 99 | * @prama image 需要转为jpeg的png图片 100 | * 101 | * @return 返回一张jpeg图片 102 | */ 103 | + (JPEGImage *)jpegImageWithPNGImage:(PNGImage *)pngImage; 104 | + (JPEGImage *)jpegImageWithPNGData:(PNGData *)pngData; 105 | + (JPEGData *)jpegDataWithPNGData:(PNGData *)pngData; 106 | + (JPEGData *)jpegDataWithPNGImage:(PNGImage *)pngImage; 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /BANetManager/Classes/UIImage+CompressImage.m: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * @header BAKit.h 4 | * BABaseProject 5 | * 6 | * @brief BAKit 7 | * 8 | * @author 博爱 9 | * @copyright Copyright © 2016年 博爱. All rights reserved. 10 | * @version V1.0 11 | */ 12 | 13 | // _ooOoo_ 14 | // o8888888o 15 | // 88" . "88 16 | // (| -_- |) 17 | // O\ = /O 18 | // ____/`---'\____ 19 | // . ' \\| |// `. 20 | // / \\||| : |||// \ 21 | // / _||||| -:- |||||- \ 22 | // | | \\\ - /// | | 23 | // | \_| ''\---/'' | | 24 | // \ .-\__ `-` ___/-. / 25 | // ___`. .' /--.--\ `. . __ 26 | // ."" '< `.___\_<|>_/___.' >'"". 27 | // | | : `- \`.;`\ _ /`;.`/ - ` : | | 28 | // \ \ `-. \_ __\ /__ _/ .-` / / 29 | // ======`-.____`-.___\_____/___.-`____.-'====== 30 | // `=---=' 31 | // 32 | // ............................................. 33 | // 佛祖镇楼 BUG辟易 34 | // 佛曰: 35 | // 写字楼里写字间,写字间里程序员; 36 | // 程序人员写程序,又拿程序换酒钱。 37 | // 酒醒只在网上坐,酒醉还来网下眠; 38 | // 酒醉酒醒日复日,网上网下年复年。 39 | // 但愿老死电脑间,不愿鞠躬老板前; 40 | // 奔驰宝马贵者趣,公交自行程序员。 41 | // 别人笑我忒疯癫,我笑自己命太贱; 42 | // 不见满街漂亮妹,哪个归得程序员? 43 | 44 | /* 45 | 46 | ********************************************************************************* 47 | * 48 | * 在使用BAKit的过程中如果出现bug请及时以以下任意一种方式联系我,我会及时修复bug 49 | * 50 | * QQ : 可以添加ios开发技术群 479663605 在这里找到我(博爱1616【137361770】) 51 | * 微博 : 博爱1616 52 | * Email : 137361770@qq.com 53 | * GitHub : https://github.com/boai 54 | * 博客园 : http://www.cnblogs.com/boai/ 55 | * 博客 : http://boai.github.io 56 | * 简书 : http://www.jianshu.com/users/95c9800fdf47/latest_articles 57 | * 简书专题 : http://www.jianshu.com/collection/072d578bf782 58 | 59 | ********************************************************************************* 60 | 61 | */ 62 | 63 | 64 | #import "UIImage+CompressImage.h" 65 | 66 | @implementation UIImage (CompressImage) 67 | 68 | +(JPEGImage *)needCompressImage:(UIImage *)image size:(CGSize )size scale:(CGFloat )scale { 69 | JPEGImage *newImage = nil; 70 | //创建画板 71 | UIGraphicsBeginImageContext(size); 72 | 73 | //写入图片 74 | [image drawInRect:CGRectMake(0, 0, size.width, size.height)]; 75 | 76 | //得到新的图片 77 | newImage = UIGraphicsGetImageFromCurrentImageContext(); 78 | 79 | //释放画板 80 | UIGraphicsEndImageContext(); 81 | 82 | //比例压缩 83 | newImage = [UIImage imageWithData:UIImageJPEGRepresentation(newImage, scale)]; 84 | // newImage = [UIImage imageWithData:UIImageJPEGRepresentation(newImage, 1.0) scale:scale]; 85 | 86 | return newImage; 87 | } 88 | 89 | +(JPEGImage *)needCompressImageData:(NSData *)imageData size:(CGSize )size scale:(CGFloat )scale { 90 | PNGImage *image = [UIImage imageWithData:imageData]; 91 | return [UIImage needCompressImage:image size:size scale:scale]; 92 | } 93 | 94 | + (JPEGImage *)needCenterImage:(UIImage *)image size:(CGSize )size scale:(CGFloat )scale { 95 | /* 想切中间部分,待解决 */ 96 | //#warning area of center image 97 | JPEGImage *newImage = nil; 98 | //创建画板 99 | UIGraphicsBeginImageContext(size); 100 | 101 | //写入图片,在中间 102 | [image drawInRect:CGRectMake(0, 0, size.width, size.height)]; 103 | 104 | //得到新的图片 105 | newImage = UIGraphicsGetImageFromCurrentImageContext(); 106 | 107 | //释放画板 108 | UIGraphicsEndImageContext(); 109 | 110 | //比例压缩 111 | newImage = [UIImage imageWithData:UIImageJPEGRepresentation(newImage, scale)]; 112 | 113 | return newImage; 114 | } 115 | 116 | +(JPEGImage *)jpegImageWithPNGImage:(PNGImage *)pngImage { 117 | return [UIImage needCompressImage:pngImage size:pngImage.size scale:1.0]; 118 | } 119 | 120 | +(JPEGImage *)jpegImageWithPNGData:(PNGData *)pngData { 121 | PNGImage *pngImage = [UIImage imageWithData:pngData]; 122 | return [UIImage needCompressImage:pngImage size:pngImage.size scale:1.0]; 123 | } 124 | 125 | +(JPEGData *)jpegDataWithPNGData:(PNGData *)pngData { 126 | return UIImageJPEGRepresentation([UIImage jpegImageWithPNGData:pngData], 1.0); 127 | } 128 | 129 | +(JPEGData *)jpegDataWithPNGImage:(PNGImage *)pngImage { 130 | return UIImageJPEGRepresentation([UIImage jpegImageWithPNGImage:pngImage], 1.0); 131 | } 132 | @end 133 | -------------------------------------------------------------------------------- /Example/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BAHome/BANetManager/a010925401658fa8788da6796a870352eb7143b4/Example/.DS_Store -------------------------------------------------------------------------------- /Example/BANetManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/BANetManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/BANetManager.xcodeproj/xcshareddata/xcschemes/BANetManager-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 42 | 48 | 49 | 50 | 51 | 52 | 62 | 64 | 70 | 71 | 72 | 73 | 79 | 81 | 87 | 88 | 89 | 90 | 92 | 93 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /Example/BANetManager.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/BANetManager.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/BANetManager.xcworkspace/xcuserdata/Alria.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BAHome/BANetManager/a010925401658fa8788da6796a870352eb7143b4/Example/BANetManager.xcworkspace/xcuserdata/Alria.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Example/BANetManager.xcworkspace/xcuserdata/Alria.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Example/BANetManager/BAAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAAppDelegate.h 3 | // BANetManager 4 | // 5 | // Created by boai on 05/11/2020. 6 | // Copyright (c) 2020 boai. All rights reserved. 7 | // 8 | 9 | @import UIKit; 10 | 11 | @interface BAAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Example/BANetManager/BAAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // BAAppDelegate.m 3 | // BANetManager 4 | // 5 | // Created by boai on 05/11/2020. 6 | // Copyright (c) 2020 boai. All rights reserved. 7 | // 8 | 9 | #import "BAAppDelegate.h" 10 | 11 | @implementation BAAppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application 42 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Example/BANetManager/BANetManager-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(MARKETING_VERSION) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(CURRENT_PROJECT_VERSION) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | UIUserInterfaceStyle 49 | Light 50 | NSAppTransportSecurity 51 | 52 | NSAllowsArbitraryLoads 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Example/BANetManager/BANetManager-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | @import UIKit; 15 | @import Foundation; 16 | #endif 17 | -------------------------------------------------------------------------------- /Example/BANetManager/BAViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BAViewController.h 3 | // BANetManager 4 | // 5 | // Created by boai on 05/11/2020. 6 | // Copyright (c) 2020 boai. All rights reserved. 7 | // 8 | 9 | @import UIKit; 10 | 11 | @interface BAViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/BANetManager/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Example/BANetManager/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Example/BANetManager/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Example/BANetManager/Images.xcassets/IMG_0060.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "IMG_0060.JPG", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/BANetManager/Images.xcassets/IMG_0060.imageset/IMG_0060.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BAHome/BANetManager/a010925401658fa8788da6796a870352eb7143b4/Example/BANetManager/Images.xcassets/IMG_0060.imageset/IMG_0060.JPG -------------------------------------------------------------------------------- /Example/BANetManager/Images.xcassets/bg_label.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "bg_label.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/BANetManager/Images.xcassets/bg_label.imageset/bg_label.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BAHome/BANetManager/a010925401658fa8788da6796a870352eb7143b4/Example/BANetManager/Images.xcassets/bg_label.imageset/bg_label.png -------------------------------------------------------------------------------- /Example/BANetManager/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example/BANetManager/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // BANetManager 4 | // 5 | // Created by boai on 05/11/2020. 6 | // Copyright (c) 2020 boai. All rights reserved. 7 | // 8 | 9 | @import UIKit; 10 | #import "BAAppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) 13 | { 14 | @autoreleasepool { 15 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([BAAppDelegate class])); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Example/BANetManager/postdynamic.php: -------------------------------------------------------------------------------- 1 | 200, 43 | "message" =>"上传动态成功" 44 | // "band_count"=>intval('$band_count') 45 | ); 46 | $json = json_encode($data); 47 | echo ($json); 48 | 49 | ?> 50 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | #use_frameworks! 2 | 3 | platform :ios, '9.0' 4 | 5 | target 'BANetManager_Example' do 6 | pod 'BANetManager', :path => '../' 7 | 8 | pod 'AFNetworking' 9 | pod 'YYCache' 10 | pod 'MJExtension' 11 | 12 | end 13 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (4.0.1): 3 | - AFNetworking/NSURLSession (= 4.0.1) 4 | - AFNetworking/Reachability (= 4.0.1) 5 | - AFNetworking/Security (= 4.0.1) 6 | - AFNetworking/Serialization (= 4.0.1) 7 | - AFNetworking/UIKit (= 4.0.1) 8 | - AFNetworking/NSURLSession (4.0.1): 9 | - AFNetworking/Reachability 10 | - AFNetworking/Security 11 | - AFNetworking/Serialization 12 | - AFNetworking/Reachability (4.0.1) 13 | - AFNetworking/Security (4.0.1) 14 | - AFNetworking/Serialization (4.0.1) 15 | - AFNetworking/UIKit (4.0.1): 16 | - AFNetworking/NSURLSession 17 | - BANetManager (2.4.0): 18 | - AFNetworking 19 | - YYCache 20 | - MJExtension (3.2.1) 21 | - YYCache (1.0.4) 22 | 23 | DEPENDENCIES: 24 | - AFNetworking 25 | - BANetManager (from `../`) 26 | - MJExtension 27 | - YYCache 28 | 29 | SPEC REPOS: 30 | trunk: 31 | - AFNetworking 32 | - MJExtension 33 | - YYCache 34 | 35 | EXTERNAL SOURCES: 36 | BANetManager: 37 | :path: "../" 38 | 39 | SPEC CHECKSUMS: 40 | AFNetworking: 7864c38297c79aaca1500c33288e429c3451fdce 41 | BANetManager: 5563b06ed6ac5e75c1bd2589ad19ee48678507d3 42 | MJExtension: 635f2c663dcb1bf76fa4b715b2570a5710aec545 43 | YYCache: 8105b6638f5e849296c71f331ff83891a4942952 44 | 45 | PODFILE CHECKSUM: e40484ccc388d756fa860c8d4bc3db36d82a6bbb 46 | 47 | COCOAPODS: 1.9.1 48 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/AFNetworking/AFCompatibilityMacros.h: -------------------------------------------------------------------------------- 1 | // AFCompatibilityMacros.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #ifndef AFCompatibilityMacros_h 23 | #define AFCompatibilityMacros_h 24 | 25 | #ifdef API_AVAILABLE 26 | #define AF_API_AVAILABLE(...) API_AVAILABLE(__VA_ARGS__) 27 | #else 28 | #define AF_API_AVAILABLE(...) 29 | #endif // API_AVAILABLE 30 | 31 | #ifdef API_UNAVAILABLE 32 | #define AF_API_UNAVAILABLE(...) API_UNAVAILABLE(__VA_ARGS__) 33 | #else 34 | #define AF_API_UNAVAILABLE(...) 35 | #endif // API_UNAVAILABLE 36 | 37 | #if __has_warning("-Wunguarded-availability-new") 38 | #define AF_CAN_USE_AT_AVAILABLE 1 39 | #else 40 | #define AF_CAN_USE_AT_AVAILABLE 0 41 | #endif 42 | 43 | #if ((__IPHONE_OS_VERSION_MAX_ALLOWED && __IPHONE_OS_VERSION_MAX_ALLOWED < 100000) || (__MAC_OS_VERSION_MAX_ALLOWED && __MAC_OS_VERSION_MAX_ALLOWED < 101200) ||(__WATCH_OS_MAX_VERSION_ALLOWED && __WATCH_OS_MAX_VERSION_ALLOWED < 30000) ||(__TV_OS_MAX_VERSION_ALLOWED && __TV_OS_MAX_VERSION_ALLOWED < 100000)) 44 | #define AF_CAN_INCLUDE_SESSION_TASK_METRICS 0 45 | #else 46 | #define AF_CAN_INCLUDE_SESSION_TASK_METRICS 1 47 | #endif 48 | 49 | #endif /* AFCompatibilityMacros_h */ 50 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | // AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import 25 | #import 26 | 27 | #ifndef _AFNETWORKING_ 28 | #define _AFNETWORKING_ 29 | 30 | #import "AFURLRequestSerialization.h" 31 | #import "AFURLResponseSerialization.h" 32 | #import "AFSecurityPolicy.h" 33 | 34 | #if !TARGET_OS_WATCH 35 | #import "AFNetworkReachabilityManager.h" 36 | #endif 37 | 38 | #import "AFURLSessionManager.h" 39 | #import "AFHTTPSessionManager.h" 40 | 41 | #endif /* _AFNETWORKING_ */ 42 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | // AFSecurityPolicy.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | #import 24 | 25 | typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { 26 | AFSSLPinningModeNone, 27 | AFSSLPinningModePublicKey, 28 | AFSSLPinningModeCertificate, 29 | }; 30 | 31 | /** 32 | `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. 33 | 34 | Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. 35 | */ 36 | 37 | NS_ASSUME_NONNULL_BEGIN 38 | 39 | @interface AFSecurityPolicy : NSObject 40 | 41 | /** 42 | The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. 43 | */ 44 | @property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; 45 | 46 | /** 47 | The certificates used to evaluate server trust according to the SSL pinning mode. 48 | 49 | Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches. 50 | 51 | @see policyWithPinningMode:withPinnedCertificates: 52 | */ 53 | @property (nonatomic, strong, nullable) NSSet *pinnedCertificates; 54 | 55 | /** 56 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. 57 | */ 58 | @property (nonatomic, assign) BOOL allowInvalidCertificates; 59 | 60 | /** 61 | Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`. 62 | */ 63 | @property (nonatomic, assign) BOOL validatesDomainName; 64 | 65 | ///----------------------------------------- 66 | /// @name Getting Certificates from the Bundle 67 | ///----------------------------------------- 68 | 69 | /** 70 | Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`. 71 | 72 | @return The certificates included in the given bundle. 73 | */ 74 | + (NSSet *)certificatesInBundle:(NSBundle *)bundle; 75 | 76 | ///----------------------------------------- 77 | /// @name Getting Specific Security Policies 78 | ///----------------------------------------- 79 | 80 | /** 81 | Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys. 82 | 83 | @return The default security policy. 84 | */ 85 | + (instancetype)defaultPolicy; 86 | 87 | ///--------------------- 88 | /// @name Initialization 89 | ///--------------------- 90 | 91 | /** 92 | Creates and returns a security policy with the specified pinning mode. 93 | 94 | Certificates with the `.cer` extension found in the main bundle will be pinned. If you want more control over which certificates are pinned, please use `policyWithPinningMode:withPinnedCertificates:` instead. 95 | 96 | @param pinningMode The SSL pinning mode. 97 | 98 | @return A new security policy. 99 | 100 | @see -policyWithPinningMode:withPinnedCertificates: 101 | */ 102 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; 103 | 104 | /** 105 | Creates and returns a security policy with the specified pinning mode. 106 | 107 | @param pinningMode The SSL pinning mode. 108 | @param pinnedCertificates The certificates to pin against. 109 | 110 | @return A new security policy. 111 | 112 | @see +certificatesInBundle: 113 | @see -pinnedCertificates 114 | */ 115 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates; 116 | 117 | ///------------------------------ 118 | /// @name Evaluating Server Trust 119 | ///------------------------------ 120 | 121 | /** 122 | Whether or not the specified server trust should be accepted, based on the security policy. 123 | 124 | This method should be used when responding to an authentication challenge from a server. 125 | 126 | @param serverTrust The X.509 certificate trust of the server. 127 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated. 128 | 129 | @return Whether or not to trust the server. 130 | */ 131 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust 132 | forDomain:(nullable NSString *)domain; 133 | 134 | @end 135 | 136 | NS_ASSUME_NONNULL_END 137 | 138 | ///---------------- 139 | /// @name Constants 140 | ///---------------- 141 | 142 | /** 143 | ## SSL Pinning Modes 144 | 145 | The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. 146 | 147 | enum { 148 | AFSSLPinningModeNone, 149 | AFSSLPinningModePublicKey, 150 | AFSSLPinningModeCertificate, 151 | } 152 | 153 | `AFSSLPinningModeNone` 154 | Do not used pinned certificates to validate servers. 155 | 156 | `AFSSLPinningModePublicKey` 157 | Validate host certificates against public keys of pinned certificates. 158 | 159 | `AFSSLPinningModeCertificate` 160 | Validate host certificates against pinned certificates. 161 | */ 162 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2020 Alamofire Software Foundation (http://alamofire.org/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | /** 33 | `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a session task has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero. 34 | 35 | You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code: 36 | 37 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; 38 | 39 | By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. 40 | 41 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: 42 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 43 | */ 44 | NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.") 45 | @interface AFNetworkActivityIndicatorManager : NSObject 46 | 47 | /** 48 | A Boolean value indicating whether the manager is enabled. 49 | 50 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. 51 | */ 52 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled; 53 | 54 | /** 55 | A Boolean value indicating whether the network activity indicator manager is currently active. 56 | */ 57 | @property (readonly, nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; 58 | 59 | /** 60 | A time interval indicating the minimum duration of networking activity that should occur before the activity indicator is displayed. The default value 1 second. If the network activity indicator should be displayed immediately when network activity occurs, this value should be set to 0 seconds. 61 | 62 | Apple's HIG describes the following: 63 | 64 | > Display the network activity indicator to provide feedback when your app accesses the network for more than a couple of seconds. If the operation finishes sooner than that, you don’t have to show the network activity indicator, because the indicator is likely to disappear before users notice its presence. 65 | 66 | */ 67 | @property (nonatomic, assign) NSTimeInterval activationDelay; 68 | 69 | /** 70 | A time interval indicating the duration of time of no networking activity required before the activity indicator is disabled. This allows for continuous display of the network activity indicator across multiple requests. The default value is 0.17 seconds. 71 | */ 72 | 73 | @property (nonatomic, assign) NSTimeInterval completionDelay; 74 | 75 | /** 76 | Returns the shared network activity indicator manager object for the system. 77 | 78 | @return The systemwide network activity indicator manager. 79 | */ 80 | + (instancetype)sharedManager; 81 | 82 | /** 83 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. 84 | */ 85 | - (void)incrementActivityCount; 86 | 87 | /** 88 | Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. 89 | */ 90 | - (void)decrementActivityCount; 91 | 92 | /** 93 | Set the a custom method to be executed when the network activity indicator manager should be hidden/shown. By default, this is null, and the UIApplication Network Activity Indicator will be managed automatically. If this block is set, it is the responsiblity of the caller to manager the network activity indicator going forward. 94 | 95 | @param block A block to be executed when the network activity indicator status changes. 96 | */ 97 | - (void)setNetworkingActivityActionWithBlock:(nullable void (^)(BOOL networkActivityIndicatorVisible))block; 98 | 99 | @end 100 | 101 | NS_ASSUME_NONNULL_END 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import 29 | 30 | /** 31 | This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task. 32 | */ 33 | @interface UIActivityIndicatorView (AFNetworking) 34 | 35 | ///---------------------------------- 36 | /// @name Animating for Session Tasks 37 | ///---------------------------------- 38 | 39 | /** 40 | Binds the animating state to the state of the specified task. 41 | 42 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 43 | */ 44 | - (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task; 45 | 46 | @end 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.m 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIActivityIndicatorView+AFNetworking.h" 23 | #import 24 | 25 | #if TARGET_OS_IOS || TARGET_OS_TV 26 | 27 | #import "AFURLSessionManager.h" 28 | 29 | @interface AFActivityIndicatorViewNotificationObserver : NSObject 30 | @property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView; 31 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView; 32 | 33 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; 34 | 35 | @end 36 | 37 | @implementation UIActivityIndicatorView (AFNetworking) 38 | 39 | - (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver { 40 | AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); 41 | if (notificationObserver == nil) { 42 | notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self]; 43 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 44 | } 45 | return notificationObserver; 46 | } 47 | 48 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 49 | [[self af_notificationObserver] setAnimatingWithStateOfTask:task]; 50 | } 51 | 52 | @end 53 | 54 | @implementation AFActivityIndicatorViewNotificationObserver 55 | 56 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView 57 | { 58 | self = [super init]; 59 | if (self) { 60 | _activityIndicatorView = activityIndicatorView; 61 | } 62 | return self; 63 | } 64 | 65 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 66 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 67 | 68 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 69 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 70 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 71 | 72 | if (task) { 73 | if (task.state != NSURLSessionTaskStateCompleted) { 74 | UIActivityIndicatorView *activityIndicatorView = self.activityIndicatorView; 75 | if (task.state == NSURLSessionTaskStateRunning) { 76 | [activityIndicatorView startAnimating]; 77 | } else { 78 | [activityIndicatorView stopAnimating]; 79 | } 80 | 81 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; 82 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; 83 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; 84 | } 85 | } 86 | } 87 | 88 | #pragma mark - 89 | 90 | - (void)af_startAnimating { 91 | dispatch_async(dispatch_get_main_queue(), ^{ 92 | [self.activityIndicatorView startAnimating]; 93 | }); 94 | } 95 | 96 | - (void)af_stopAnimating { 97 | dispatch_async(dispatch_get_main_queue(), ^{ 98 | [self.activityIndicatorView stopAnimating]; 99 | }); 100 | } 101 | 102 | #pragma mark - 103 | 104 | - (void)dealloc { 105 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 106 | 107 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 108 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 109 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 110 | } 111 | 112 | @end 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIImageView+AFNetworking.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @class AFImageDownloader; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL. 36 | */ 37 | @interface UIImageView (AFNetworking) 38 | 39 | ///------------------------------------ 40 | /// @name Accessing the Image Downloader 41 | ///------------------------------------ 42 | 43 | /** 44 | Set the shared image downloader used to download images. 45 | 46 | @param imageDownloader The shared image downloader used to download images. 47 | */ 48 | + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader; 49 | 50 | /** 51 | The shared image downloader used to download images. 52 | */ 53 | + (AFImageDownloader *)sharedImageDownloader; 54 | 55 | ///-------------------- 56 | /// @name Setting Image 57 | ///-------------------- 58 | 59 | /** 60 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 61 | 62 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 63 | 64 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` 65 | 66 | @param url The URL used for the image request. 67 | */ 68 | - (void)setImageWithURL:(NSURL *)url; 69 | 70 | /** 71 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 72 | 73 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 74 | 75 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` 76 | 77 | @param url The URL used for the image request. 78 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. 79 | */ 80 | - (void)setImageWithURL:(NSURL *)url 81 | placeholderImage:(nullable UIImage *)placeholderImage; 82 | 83 | /** 84 | Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 85 | 86 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 87 | 88 | If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied. 89 | 90 | @param urlRequest The URL request used for the image request. 91 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. 92 | @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. 93 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. 94 | */ 95 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest 96 | placeholderImage:(nullable UIImage *)placeholderImage 97 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success 98 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; 99 | 100 | /** 101 | Cancels any executing image operation for the receiver, if one exists. 102 | */ 103 | - (void)cancelImageDownloadTask; 104 | 105 | @end 106 | 107 | NS_ASSUME_NONNULL_END 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIKit+AFNetworking.h 2 | // 3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #ifndef _UIKIT_AFNETWORKING_ 26 | #define _UIKIT_AFNETWORKING_ 27 | 28 | #if TARGET_OS_IOS || TARGET_OS_TV 29 | #import "AFAutoPurgingImageCache.h" 30 | #import "AFImageDownloader.h" 31 | #import "UIActivityIndicatorView+AFNetworking.h" 32 | #import "UIButton+AFNetworking.h" 33 | #import "UIImageView+AFNetworking.h" 34 | #import "UIProgressView+AFNetworking.h" 35 | #endif 36 | 37 | #if TARGET_OS_IOS 38 | #import "AFNetworkActivityIndicatorManager.h" 39 | #import "UIRefreshControl+AFNetworking.h" 40 | #import "WKWebView+AFNetworking.h" 41 | #endif 42 | 43 | #endif /* _UIKIT_AFNETWORKING_ */ 44 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task. 35 | */ 36 | @interface UIProgressView (AFNetworking) 37 | 38 | ///------------------------------------ 39 | /// @name Setting Session Task Progress 40 | ///------------------------------------ 41 | 42 | /** 43 | Binds the progress to the upload progress of the specified session task. 44 | 45 | @param task The session task. 46 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 47 | */ 48 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 49 | animated:(BOOL)animated; 50 | 51 | /** 52 | Binds the progress to the download progress of the specified session task. 53 | 54 | @param task The session task. 55 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 56 | */ 57 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 58 | animated:(BOOL)animated; 59 | 60 | @end 61 | 62 | NS_ASSUME_NONNULL_END 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.m 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIProgressView+AFNetworking.h" 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import "AFURLSessionManager.h" 29 | 30 | static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext; 31 | static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext; 32 | 33 | #pragma mark - 34 | 35 | @implementation UIProgressView (AFNetworking) 36 | 37 | - (BOOL)af_uploadProgressAnimated { 38 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue]; 39 | } 40 | 41 | - (void)af_setUploadProgressAnimated:(BOOL)animated { 42 | objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 43 | } 44 | 45 | - (BOOL)af_downloadProgressAnimated { 46 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue]; 47 | } 48 | 49 | - (void)af_setDownloadProgressAnimated:(BOOL)animated { 50 | objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 51 | } 52 | 53 | #pragma mark - 54 | 55 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 56 | animated:(BOOL)animated 57 | { 58 | if (task.state == NSURLSessionTaskStateCompleted) { 59 | return; 60 | } 61 | 62 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; 63 | [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; 64 | 65 | [self af_setUploadProgressAnimated:animated]; 66 | } 67 | 68 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 69 | animated:(BOOL)animated 70 | { 71 | if (task.state == NSURLSessionTaskStateCompleted) { 72 | return; 73 | } 74 | 75 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; 76 | [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; 77 | 78 | [self af_setDownloadProgressAnimated:animated]; 79 | } 80 | 81 | #pragma mark - NSKeyValueObserving 82 | 83 | - (void)observeValueForKeyPath:(NSString *)keyPath 84 | ofObject:(id)object 85 | change:(__unused NSDictionary *)change 86 | context:(void *)context 87 | { 88 | if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) { 89 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { 90 | if ([object countOfBytesExpectedToSend] > 0) { 91 | dispatch_async(dispatch_get_main_queue(), ^{ 92 | [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated]; 93 | }); 94 | } 95 | } 96 | 97 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { 98 | if ([object countOfBytesExpectedToReceive] > 0) { 99 | dispatch_async(dispatch_get_main_queue(), ^{ 100 | [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated]; 101 | }); 102 | } 103 | } 104 | 105 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) { 106 | if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) { 107 | @try { 108 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))]; 109 | 110 | if (context == AFTaskCountOfBytesSentContext) { 111 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; 112 | } 113 | 114 | if (context == AFTaskCountOfBytesReceivedContext) { 115 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; 116 | } 117 | } 118 | @catch (NSException * __unused exception) {} 119 | } 120 | } 121 | } 122 | } 123 | 124 | @end 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import 26 | 27 | #if TARGET_OS_IOS 28 | 29 | #import 30 | 31 | NS_ASSUME_NONNULL_BEGIN 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a session task. 35 | */ 36 | @interface UIRefreshControl (AFNetworking) 37 | 38 | ///----------------------------------- 39 | /// @name Refreshing for Session Tasks 40 | ///----------------------------------- 41 | 42 | /** 43 | Binds the refreshing state to the state of the specified task. 44 | 45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 46 | */ 47 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 48 | 49 | @end 50 | 51 | NS_ASSUME_NONNULL_END 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "UIRefreshControl+AFNetworking.h" 24 | #import 25 | 26 | #if TARGET_OS_IOS 27 | 28 | #import "AFURLSessionManager.h" 29 | 30 | @interface AFRefreshControlNotificationObserver : NSObject 31 | @property (readonly, nonatomic, weak) UIRefreshControl *refreshControl; 32 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl; 33 | 34 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 35 | 36 | @end 37 | 38 | @implementation UIRefreshControl (AFNetworking) 39 | 40 | - (AFRefreshControlNotificationObserver *)af_notificationObserver { 41 | AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); 42 | if (notificationObserver == nil) { 43 | notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self]; 44 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 45 | } 46 | return notificationObserver; 47 | } 48 | 49 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 50 | [[self af_notificationObserver] setRefreshingWithStateOfTask:task]; 51 | } 52 | 53 | @end 54 | 55 | @implementation AFRefreshControlNotificationObserver 56 | 57 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl 58 | { 59 | self = [super init]; 60 | if (self) { 61 | _refreshControl = refreshControl; 62 | } 63 | return self; 64 | } 65 | 66 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 67 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 68 | 69 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 70 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 71 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 72 | 73 | if (task) { 74 | UIRefreshControl *refreshControl = self.refreshControl; 75 | if (task.state == NSURLSessionTaskStateRunning) { 76 | [refreshControl beginRefreshing]; 77 | 78 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; 79 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; 80 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; 81 | } else { 82 | [refreshControl endRefreshing]; 83 | } 84 | } 85 | } 86 | 87 | #pragma mark - 88 | 89 | - (void)af_beginRefreshing { 90 | dispatch_async(dispatch_get_main_queue(), ^{ 91 | [self.refreshControl beginRefreshing]; 92 | }); 93 | } 94 | 95 | - (void)af_endRefreshing { 96 | dispatch_async(dispatch_get_main_queue(), ^{ 97 | [self.refreshControl endRefreshing]; 98 | }); 99 | } 100 | 101 | #pragma mark - 102 | 103 | - (void)dealloc { 104 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 105 | 106 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 107 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 108 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 109 | } 110 | 111 | @end 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /Example/Pods/AFNetworking/UIKit+AFNetworking/WKWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // WkWebView+AFNetworking.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS 27 | 28 | #import 29 | #import 30 | 31 | NS_ASSUME_NONNULL_BEGIN 32 | 33 | @class AFHTTPSessionManager; 34 | 35 | @interface WKWebView (AFNetworking) 36 | 37 | /** 38 | The session manager used to download all request 39 | */ 40 | @property (nonatomic, strong) AFHTTPSessionManager *sessionManager; 41 | 42 | /** 43 | Asynchronously loads the specified request. 44 | 45 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 46 | @param navigation The WKNavigation object that containts information for tracking the loading progress of a webpage. This must not be `nil`. 47 | @param progress A progress object monitoring the current download progress. 48 | @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string. 49 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 50 | */ 51 | - (void)loadRequest:(NSURLRequest *)request 52 | navigation:(WKNavigation * _Nonnull)navigation 53 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress 54 | success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 55 | failure:(nullable void (^)(NSError *error))failure; 56 | 57 | /** 58 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. 59 | 60 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 61 | @param navigation The WKNavigation object that containts information for tracking the loading progress of a webpage. This must not be `nil`. 62 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. 63 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. 64 | @param progress A progress object monitoring the current download progress. 65 | @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data. 66 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 67 | */ 68 | - (void)loadRequest:(NSURLRequest *)request 69 | navigation:(WKNavigation * _Nonnull)navigation 70 | MIMEType:(nullable NSString *)MIMEType 71 | textEncodingName:(nullable NSString *)textEncodingName 72 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress 73 | success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 74 | failure:(nullable void (^)(NSError *error))failure; 75 | 76 | @end 77 | 78 | NS_ASSUME_NONNULL_END 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/AFAutoPurgingImageCache.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/AFCompatibilityMacros.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFCompatibilityMacros.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/AFImageDownloader.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFImageDownloader.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/AFNetworking/WKWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/WKWebView+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/BANetManager/BADataEntity.h: -------------------------------------------------------------------------------- 1 | ../../../../../BANetManager/Classes/BADataEntity.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/BANetManager/BANetManager.h: -------------------------------------------------------------------------------- 1 | ../../../../../BANetManager/Classes/BANetManager.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/BANetManager/BANetManagerCache.h: -------------------------------------------------------------------------------- 1 | ../../../../../BANetManager/Classes/BANetManagerCache.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/BANetManager/BANetManager_OC.h: -------------------------------------------------------------------------------- 1 | ../../../../../BANetManager/Classes/BANetManager_OC.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/BANetManager/BANetManager_Version.h: -------------------------------------------------------------------------------- 1 | ../../../../../BANetManager/Classes/BANetManager_Version.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/BANetManager/UIImage+CompressImage.h: -------------------------------------------------------------------------------- 1 | ../../../../../BANetManager/Classes/UIImage+CompressImage.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/MJExtension/MJExtension.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/MJExtension.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/MJExtension/MJExtensionConst.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/MJExtensionConst.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/MJExtension/MJFoundation.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/MJFoundation.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/MJExtension/MJProperty.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/MJProperty.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/MJExtension/MJPropertyKey.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/MJPropertyKey.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/MJExtension/MJPropertyType.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/MJPropertyType.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/MJExtension/NSObject+MJClass.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/NSObject+MJClass.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/MJExtension/NSObject+MJCoding.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/NSObject+MJCoding.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/MJExtension/NSObject+MJKeyValue.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/NSObject+MJKeyValue.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/MJExtension/NSObject+MJProperty.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/NSObject+MJProperty.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/MJExtension/NSString+MJExtension.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/NSString+MJExtension.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/YYCache/YYCache.h: -------------------------------------------------------------------------------- 1 | ../../../YYCache/YYCache/YYCache.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/YYCache/YYDiskCache.h: -------------------------------------------------------------------------------- 1 | ../../../YYCache/YYCache/YYDiskCache.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/YYCache/YYKVStorage.h: -------------------------------------------------------------------------------- 1 | ../../../YYCache/YYCache/YYKVStorage.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/YYCache/YYMemoryCache.h: -------------------------------------------------------------------------------- 1 | ../../../YYCache/YYCache/YYMemoryCache.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/AFAutoPurgingImageCache.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/AFCompatibilityMacros.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFCompatibilityMacros.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/AFImageDownloader.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFImageDownloader.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/AFNetworking/WKWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/WKWebView+AFNetworking.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/BANetManager/BADataEntity.h: -------------------------------------------------------------------------------- 1 | ../../../../../BANetManager/Classes/BADataEntity.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/BANetManager/BANetManager.h: -------------------------------------------------------------------------------- 1 | ../../../../../BANetManager/Classes/BANetManager.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/BANetManager/BANetManagerCache.h: -------------------------------------------------------------------------------- 1 | ../../../../../BANetManager/Classes/BANetManagerCache.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/BANetManager/BANetManager_OC.h: -------------------------------------------------------------------------------- 1 | ../../../../../BANetManager/Classes/BANetManager_OC.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/BANetManager/BANetManager_Version.h: -------------------------------------------------------------------------------- 1 | ../../../../../BANetManager/Classes/BANetManager_Version.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/BANetManager/UIImage+CompressImage.h: -------------------------------------------------------------------------------- 1 | ../../../../../BANetManager/Classes/UIImage+CompressImage.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/MJExtension/MJExtension.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/MJExtension.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/MJExtension/MJExtensionConst.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/MJExtensionConst.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/MJExtension/MJFoundation.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/MJFoundation.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/MJExtension/MJProperty.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/MJProperty.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/MJExtension/MJPropertyKey.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/MJPropertyKey.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/MJExtension/MJPropertyType.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/MJPropertyType.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/MJExtension/NSObject+MJClass.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/NSObject+MJClass.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/MJExtension/NSObject+MJCoding.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/NSObject+MJCoding.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/MJExtension/NSObject+MJKeyValue.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/NSObject+MJKeyValue.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/MJExtension/NSObject+MJProperty.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/NSObject+MJProperty.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/MJExtension/NSString+MJExtension.h: -------------------------------------------------------------------------------- 1 | ../../../MJExtension/MJExtension/NSString+MJExtension.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/YYCache/YYCache.h: -------------------------------------------------------------------------------- 1 | ../../../YYCache/YYCache/YYCache.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/YYCache/YYDiskCache.h: -------------------------------------------------------------------------------- 1 | ../../../YYCache/YYCache/YYDiskCache.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/YYCache/YYKVStorage.h: -------------------------------------------------------------------------------- 1 | ../../../YYCache/YYCache/YYKVStorage.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/YYCache/YYMemoryCache.h: -------------------------------------------------------------------------------- 1 | ../../../YYCache/YYCache/YYMemoryCache.h -------------------------------------------------------------------------------- /Example/Pods/Local Podspecs/BANetManager.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BANetManager", 3 | "version": "2.4.0", 4 | "summary": "基于AFNetworking 3.0、3.1最新版本的封装,集成了 get / post / put / delete 方法请求数据,单图/多图上传,视频上传/下载,网络监测 等多种网络请求方式,", 5 | "description": "2020-05-11,适配最新版 AFN 4.0", 6 | "homepage": "https://github.com/boai/BANetManager", 7 | "license": { 8 | "type": "MIT", 9 | "file": "LICENSE" 10 | }, 11 | "authors": { 12 | "boai": "sunboyan@outlook.com" 13 | }, 14 | "social_media_url": "http://weibo.com/538298123", 15 | "platforms": { 16 | "ios": "9.0" 17 | }, 18 | "source": { 19 | "git": "https://github.com/boai/BANetManager.git", 20 | "tag": "2.4.0" 21 | }, 22 | "source_files": [ 23 | "BANetManager/Classes", 24 | "BANetManager/Classes/**/*.{h,m}" 25 | ], 26 | "exclude_files": "Classes/Exclude", 27 | "public_header_files": "BANetManager/Classes/**/*.h", 28 | "requires_arc": true, 29 | "frameworks": "UIKit", 30 | "dependencies": { 31 | "AFNetworking": [ 32 | 33 | ], 34 | "YYCache": [ 35 | 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2019 MJExtension (https://github.com/CoderMJLee/MJExtension) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/MJExtension.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJExtension.h 3 | // MJExtension 4 | // 5 | // Created by mj on 14-1-15. 6 | // Copyright (c) 2014年 小码哥. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSObject+MJCoding.h" 11 | #import "NSObject+MJProperty.h" 12 | #import "NSObject+MJClass.h" 13 | #import "NSObject+MJKeyValue.h" 14 | #import "NSString+MJExtension.h" 15 | #import "MJExtensionConst.h" 16 | 17 | #import "MJFoundation.h" 18 | 19 | //! Project version number for MJExtension. 20 | FOUNDATION_EXPORT double MJExtensionVersionNumber; 21 | 22 | //! Project version string for MJExtension. 23 | FOUNDATION_EXPORT const unsigned char MJExtensionVersionString[]; 24 | 25 | // In this header, you should import all the public headers of your framework using statements like #import 26 | 27 | 28 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/MJExtensionConst.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __MJExtensionConst__H__ 3 | #define __MJExtensionConst__H__ 4 | 5 | #import 6 | 7 | #ifndef MJ_LOCK 8 | #define MJ_LOCK(lock) dispatch_semaphore_wait(lock, DISPATCH_TIME_FOREVER); 9 | #endif 10 | 11 | #ifndef MJ_UNLOCK 12 | #define MJ_UNLOCK(lock) dispatch_semaphore_signal(lock); 13 | #endif 14 | 15 | // 信号量 16 | #define MJExtensionSemaphoreCreate \ 17 | static dispatch_semaphore_t signalSemaphore; \ 18 | static dispatch_once_t onceTokenSemaphore; \ 19 | dispatch_once(&onceTokenSemaphore, ^{ \ 20 | signalSemaphore = dispatch_semaphore_create(1); \ 21 | }); 22 | 23 | #define MJExtensionSemaphoreWait MJ_LOCK(signalSemaphore) 24 | #define MJExtensionSemaphoreSignal MJ_UNLOCK(signalSemaphore) 25 | 26 | // 过期 27 | #define MJExtensionDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead) 28 | 29 | // 构建错误 30 | #define MJExtensionBuildError(clazz, msg) \ 31 | NSError *error = [NSError errorWithDomain:msg code:250 userInfo:nil]; \ 32 | [clazz setMj_error:error]; 33 | 34 | // 日志输出 35 | #ifdef DEBUG 36 | #define MJExtensionLog(...) NSLog(__VA_ARGS__) 37 | #else 38 | #define MJExtensionLog(...) 39 | #endif 40 | 41 | /** 42 | * 断言 43 | * @param condition 条件 44 | * @param returnValue 返回值 45 | */ 46 | #define MJExtensionAssertError(condition, returnValue, clazz, msg) \ 47 | [clazz setMj_error:nil]; \ 48 | if ((condition) == NO) { \ 49 | MJExtensionBuildError(clazz, msg); \ 50 | return returnValue;\ 51 | } 52 | 53 | #define MJExtensionAssert2(condition, returnValue) \ 54 | if ((condition) == NO) return returnValue; 55 | 56 | /** 57 | * 断言 58 | * @param condition 条件 59 | */ 60 | #define MJExtensionAssert(condition) MJExtensionAssert2(condition, ) 61 | 62 | /** 63 | * 断言 64 | * @param param 参数 65 | * @param returnValue 返回值 66 | */ 67 | #define MJExtensionAssertParamNotNil2(param, returnValue) \ 68 | MJExtensionAssert2((param) != nil, returnValue) 69 | 70 | /** 71 | * 断言 72 | * @param param 参数 73 | */ 74 | #define MJExtensionAssertParamNotNil(param) MJExtensionAssertParamNotNil2(param, ) 75 | 76 | /** 77 | * 打印所有的属性 78 | */ 79 | #define MJLogAllIvars \ 80 | - (NSString *)description \ 81 | { \ 82 | return [self mj_keyValues].description; \ 83 | } 84 | #define MJExtensionLogAllProperties MJLogAllIvars 85 | 86 | /** 仅在 Debugger 展示所有的属性 */ 87 | #define MJImplementDebugDescription \ 88 | - (NSString *)debugDescription \ 89 | { \ 90 | return [self mj_keyValues].debugDescription; \ 91 | } 92 | 93 | /** 94 | * 类型(属性类型) 95 | */ 96 | FOUNDATION_EXPORT NSString *const MJPropertyTypeInt; 97 | FOUNDATION_EXPORT NSString *const MJPropertyTypeShort; 98 | FOUNDATION_EXPORT NSString *const MJPropertyTypeFloat; 99 | FOUNDATION_EXPORT NSString *const MJPropertyTypeDouble; 100 | FOUNDATION_EXPORT NSString *const MJPropertyTypeLong; 101 | FOUNDATION_EXPORT NSString *const MJPropertyTypeLongLong; 102 | FOUNDATION_EXPORT NSString *const MJPropertyTypeChar; 103 | FOUNDATION_EXPORT NSString *const MJPropertyTypeBOOL1; 104 | FOUNDATION_EXPORT NSString *const MJPropertyTypeBOOL2; 105 | FOUNDATION_EXPORT NSString *const MJPropertyTypePointer; 106 | 107 | FOUNDATION_EXPORT NSString *const MJPropertyTypeIvar; 108 | FOUNDATION_EXPORT NSString *const MJPropertyTypeMethod; 109 | FOUNDATION_EXPORT NSString *const MJPropertyTypeBlock; 110 | FOUNDATION_EXPORT NSString *const MJPropertyTypeClass; 111 | FOUNDATION_EXPORT NSString *const MJPropertyTypeSEL; 112 | FOUNDATION_EXPORT NSString *const MJPropertyTypeId; 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/MJExtensionConst.m: -------------------------------------------------------------------------------- 1 | #ifndef __MJExtensionConst__M__ 2 | #define __MJExtensionConst__M__ 3 | 4 | #import 5 | 6 | /** 7 | * 成员变量类型(属性类型) 8 | */ 9 | NSString *const MJPropertyTypeInt = @"i"; 10 | NSString *const MJPropertyTypeShort = @"s"; 11 | NSString *const MJPropertyTypeFloat = @"f"; 12 | NSString *const MJPropertyTypeDouble = @"d"; 13 | NSString *const MJPropertyTypeLong = @"l"; 14 | NSString *const MJPropertyTypeLongLong = @"q"; 15 | NSString *const MJPropertyTypeChar = @"c"; 16 | NSString *const MJPropertyTypeBOOL1 = @"c"; 17 | NSString *const MJPropertyTypeBOOL2 = @"b"; 18 | NSString *const MJPropertyTypePointer = @"*"; 19 | 20 | NSString *const MJPropertyTypeIvar = @"^{objc_ivar=}"; 21 | NSString *const MJPropertyTypeMethod = @"^{objc_method=}"; 22 | NSString *const MJPropertyTypeBlock = @"@?"; 23 | NSString *const MJPropertyTypeClass = @"#"; 24 | NSString *const MJPropertyTypeSEL = @":"; 25 | NSString *const MJPropertyTypeId = @"@"; 26 | 27 | #endif -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/MJFoundation.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJFoundation.h 3 | // MJExtensionExample 4 | // 5 | // Created by MJ Lee on 14/7/16. 6 | // Copyright (c) 2014年 小码哥. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MJFoundation : NSObject 12 | 13 | + (BOOL)isClassFromFoundation:(Class)c; 14 | + (BOOL)isFromNSObjectProtocolProperty:(NSString *)propertyName; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/MJFoundation.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJFoundation.m 3 | // MJExtensionExample 4 | // 5 | // Created by MJ Lee on 14/7/16. 6 | // Copyright (c) 2014年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJFoundation.h" 10 | #import "MJExtensionConst.h" 11 | #import 12 | #import "objc/runtime.h" 13 | 14 | @implementation MJFoundation 15 | 16 | + (BOOL)isClassFromFoundation:(Class)c 17 | { 18 | if (c == [NSObject class] || c == [NSManagedObject class]) return YES; 19 | 20 | static NSSet *foundationClasses; 21 | static dispatch_once_t onceToken; 22 | dispatch_once(&onceToken, ^{ 23 | // 集合中没有NSObject,因为几乎所有的类都是继承自NSObject,具体是不是NSObject需要特殊判断 24 | foundationClasses = [NSSet setWithObjects: 25 | [NSURL class], 26 | [NSDate class], 27 | [NSValue class], 28 | [NSData class], 29 | [NSError class], 30 | [NSArray class], 31 | [NSDictionary class], 32 | [NSString class], 33 | [NSAttributedString class], nil]; 34 | }); 35 | 36 | __block BOOL result = NO; 37 | [foundationClasses enumerateObjectsUsingBlock:^(Class foundationClass, BOOL *stop) { 38 | if ([c isSubclassOfClass:foundationClass]) { 39 | result = YES; 40 | *stop = YES; 41 | } 42 | }]; 43 | return result; 44 | } 45 | 46 | + (BOOL)isFromNSObjectProtocolProperty:(NSString *)propertyName 47 | { 48 | if (!propertyName) return NO; 49 | 50 | static NSSet *objectProtocolPropertyNames; 51 | static dispatch_once_t onceToken; 52 | dispatch_once(&onceToken, ^{ 53 | unsigned int count = 0; 54 | objc_property_t *propertyList = protocol_copyPropertyList(@protocol(NSObject), &count); 55 | NSMutableSet *propertyNames = [NSMutableSet setWithCapacity:count]; 56 | for (int i = 0; i < count; i++) { 57 | objc_property_t property = propertyList[i]; 58 | NSString *propertyName = [NSString stringWithCString:property_getName(property) encoding:NSUTF8StringEncoding]; 59 | if (propertyName) { 60 | [propertyNames addObject:propertyName]; 61 | } 62 | } 63 | objectProtocolPropertyNames = [propertyNames copy]; 64 | free(propertyList); 65 | }); 66 | 67 | return [objectProtocolPropertyNames containsObject:propertyName]; 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/MJProperty.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJProperty.h 3 | // MJExtensionExample 4 | // 5 | // Created by MJ Lee on 15/4/17. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 包装一个成员属性 8 | 9 | #import 10 | #import 11 | #import "MJPropertyType.h" 12 | #import "MJPropertyKey.h" 13 | 14 | /** 15 | * 包装一个成员 16 | */ 17 | @interface MJProperty : NSObject 18 | /** 成员属性 */ 19 | @property (nonatomic, assign) objc_property_t property; 20 | /** 成员属性的名字 */ 21 | @property (nonatomic, readonly) NSString *name; 22 | 23 | /** 成员属性的类型 */ 24 | @property (nonatomic, readonly) MJPropertyType *type; 25 | /** 成员属性来源于哪个类(可能是父类) */ 26 | @property (nonatomic, assign) Class srcClass; 27 | 28 | /**** 同一个成员属性 - 父类和子类的行为可能不一致(originKey、propertyKeys、objectClassInArray) ****/ 29 | /** 设置最原始的key */ 30 | - (void)setOriginKey:(id)originKey forClass:(Class)c; 31 | /** 对应着字典中的多级key(里面存放的数组,数组里面都是MJPropertyKey对象) */ 32 | - (NSArray *)propertyKeysForClass:(Class)c; 33 | 34 | /** 模型数组中的模型类型 */ 35 | - (void)setObjectClassInArray:(Class)objectClass forClass:(Class)c; 36 | - (Class)objectClassInArrayForClass:(Class)c; 37 | /**** 同一个成员变量 - 父类和子类的行为可能不一致(key、keys、objectClassInArray) ****/ 38 | 39 | /** 40 | * 设置object的成员变量值 41 | */ 42 | - (void)setValue:(id)value forObject:(id)object; 43 | /** 44 | * 得到object的成员属性值 45 | */ 46 | - (id)valueForObject:(id)object; 47 | 48 | /** 49 | * 初始化 50 | */ 51 | + (instancetype)cachedPropertyWithProperty:(objc_property_t)property; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/MJPropertyKey.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJPropertyKey.h 3 | // MJExtensionExample 4 | // 5 | // Created by MJ Lee on 15/8/11. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef enum { 12 | MJPropertyKeyTypeDictionary = 0, // 字典的key 13 | MJPropertyKeyTypeArray // 数组的key 14 | } MJPropertyKeyType; 15 | 16 | /** 17 | * 属性的key 18 | */ 19 | @interface MJPropertyKey : NSObject 20 | /** key的名字 */ 21 | @property (copy, nonatomic) NSString *name; 22 | /** key的种类,可能是@"10",可能是@"age" */ 23 | @property (assign, nonatomic) MJPropertyKeyType type; 24 | 25 | /** 26 | * 根据当前的key,也就是name,从object(字典或者数组)中取值 27 | */ 28 | - (id)valueInObject:(id)object; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/MJPropertyKey.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJPropertyKey.m 3 | // MJExtensionExample 4 | // 5 | // Created by MJ Lee on 15/8/11. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJPropertyKey.h" 10 | 11 | @implementation MJPropertyKey 12 | 13 | - (id)valueInObject:(id)object 14 | { 15 | if ([object isKindOfClass:[NSDictionary class]] && self.type == MJPropertyKeyTypeDictionary) { 16 | return object[self.name]; 17 | } else if ([object isKindOfClass:[NSArray class]] && self.type == MJPropertyKeyTypeArray) { 18 | NSArray *array = object; 19 | NSUInteger index = self.name.intValue; 20 | if (index < array.count) return array[index]; 21 | return nil; 22 | } 23 | return nil; 24 | } 25 | @end 26 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/MJPropertyType.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJPropertyType.h 3 | // MJExtension 4 | // 5 | // Created by mj on 14-1-15. 6 | // Copyright (c) 2014年 小码哥. All rights reserved. 7 | // 包装一种类型 8 | 9 | #import 10 | 11 | /** 12 | * 包装一种类型 13 | */ 14 | @interface MJPropertyType : NSObject 15 | /** 类型标识符 */ 16 | @property (nonatomic, copy) NSString *code; 17 | 18 | /** 是否为id类型 */ 19 | @property (nonatomic, readonly, getter=isIdType) BOOL idType; 20 | 21 | /** 是否为基本数字类型:int、float等 */ 22 | @property (nonatomic, readonly, getter=isNumberType) BOOL numberType; 23 | 24 | /** 是否为BOOL类型 */ 25 | @property (nonatomic, readonly, getter=isBoolType) BOOL boolType; 26 | 27 | /** 对象类型(如果是基本数据类型,此值为nil) */ 28 | @property (nonatomic, readonly) Class typeClass; 29 | 30 | /** 类型是否来自于Foundation框架,比如NSString、NSArray */ 31 | @property (nonatomic, readonly, getter = isFromFoundation) BOOL fromFoundation; 32 | /** 类型是否不支持KVC */ 33 | @property (nonatomic, readonly, getter = isKVCDisabled) BOOL KVCDisabled; 34 | 35 | /** 36 | * 获得缓存的类型对象 37 | */ 38 | + (instancetype)cachedTypeWithCode:(NSString *)code; 39 | @end -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/MJPropertyType.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJPropertyType.m 3 | // MJExtension 4 | // 5 | // Created by mj on 14-1-15. 6 | // Copyright (c) 2014年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJPropertyType.h" 10 | #import "MJExtension.h" 11 | #import "MJFoundation.h" 12 | #import "MJExtensionConst.h" 13 | 14 | @implementation MJPropertyType 15 | 16 | + (instancetype)cachedTypeWithCode:(NSString *)code 17 | { 18 | MJExtensionAssertParamNotNil2(code, nil); 19 | 20 | static NSMutableDictionary *types; 21 | static dispatch_once_t onceToken; 22 | dispatch_once(&onceToken, ^{ 23 | types = [NSMutableDictionary dictionary]; 24 | }); 25 | 26 | MJPropertyType *type = types[code]; 27 | if (type == nil) { 28 | type = [[self alloc] init]; 29 | type.code = code; 30 | types[code] = type; 31 | } 32 | return type; 33 | } 34 | 35 | #pragma mark - 公共方法 36 | - (void)setCode:(NSString *)code 37 | { 38 | _code = code; 39 | 40 | MJExtensionAssertParamNotNil(code); 41 | 42 | if ([code isEqualToString:MJPropertyTypeId]) { 43 | _idType = YES; 44 | } else if (code.length == 0) { 45 | _KVCDisabled = YES; 46 | } else if (code.length > 3 && [code hasPrefix:@"@\""]) { 47 | // 去掉@"和",截取中间的类型名称 48 | _code = [code substringWithRange:NSMakeRange(2, code.length - 3)]; 49 | _typeClass = NSClassFromString(_code); 50 | _fromFoundation = [MJFoundation isClassFromFoundation:_typeClass]; 51 | _numberType = [_typeClass isSubclassOfClass:[NSNumber class]]; 52 | 53 | } else if ([code isEqualToString:MJPropertyTypeSEL] || 54 | [code isEqualToString:MJPropertyTypeIvar] || 55 | [code isEqualToString:MJPropertyTypeMethod]) { 56 | _KVCDisabled = YES; 57 | } 58 | 59 | // 是否为数字类型 60 | NSString *lowerCode = _code.lowercaseString; 61 | NSArray *numberTypes = @[MJPropertyTypeInt, MJPropertyTypeShort, MJPropertyTypeBOOL1, MJPropertyTypeBOOL2, MJPropertyTypeFloat, MJPropertyTypeDouble, MJPropertyTypeLong, MJPropertyTypeLongLong, MJPropertyTypeChar]; 62 | if ([numberTypes containsObject:lowerCode]) { 63 | _numberType = YES; 64 | 65 | if ([lowerCode isEqualToString:MJPropertyTypeBOOL1] 66 | || [lowerCode isEqualToString:MJPropertyTypeBOOL2]) { 67 | _boolType = YES; 68 | } 69 | } 70 | } 71 | @end 72 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/NSObject+MJClass.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+MJClass.h 3 | // MJExtensionExample 4 | // 5 | // Created by MJ Lee on 15/8/11. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | * 遍历所有类的block(父类) 13 | */ 14 | typedef void (^MJClassesEnumeration)(Class c, BOOL *stop); 15 | 16 | /** 这个数组中的属性名才会进行字典和模型的转换 */ 17 | typedef NSArray * (^MJAllowedPropertyNames)(void); 18 | /** 这个数组中的属性名才会进行归档 */ 19 | typedef NSArray * (^MJAllowedCodingPropertyNames)(void); 20 | 21 | /** 这个数组中的属性名将会被忽略:不进行字典和模型的转换 */ 22 | typedef NSArray * (^MJIgnoredPropertyNames)(void); 23 | /** 这个数组中的属性名将会被忽略:不进行归档 */ 24 | typedef NSArray * (^MJIgnoredCodingPropertyNames)(void); 25 | 26 | /** 27 | * 类相关的扩展 28 | */ 29 | @interface NSObject (MJClass) 30 | /** 31 | * 遍历所有的类 32 | */ 33 | + (void)mj_enumerateClasses:(MJClassesEnumeration)enumeration; 34 | + (void)mj_enumerateAllClasses:(MJClassesEnumeration)enumeration; 35 | 36 | #pragma mark - 属性白名单配置 37 | /** 38 | * 这个数组中的属性名才会进行字典和模型的转换 39 | * 40 | * @param allowedPropertyNames 这个数组中的属性名才会进行字典和模型的转换 41 | */ 42 | + (void)mj_setupAllowedPropertyNames:(MJAllowedPropertyNames)allowedPropertyNames; 43 | 44 | /** 45 | * 这个数组中的属性名才会进行字典和模型的转换 46 | */ 47 | + (NSMutableArray *)mj_totalAllowedPropertyNames; 48 | 49 | #pragma mark - 属性黑名单配置 50 | /** 51 | * 这个数组中的属性名将会被忽略:不进行字典和模型的转换 52 | * 53 | * @param ignoredPropertyNames 这个数组中的属性名将会被忽略:不进行字典和模型的转换 54 | */ 55 | + (void)mj_setupIgnoredPropertyNames:(MJIgnoredPropertyNames)ignoredPropertyNames; 56 | 57 | /** 58 | * 这个数组中的属性名将会被忽略:不进行字典和模型的转换 59 | */ 60 | + (NSMutableArray *)mj_totalIgnoredPropertyNames; 61 | 62 | #pragma mark - 归档属性白名单配置 63 | /** 64 | * 这个数组中的属性名才会进行归档 65 | * 66 | * @param allowedCodingPropertyNames 这个数组中的属性名才会进行归档 67 | */ 68 | + (void)mj_setupAllowedCodingPropertyNames:(MJAllowedCodingPropertyNames)allowedCodingPropertyNames; 69 | 70 | /** 71 | * 这个数组中的属性名才会进行字典和模型的转换 72 | */ 73 | + (NSMutableArray *)mj_totalAllowedCodingPropertyNames; 74 | 75 | #pragma mark - 归档属性黑名单配置 76 | /** 77 | * 这个数组中的属性名将会被忽略:不进行归档 78 | * 79 | * @param ignoredCodingPropertyNames 这个数组中的属性名将会被忽略:不进行归档 80 | */ 81 | + (void)mj_setupIgnoredCodingPropertyNames:(MJIgnoredCodingPropertyNames)ignoredCodingPropertyNames; 82 | 83 | /** 84 | * 这个数组中的属性名将会被忽略:不进行归档 85 | */ 86 | + (NSMutableArray *)mj_totalIgnoredCodingPropertyNames; 87 | 88 | #pragma mark - 内部使用 89 | + (void)mj_setupBlockReturnValue:(id (^)(void))block key:(const char *)key; 90 | @end 91 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/NSObject+MJClass.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+MJClass.m 3 | // MJExtensionExample 4 | // 5 | // Created by MJ Lee on 15/8/11. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "NSObject+MJClass.h" 10 | #import "NSObject+MJCoding.h" 11 | #import "NSObject+MJKeyValue.h" 12 | #import "MJFoundation.h" 13 | #import 14 | 15 | static const char MJAllowedPropertyNamesKey = '\0'; 16 | static const char MJIgnoredPropertyNamesKey = '\0'; 17 | static const char MJAllowedCodingPropertyNamesKey = '\0'; 18 | static const char MJIgnoredCodingPropertyNamesKey = '\0'; 19 | 20 | @implementation NSObject (MJClass) 21 | 22 | + (NSMutableDictionary *)mj_classDictForKey:(const void *)key 23 | { 24 | static NSMutableDictionary *allowedPropertyNamesDict; 25 | static NSMutableDictionary *ignoredPropertyNamesDict; 26 | static NSMutableDictionary *allowedCodingPropertyNamesDict; 27 | static NSMutableDictionary *ignoredCodingPropertyNamesDict; 28 | 29 | static dispatch_once_t onceToken; 30 | dispatch_once(&onceToken, ^{ 31 | allowedPropertyNamesDict = [NSMutableDictionary dictionary]; 32 | ignoredPropertyNamesDict = [NSMutableDictionary dictionary]; 33 | allowedCodingPropertyNamesDict = [NSMutableDictionary dictionary]; 34 | ignoredCodingPropertyNamesDict = [NSMutableDictionary dictionary]; 35 | }); 36 | 37 | if (key == &MJAllowedPropertyNamesKey) return allowedPropertyNamesDict; 38 | if (key == &MJIgnoredPropertyNamesKey) return ignoredPropertyNamesDict; 39 | if (key == &MJAllowedCodingPropertyNamesKey) return allowedCodingPropertyNamesDict; 40 | if (key == &MJIgnoredCodingPropertyNamesKey) return ignoredCodingPropertyNamesDict; 41 | return nil; 42 | } 43 | 44 | + (void)mj_enumerateClasses:(MJClassesEnumeration)enumeration 45 | { 46 | // 1.没有block就直接返回 47 | if (enumeration == nil) return; 48 | 49 | // 2.停止遍历的标记 50 | BOOL stop = NO; 51 | 52 | // 3.当前正在遍历的类 53 | Class c = self; 54 | 55 | // 4.开始遍历每一个类 56 | while (c && !stop) { 57 | // 4.1.执行操作 58 | enumeration(c, &stop); 59 | 60 | // 4.2.获得父类 61 | c = class_getSuperclass(c); 62 | 63 | if ([MJFoundation isClassFromFoundation:c]) break; 64 | } 65 | } 66 | 67 | + (void)mj_enumerateAllClasses:(MJClassesEnumeration)enumeration 68 | { 69 | // 1.没有block就直接返回 70 | if (enumeration == nil) return; 71 | 72 | // 2.停止遍历的标记 73 | BOOL stop = NO; 74 | 75 | // 3.当前正在遍历的类 76 | Class c = self; 77 | 78 | // 4.开始遍历每一个类 79 | while (c && !stop) { 80 | // 4.1.执行操作 81 | enumeration(c, &stop); 82 | 83 | // 4.2.获得父类 84 | c = class_getSuperclass(c); 85 | } 86 | } 87 | 88 | #pragma mark - 属性黑名单配置 89 | + (void)mj_setupIgnoredPropertyNames:(MJIgnoredPropertyNames)ignoredPropertyNames 90 | { 91 | [self mj_setupBlockReturnValue:ignoredPropertyNames key:&MJIgnoredPropertyNamesKey]; 92 | } 93 | 94 | + (NSMutableArray *)mj_totalIgnoredPropertyNames 95 | { 96 | return [self mj_totalObjectsWithSelector:@selector(mj_ignoredPropertyNames) key:&MJIgnoredPropertyNamesKey]; 97 | } 98 | 99 | #pragma mark - 归档属性黑名单配置 100 | + (void)mj_setupIgnoredCodingPropertyNames:(MJIgnoredCodingPropertyNames)ignoredCodingPropertyNames 101 | { 102 | [self mj_setupBlockReturnValue:ignoredCodingPropertyNames key:&MJIgnoredCodingPropertyNamesKey]; 103 | } 104 | 105 | + (NSMutableArray *)mj_totalIgnoredCodingPropertyNames 106 | { 107 | return [self mj_totalObjectsWithSelector:@selector(mj_ignoredCodingPropertyNames) key:&MJIgnoredCodingPropertyNamesKey]; 108 | } 109 | 110 | #pragma mark - 属性白名单配置 111 | + (void)mj_setupAllowedPropertyNames:(MJAllowedPropertyNames)allowedPropertyNames; 112 | { 113 | [self mj_setupBlockReturnValue:allowedPropertyNames key:&MJAllowedPropertyNamesKey]; 114 | } 115 | 116 | + (NSMutableArray *)mj_totalAllowedPropertyNames 117 | { 118 | return [self mj_totalObjectsWithSelector:@selector(mj_allowedPropertyNames) key:&MJAllowedPropertyNamesKey]; 119 | } 120 | 121 | #pragma mark - 归档属性白名单配置 122 | + (void)mj_setupAllowedCodingPropertyNames:(MJAllowedCodingPropertyNames)allowedCodingPropertyNames 123 | { 124 | [self mj_setupBlockReturnValue:allowedCodingPropertyNames key:&MJAllowedCodingPropertyNamesKey]; 125 | } 126 | 127 | + (NSMutableArray *)mj_totalAllowedCodingPropertyNames 128 | { 129 | return [self mj_totalObjectsWithSelector:@selector(mj_allowedCodingPropertyNames) key:&MJAllowedCodingPropertyNamesKey]; 130 | } 131 | 132 | #pragma mark - block和方法处理:存储block的返回值 133 | + (void)mj_setupBlockReturnValue:(id (^)(void))block key:(const char *)key 134 | { 135 | if (block) { 136 | objc_setAssociatedObject(self, key, block(), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 137 | } else { 138 | objc_setAssociatedObject(self, key, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 139 | } 140 | 141 | // 清空数据 142 | MJExtensionSemaphoreCreate 143 | MJExtensionSemaphoreWait 144 | [[self mj_classDictForKey:key] removeAllObjects]; 145 | MJExtensionSemaphoreSignal 146 | } 147 | 148 | + (NSMutableArray *)mj_totalObjectsWithSelector:(SEL)selector key:(const char *)key 149 | { 150 | MJExtensionSemaphoreCreate 151 | MJExtensionSemaphoreWait 152 | NSMutableArray *array = [self mj_classDictForKey:key][NSStringFromClass(self)]; 153 | if (array == nil) { 154 | // 创建、存储 155 | [self mj_classDictForKey:key][NSStringFromClass(self)] = array = [NSMutableArray array]; 156 | 157 | if ([self respondsToSelector:selector]) { 158 | #pragma clang diagnostic push 159 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 160 | NSArray *subArray = [self performSelector:selector]; 161 | #pragma clang diagnostic pop 162 | if (subArray) { 163 | [array addObjectsFromArray:subArray]; 164 | } 165 | } 166 | 167 | [self mj_enumerateAllClasses:^(__unsafe_unretained Class c, BOOL *stop) { 168 | NSArray *subArray = objc_getAssociatedObject(c, key); 169 | [array addObjectsFromArray:subArray]; 170 | }]; 171 | } 172 | MJExtensionSemaphoreSignal 173 | return array; 174 | } 175 | @end 176 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/NSObject+MJCoding.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+MJCoding.h 3 | // MJExtension 4 | // 5 | // Created by mj on 14-1-15. 6 | // Copyright (c) 2014年 小码哥. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MJExtensionConst.h" 11 | 12 | /** 13 | * Codeing协议 14 | */ 15 | @protocol MJCoding 16 | @optional 17 | /** 18 | * 这个数组中的属性名才会进行归档 19 | */ 20 | + (NSArray *)mj_allowedCodingPropertyNames; 21 | /** 22 | * 这个数组中的属性名将会被忽略:不进行归档 23 | */ 24 | + (NSArray *)mj_ignoredCodingPropertyNames; 25 | @end 26 | 27 | @interface NSObject (MJCoding) 28 | /** 29 | * 解码(从文件中解析对象) 30 | */ 31 | - (void)mj_decode:(NSCoder *)decoder; 32 | /** 33 | * 编码(将对象写入文件中) 34 | */ 35 | - (void)mj_encode:(NSCoder *)encoder; 36 | @end 37 | 38 | /** 39 | 归档的实现 40 | */ 41 | #define MJCodingImplementation \ 42 | - (id)initWithCoder:(NSCoder *)decoder \ 43 | { \ 44 | if (self = [super init]) { \ 45 | [self mj_decode:decoder]; \ 46 | } \ 47 | return self; \ 48 | } \ 49 | \ 50 | - (void)encodeWithCoder:(NSCoder *)encoder \ 51 | { \ 52 | [self mj_encode:encoder]; \ 53 | } 54 | 55 | #define MJExtensionCodingImplementation MJCodingImplementation -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/NSObject+MJCoding.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+MJCoding.m 3 | // MJExtension 4 | // 5 | // Created by mj on 14-1-15. 6 | // Copyright (c) 2014年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "NSObject+MJCoding.h" 10 | #import "NSObject+MJClass.h" 11 | #import "NSObject+MJProperty.h" 12 | #import "MJProperty.h" 13 | 14 | @implementation NSObject (MJCoding) 15 | 16 | - (void)mj_encode:(NSCoder *)encoder 17 | { 18 | Class clazz = [self class]; 19 | 20 | NSArray *allowedCodingPropertyNames = [clazz mj_totalAllowedCodingPropertyNames]; 21 | NSArray *ignoredCodingPropertyNames = [clazz mj_totalIgnoredCodingPropertyNames]; 22 | 23 | [clazz mj_enumerateProperties:^(MJProperty *property, BOOL *stop) { 24 | // 检测是否被忽略 25 | if (allowedCodingPropertyNames.count && ![allowedCodingPropertyNames containsObject:property.name]) return; 26 | if ([ignoredCodingPropertyNames containsObject:property.name]) return; 27 | 28 | id value = [property valueForObject:self]; 29 | if (value == nil) return; 30 | [encoder encodeObject:value forKey:property.name]; 31 | }]; 32 | } 33 | 34 | - (void)mj_decode:(NSCoder *)decoder 35 | { 36 | Class clazz = [self class]; 37 | 38 | NSArray *allowedCodingPropertyNames = [clazz mj_totalAllowedCodingPropertyNames]; 39 | NSArray *ignoredCodingPropertyNames = [clazz mj_totalIgnoredCodingPropertyNames]; 40 | 41 | [clazz mj_enumerateProperties:^(MJProperty *property, BOOL *stop) { 42 | // 检测是否被忽略 43 | if (allowedCodingPropertyNames.count && ![allowedCodingPropertyNames containsObject:property.name]) return; 44 | if ([ignoredCodingPropertyNames containsObject:property.name]) return; 45 | 46 | id value = [decoder decodeObjectForKey:property.name]; 47 | if (value == nil) { // 兼容以前的MJExtension版本 48 | value = [decoder decodeObjectForKey:[@"_" stringByAppendingString:property.name]]; 49 | } 50 | if (value == nil) return; 51 | [property setValue:value forObject:self]; 52 | }]; 53 | } 54 | @end 55 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/NSObject+MJKeyValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+MJKeyValue.h 3 | // MJExtension 4 | // 5 | // Created by mj on 13-8-24. 6 | // Copyright (c) 2013年 小码哥. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MJExtensionConst.h" 11 | #import 12 | #import "MJProperty.h" 13 | 14 | /** 15 | * KeyValue协议 16 | */ 17 | @protocol MJKeyValue 18 | @optional 19 | /** 20 | * 只有这个数组中的属性名才允许进行字典和模型的转换 21 | */ 22 | + (NSArray *)mj_allowedPropertyNames; 23 | 24 | /** 25 | * 这个数组中的属性名将会被忽略:不进行字典和模型的转换 26 | */ 27 | + (NSArray *)mj_ignoredPropertyNames; 28 | 29 | /** 30 | * 将属性名换为其他key去字典中取值 31 | * 32 | * @return 字典中的key是属性名,value是从字典中取值用的key 33 | */ 34 | + (NSDictionary *)mj_replacedKeyFromPropertyName; 35 | 36 | /** 37 | * 将属性名换为其他key去字典中取值 38 | * 39 | * @return 从字典中取值用的key 40 | */ 41 | + (id)mj_replacedKeyFromPropertyName121:(NSString *)propertyName; 42 | 43 | /** 44 | * 数组中需要转换的模型类 45 | * 46 | * @return 字典中的key是数组属性名,value是数组中存放模型的Class(Class类型或者NSString类型) 47 | */ 48 | + (NSDictionary *)mj_objectClassInArray; 49 | 50 | 51 | /** 特殊地区在字符串格式化数字时使用 */ 52 | + (NSLocale *)mj_numberLocale; 53 | 54 | /** 55 | * 旧值换新值,用于过滤字典中的值 56 | * 57 | * @param oldValue 旧值 58 | * 59 | * @return 新值 60 | */ 61 | - (id)mj_newValueFromOldValue:(id)oldValue property:(MJProperty *)property; 62 | 63 | /** 64 | * 当字典转模型完毕时调用 65 | */ 66 | - (void)mj_keyValuesDidFinishConvertingToObject MJExtensionDeprecated("请使用`mj_didConvertToObjectWithKeyValues:`替代"); 67 | - (void)mj_keyValuesDidFinishConvertingToObject:(NSDictionary *)keyValues MJExtensionDeprecated("请使用`mj_didConvertToObjectWithKeyValues:`替代"); 68 | - (void)mj_didConvertToObjectWithKeyValues:(NSDictionary *)keyValues; 69 | 70 | /** 71 | * 当模型转字典完毕时调用 72 | */ 73 | - (void)mj_objectDidFinishConvertingToKeyValues MJExtensionDeprecated("请使用`mj_objectDidConvertToKeyValues:`替代"); 74 | - (void)mj_objectDidConvertToKeyValues:(NSDictionary *)keyValues; 75 | 76 | @end 77 | 78 | @interface NSObject (MJKeyValue) 79 | #pragma mark - 类方法 80 | /** 81 | * 字典转模型过程中遇到的错误 82 | */ 83 | + (NSError *)mj_error; 84 | 85 | /** 86 | * 模型转字典时,字典的key是否参考replacedKeyFromPropertyName等方法(父类设置了,子类也会继承下来) 87 | */ 88 | + (void)mj_referenceReplacedKeyWhenCreatingKeyValues:(BOOL)reference; 89 | 90 | #pragma mark - 对象方法 91 | /** 92 | * 将字典的键值对转成模型属性 93 | * @param keyValues 字典(可以是NSDictionary、NSData、NSString) 94 | */ 95 | - (instancetype)mj_setKeyValues:(id)keyValues; 96 | 97 | /** 98 | * 将字典的键值对转成模型属性 99 | * @param keyValues 字典(可以是NSDictionary、NSData、NSString) 100 | * @param context CoreData上下文 101 | */ 102 | - (instancetype)mj_setKeyValues:(id)keyValues context:(NSManagedObjectContext *)context; 103 | 104 | /** 105 | * 将模型转成字典 106 | * @return 字典 107 | */ 108 | - (NSMutableDictionary *)mj_keyValues; 109 | - (NSMutableDictionary *)mj_keyValuesWithKeys:(NSArray *)keys; 110 | - (NSMutableDictionary *)mj_keyValuesWithIgnoredKeys:(NSArray *)ignoredKeys; 111 | 112 | /** 113 | * 通过模型数组来创建一个字典数组 114 | * @param objectArray 模型数组 115 | * @return 字典数组 116 | */ 117 | + (NSMutableArray *)mj_keyValuesArrayWithObjectArray:(NSArray *)objectArray; 118 | + (NSMutableArray *)mj_keyValuesArrayWithObjectArray:(NSArray *)objectArray keys:(NSArray *)keys; 119 | + (NSMutableArray *)mj_keyValuesArrayWithObjectArray:(NSArray *)objectArray ignoredKeys:(NSArray *)ignoredKeys; 120 | 121 | #pragma mark - 字典转模型 122 | /** 123 | * 通过字典来创建一个模型 124 | * @param keyValues 字典(可以是NSDictionary、NSData、NSString) 125 | * @return 新建的对象 126 | */ 127 | + (instancetype)mj_objectWithKeyValues:(id)keyValues; 128 | 129 | /** 130 | * 通过字典来创建一个CoreData模型 131 | * @param keyValues 字典(可以是NSDictionary、NSData、NSString) 132 | * @param context CoreData上下文 133 | * @return 新建的对象 134 | */ 135 | + (instancetype)mj_objectWithKeyValues:(id)keyValues context:(NSManagedObjectContext *)context; 136 | 137 | /** 138 | * 通过plist来创建一个模型 139 | * @param filename 文件名(仅限于mainBundle中的文件) 140 | * @return 新建的对象 141 | */ 142 | + (instancetype)mj_objectWithFilename:(NSString *)filename; 143 | 144 | /** 145 | * 通过plist来创建一个模型 146 | * @param file 文件全路径 147 | * @return 新建的对象 148 | */ 149 | + (instancetype)mj_objectWithFile:(NSString *)file; 150 | 151 | #pragma mark - 字典数组转模型数组 152 | /** 153 | * 通过字典数组来创建一个模型数组 154 | * @param keyValuesArray 字典数组(可以是NSDictionary、NSData、NSString) 155 | * @return 模型数组 156 | */ 157 | + (NSMutableArray *)mj_objectArrayWithKeyValuesArray:(id)keyValuesArray; 158 | 159 | /** 160 | * 通过字典数组来创建一个模型数组 161 | * @param keyValuesArray 字典数组(可以是NSDictionary、NSData、NSString) 162 | * @param context CoreData上下文 163 | * @return 模型数组 164 | */ 165 | + (NSMutableArray *)mj_objectArrayWithKeyValuesArray:(id)keyValuesArray context:(NSManagedObjectContext *)context; 166 | 167 | /** 168 | * 通过plist来创建一个模型数组 169 | * @param filename 文件名(仅限于mainBundle中的文件) 170 | * @return 模型数组 171 | */ 172 | + (NSMutableArray *)mj_objectArrayWithFilename:(NSString *)filename; 173 | 174 | /** 175 | * 通过plist来创建一个模型数组 176 | * @param file 文件全路径 177 | * @return 模型数组 178 | */ 179 | + (NSMutableArray *)mj_objectArrayWithFile:(NSString *)file; 180 | 181 | #pragma mark - 转换为JSON 182 | /** 183 | * 转换为JSON Data 184 | */ 185 | - (NSData *)mj_JSONData; 186 | /** 187 | * 转换为字典或者数组 188 | */ 189 | - (id)mj_JSONObject; 190 | /** 191 | * 转换为JSON 字符串 192 | */ 193 | - (NSString *)mj_JSONString; 194 | @end 195 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/NSObject+MJProperty.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+MJProperty.h 3 | // MJExtensionExample 4 | // 5 | // Created by MJ Lee on 15/4/17. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MJExtensionConst.h" 11 | 12 | @class MJProperty; 13 | 14 | /** 15 | * 遍历成员变量用的block 16 | * 17 | * @param property 成员的包装对象 18 | * @param stop YES代表停止遍历,NO代表继续遍历 19 | */ 20 | typedef void (^MJPropertiesEnumeration)(MJProperty *property, BOOL *stop); 21 | 22 | /** 将属性名换为其他key去字典中取值 */ 23 | typedef NSDictionary * (^MJReplacedKeyFromPropertyName)(void); 24 | typedef id (^MJReplacedKeyFromPropertyName121)(NSString *propertyName); 25 | /** 数组中需要转换的模型类 */ 26 | typedef NSDictionary * (^MJObjectClassInArray)(void); 27 | /** 用于过滤字典中的值 */ 28 | typedef id (^MJNewValueFromOldValue)(id object, id oldValue, MJProperty *property); 29 | 30 | /** 31 | * 成员属性相关的扩展 32 | */ 33 | @interface NSObject (MJProperty) 34 | #pragma mark - 遍历 35 | /** 36 | * 遍历所有的成员 37 | */ 38 | + (void)mj_enumerateProperties:(MJPropertiesEnumeration)enumeration; 39 | 40 | #pragma mark - 新值配置 41 | /** 42 | * 用于过滤字典中的值 43 | * 44 | * @param newValueFormOldValue 用于过滤字典中的值 45 | */ 46 | + (void)mj_setupNewValueFromOldValue:(MJNewValueFromOldValue)newValueFormOldValue; 47 | + (id)mj_getNewValueFromObject:(__unsafe_unretained id)object oldValue:(__unsafe_unretained id)oldValue property:(__unsafe_unretained MJProperty *)property; 48 | 49 | #pragma mark - key配置 50 | /** 51 | * 将属性名换为其他key去字典中取值 52 | * 53 | * @param replacedKeyFromPropertyName 将属性名换为其他key去字典中取值 54 | */ 55 | + (void)mj_setupReplacedKeyFromPropertyName:(MJReplacedKeyFromPropertyName)replacedKeyFromPropertyName; 56 | /** 57 | * 将属性名换为其他key去字典中取值 58 | * 59 | * @param replacedKeyFromPropertyName121 将属性名换为其他key去字典中取值 60 | */ 61 | + (void)mj_setupReplacedKeyFromPropertyName121:(MJReplacedKeyFromPropertyName121)replacedKeyFromPropertyName121; 62 | 63 | #pragma mark - array model class配置 64 | /** 65 | * 数组中需要转换的模型类 66 | * 67 | * @param objectClassInArray 数组中需要转换的模型类 68 | */ 69 | + (void)mj_setupObjectClassInArray:(MJObjectClassInArray)objectClassInArray; 70 | @end 71 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/NSString+MJExtension.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+MJExtension.h 3 | // MJExtensionExample 4 | // 5 | // Created by MJ Lee on 15/6/7. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MJExtensionConst.h" 11 | 12 | @interface NSString (MJExtension) 13 | /** 14 | * 驼峰转下划线(loveYou -> love_you) 15 | */ 16 | - (NSString *)mj_underlineFromCamel; 17 | /** 18 | * 下划线转驼峰(love_you -> loveYou) 19 | */ 20 | - (NSString *)mj_camelFromUnderline; 21 | /** 22 | * 首字母变大写 23 | */ 24 | - (NSString *)mj_firstCharUpper; 25 | /** 26 | * 首字母变小写 27 | */ 28 | - (NSString *)mj_firstCharLower; 29 | 30 | - (BOOL)mj_isPureInt; 31 | 32 | - (NSURL *)mj_url; 33 | @end 34 | -------------------------------------------------------------------------------- /Example/Pods/MJExtension/MJExtension/NSString+MJExtension.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+MJExtension.m 3 | // MJExtensionExample 4 | // 5 | // Created by MJ Lee on 15/6/7. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "NSString+MJExtension.h" 10 | 11 | @implementation NSString (MJExtension) 12 | - (NSString *)mj_underlineFromCamel 13 | { 14 | if (self.length == 0) return self; 15 | NSMutableString *string = [NSMutableString string]; 16 | for (NSUInteger i = 0; i= 2) [string appendString:[cmp substringFromIndex:1]]; 40 | } else { 41 | [string appendString:cmp]; 42 | } 43 | } 44 | return string; 45 | } 46 | 47 | - (NSString *)mj_firstCharLower 48 | { 49 | if (self.length == 0) return self; 50 | NSMutableString *string = [NSMutableString string]; 51 | [string appendString:[NSString stringWithFormat:@"%c", [self characterAtIndex:0]].lowercaseString]; 52 | if (self.length >= 2) [string appendString:[self substringFromIndex:1]]; 53 | return string; 54 | } 55 | 56 | - (NSString *)mj_firstCharUpper 57 | { 58 | if (self.length == 0) return self; 59 | NSMutableString *string = [NSMutableString string]; 60 | [string appendString:[NSString stringWithFormat:@"%c", [self characterAtIndex:0]].uppercaseString]; 61 | if (self.length >= 2) [string appendString:[self substringFromIndex:1]]; 62 | return string; 63 | } 64 | 65 | - (BOOL)mj_isPureInt 66 | { 67 | NSScanner *scan = [NSScanner scannerWithString:self]; 68 | int val; 69 | return [scan scanInt:&val] && [scan isAtEnd]; 70 | } 71 | 72 | - (NSURL *)mj_url 73 | { 74 | // [self stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"!$&'()*+,-./:;=?@_~%#[]"]]; 75 | #pragma clang diagnostic push 76 | #pragma clang diagnostic ignored"-Wdeprecated-declarations" 77 | return [NSURL URLWithString:(NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]", NULL,kCFStringEncodingUTF8))]; 78 | #pragma clang diagnostic pop 79 | } 80 | @end 81 | -------------------------------------------------------------------------------- /Example/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (4.0.1): 3 | - AFNetworking/NSURLSession (= 4.0.1) 4 | - AFNetworking/Reachability (= 4.0.1) 5 | - AFNetworking/Security (= 4.0.1) 6 | - AFNetworking/Serialization (= 4.0.1) 7 | - AFNetworking/UIKit (= 4.0.1) 8 | - AFNetworking/NSURLSession (4.0.1): 9 | - AFNetworking/Reachability 10 | - AFNetworking/Security 11 | - AFNetworking/Serialization 12 | - AFNetworking/Reachability (4.0.1) 13 | - AFNetworking/Security (4.0.1) 14 | - AFNetworking/Serialization (4.0.1) 15 | - AFNetworking/UIKit (4.0.1): 16 | - AFNetworking/NSURLSession 17 | - BANetManager (2.4.0): 18 | - AFNetworking 19 | - YYCache 20 | - MJExtension (3.2.1) 21 | - YYCache (1.0.4) 22 | 23 | DEPENDENCIES: 24 | - AFNetworking 25 | - BANetManager (from `../`) 26 | - MJExtension 27 | - YYCache 28 | 29 | SPEC REPOS: 30 | trunk: 31 | - AFNetworking 32 | - MJExtension 33 | - YYCache 34 | 35 | EXTERNAL SOURCES: 36 | BANetManager: 37 | :path: "../" 38 | 39 | SPEC CHECKSUMS: 40 | AFNetworking: 7864c38297c79aaca1500c33288e429c3451fdce 41 | BANetManager: 5563b06ed6ac5e75c1bd2589ad19ee48678507d3 42 | MJExtension: 635f2c663dcb1bf76fa4b715b2570a5710aec545 43 | YYCache: 8105b6638f5e849296c71f331ff83891a4942952 44 | 45 | PODFILE CHECKSUM: e40484ccc388d756fa860c8d4bc3db36d82a6bbb 46 | 47 | COCOAPODS: 1.9.1 48 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/Alria.xcuserdatad/xcschemes/AFNetworking.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/Alria.xcuserdatad/xcschemes/BANetManager.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/Alria.xcuserdatad/xcschemes/MJExtension.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/Alria.xcuserdatad/xcschemes/Pods-BANetManager_Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/Alria.xcuserdatad/xcschemes/YYCache.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/Alria.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | AFNetworking.xcscheme 8 | 9 | isShown 10 | 11 | 12 | BANetManager.xcscheme 13 | 14 | isShown 15 | 16 | 17 | MJExtension.xcscheme 18 | 19 | isShown 20 | 21 | 22 | Pods-BANetManager_Example.xcscheme 23 | 24 | isShown 25 | 26 | 27 | YYCache.xcscheme 28 | 29 | isShown 30 | 31 | 32 | 33 | SuppressBuildableAutocreation 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/AFNetworking/AFNetworking-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 3.2.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_AFNetworking : NSObject 3 | @end 4 | @implementation PodsDummy_AFNetworking 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/AFNetworking/AFNetworking-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "AFNetworking.h" 14 | #import "AFHTTPSessionManager.h" 15 | #import "AFURLSessionManager.h" 16 | #import "AFCompatibilityMacros.h" 17 | #import "AFNetworkReachabilityManager.h" 18 | #import "AFSecurityPolicy.h" 19 | #import "AFURLRequestSerialization.h" 20 | #import "AFURLResponseSerialization.h" 21 | #import "AFAutoPurgingImageCache.h" 22 | #import "AFImageDownloader.h" 23 | #import "AFNetworkActivityIndicatorManager.h" 24 | #import "UIActivityIndicatorView+AFNetworking.h" 25 | #import "UIButton+AFNetworking.h" 26 | #import "UIImage+AFNetworking.h" 27 | #import "UIImageView+AFNetworking.h" 28 | #import "UIKit+AFNetworking.h" 29 | #import "UIProgressView+AFNetworking.h" 30 | #import "UIRefreshControl+AFNetworking.h" 31 | #import "UIWebView+AFNetworking.h" 32 | 33 | FOUNDATION_EXPORT double AFNetworkingVersionNumber; 34 | FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[]; 35 | 36 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/AFNetworking/AFNetworking.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/AFNetworking 8 | PRODUCT_BUNDLE_IDENTIFIER = com.alamofire.AFNetworking 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/AFNetworking/AFNetworking.modulemap: -------------------------------------------------------------------------------- 1 | framework module AFNetworking { 2 | umbrella header "AFNetworking-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/AFNetworking/AFNetworking.release.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/AFNetworking 8 | PRODUCT_BUNDLE_IDENTIFIER = com.alamofire.AFNetworking 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/BANetManager/BANetManager-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/BANetManager/BANetManager-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_BANetManager : NSObject 3 | @end 4 | @implementation PodsDummy_BANetManager 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/BANetManager/BANetManager-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/BANetManager/BANetManager-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double BANetManagerVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char BANetManagerVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/BANetManager/BANetManager.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/BANetManager 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/BANetManager" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/BANetManager" "${PODS_ROOT}/Headers/Public/YYCache" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../.. 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/BANetManager/BANetManager.modulemap: -------------------------------------------------------------------------------- 1 | framework module BANetManager { 2 | umbrella header "BANetManager-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/BANetManager/BANetManager.release.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/BANetManager 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/BANetManager" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/BANetManager" "${PODS_ROOT}/Headers/Public/YYCache" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../.. 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/MJExtension/MJExtension-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MJExtension : NSObject 3 | @end 4 | @implementation PodsDummy_MJExtension 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/MJExtension/MJExtension-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/MJExtension/MJExtension.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MJExtension 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/MJExtension" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MJExtension" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/MJExtension 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/MJExtension/MJExtension.release.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MJExtension 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/MJExtension" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MJExtension" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/MJExtension 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-BANetManager_Example/Pods-BANetManager_Example-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-BANetManager_Example/Pods-BANetManager_Example-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## AFNetworking 5 | 6 | Copyright (c) 2011-2020 Alamofire Software Foundation (http://alamofire.org/) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | 27 | ## BANetManager 28 | 29 | Copyright (c) 2020 boai 30 | 31 | Permission is hereby granted, free of charge, to any person obtaining a copy 32 | of this software and associated documentation files (the "Software"), to deal 33 | in the Software without restriction, including without limitation the rights 34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 35 | copies of the Software, and to permit persons to whom the Software is 36 | furnished to do so, subject to the following conditions: 37 | 38 | The above copyright notice and this permission notice shall be included in 39 | all copies or substantial portions of the Software. 40 | 41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 47 | THE SOFTWARE. 48 | 49 | 50 | ## MJExtension 51 | 52 | Copyright (c) 2013-2019 MJExtension (https://github.com/CoderMJLee/MJExtension) 53 | 54 | Permission is hereby granted, free of charge, to any person obtaining a copy 55 | of this software and associated documentation files (the "Software"), to deal 56 | in the Software without restriction, including without limitation the rights 57 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 58 | copies of the Software, and to permit persons to whom the Software is 59 | furnished to do so, subject to the following conditions: 60 | 61 | The above copyright notice and this permission notice shall be included in 62 | all copies or substantial portions of the Software. 63 | 64 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 67 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 68 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 69 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 70 | THE SOFTWARE. 71 | 72 | 73 | ## YYCache 74 | 75 | The MIT License (MIT) 76 | 77 | Copyright (c) 2015 ibireme 78 | 79 | Permission is hereby granted, free of charge, to any person obtaining a copy 80 | of this software and associated documentation files (the "Software"), to deal 81 | in the Software without restriction, including without limitation the rights 82 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 83 | copies of the Software, and to permit persons to whom the Software is 84 | furnished to do so, subject to the following conditions: 85 | 86 | The above copyright notice and this permission notice shall be included in all 87 | copies or substantial portions of the Software. 88 | 89 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 90 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 91 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 92 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 93 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 94 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 95 | SOFTWARE. 96 | 97 | 98 | Generated by CocoaPods - https://cocoapods.org 99 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-BANetManager_Example/Pods-BANetManager_Example-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_BANetManager_Example : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_BANetManager_Example 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-BANetManager_Example/Pods-BANetManager_Example-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_BANetManager_ExampleVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_BANetManager_ExampleVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-BANetManager_Example/Pods-BANetManager_Example.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/BANetManager" "${PODS_ROOT}/Headers/Public/MJExtension" "${PODS_ROOT}/Headers/Public/YYCache" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/BANetManager" "${PODS_CONFIGURATION_BUILD_DIR}/MJExtension" "${PODS_CONFIGURATION_BUILD_DIR}/YYCache" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -l"BANetManager" -l"MJExtension" -l"YYCache" -l"sqlite3" -framework "CoreFoundation" -framework "QuartzCore" -framework "UIKit" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 10 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-BANetManager_Example/Pods-BANetManager_Example.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_BANetManager_Example { 2 | umbrella header "Pods-BANetManager_Example-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-BANetManager_Example/Pods-BANetManager_Example.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/BANetManager" "${PODS_ROOT}/Headers/Public/MJExtension" "${PODS_ROOT}/Headers/Public/YYCache" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/BANetManager" "${PODS_CONFIGURATION_BUILD_DIR}/MJExtension" "${PODS_CONFIGURATION_BUILD_DIR}/YYCache" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -l"BANetManager" -l"MJExtension" -l"YYCache" -l"sqlite3" -framework "CoreFoundation" -framework "QuartzCore" -framework "UIKit" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 10 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/YYCache/YYCache-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.4 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/YYCache/YYCache-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_YYCache : NSObject 3 | @end 4 | @implementation PodsDummy_YYCache 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/YYCache/YYCache-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/YYCache/YYCache-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "YYCache.h" 14 | #import "YYDiskCache.h" 15 | #import "YYKVStorage.h" 16 | #import "YYMemoryCache.h" 17 | 18 | FOUNDATION_EXPORT double YYCacheVersionNumber; 19 | FOUNDATION_EXPORT const unsigned char YYCacheVersionString[]; 20 | 21 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/YYCache/YYCache.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/YYCache 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/YYCache" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/YYCache" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/YYCache 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/YYCache/YYCache.modulemap: -------------------------------------------------------------------------------- 1 | framework module YYCache { 2 | umbrella header "YYCache-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/YYCache/YYCache.release.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/YYCache 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/YYCache" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/YYCache" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/YYCache 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /Example/Pods/YYCache/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 ibireme 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Example/Pods/YYCache/README.md: -------------------------------------------------------------------------------- 1 | YYCache 2 | ============== 3 | 4 | [![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/ibireme/YYCache/master/LICENSE)  5 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)  6 | [![CocoaPods](http://img.shields.io/cocoapods/v/YYCache.svg?style=flat)](http://cocoapods.org/?q= YYCache)  7 | [![CocoaPods](http://img.shields.io/cocoapods/p/YYCache.svg?style=flat)](http://cocoapods.org/?q= YYCache)  8 | [![Support](https://img.shields.io/badge/support-iOS%206%2B%20-blue.svg?style=flat)](https://www.apple.com/nl/ios/)  9 | [![Build Status](https://travis-ci.org/ibireme/YYCache.svg?branch=master)](https://travis-ci.org/ibireme/YYCache) 10 | 11 | High performance cache framework for iOS.
12 | (It's a component of [YYKit](https://github.com/ibireme/YYKit)) 13 | 14 | Performance 15 | ============== 16 | 17 | ![Memory cache benchmark result](https://raw.github.com/ibireme/YYCache/master/Benchmark/Result_memory.png 18 | ) 19 | 20 | ![Disk benchmark result](https://raw.github.com/ibireme/YYCache/master/Benchmark/Result_disk.png 21 | ) 22 | 23 | You may [download](http://www.sqlite.org/download.html) and compile the latest version of sqlite and ignore the libsqlite3.dylib in iOS system to get higher performance. 24 | 25 | See `Benchmark/CacheBenchmark.xcodeproj` for more benchmark case. 26 | 27 | 28 | Features 29 | ============== 30 | - **LRU**: Objects can be evicted with least-recently-used algorithm. 31 | - **Limitation**: Cache limitation can be controlled with count, cost, age and free space. 32 | - **Compatibility**: The API is similar to `NSCache`, all methods are thread-safe. 33 | - **Memory Cache** 34 | - **Release Control**: Objects can be released synchronously/asynchronously on main thread or background thread. 35 | - **Automatically Clear**: It can be configured to automatically evict objects when receive memory warning or app enter background. 36 | - **Disk Cache** 37 | - **Customization**: It supports custom archive and unarchive method to store object which does not adopt NSCoding. 38 | - **Storage Type Control**: It can automatically decide the storage type (sqlite / file) for each object to get 39 | better performance. 40 | 41 | 42 | Installation 43 | ============== 44 | 45 | ### CocoaPods 46 | 47 | 1. Add `pod 'YYCache'` to your Podfile. 48 | 2. Run `pod install` or `pod update`. 49 | 3. Import \. 50 | 51 | 52 | ### Carthage 53 | 54 | 1. Add `github "ibireme/YYCache"` to your Cartfile. 55 | 2. Run `carthage update --platform ios` and add the framework to your project. 56 | 3. Import \. 57 | 58 | 59 | ### Manually 60 | 61 | 1. Download all the files in the YYCache subdirectory. 62 | 2. Add the source files to your Xcode project. 63 | 3. Link with required frameworks: 64 | * UIKit 65 | * CoreFoundation 66 | * QuartzCore 67 | * sqlite3 68 | 4. Import `YYCache.h`. 69 | 70 | 71 | Documentation 72 | ============== 73 | Full API documentation is available on [CocoaDocs](http://cocoadocs.org/docsets/YYCache/).
74 | You can also install documentation locally using [appledoc](https://github.com/tomaz/appledoc). 75 | 76 | 77 | Requirements 78 | ============== 79 | This library requires `iOS 6.0+` and `Xcode 7.0+`. 80 | 81 | 82 | License 83 | ============== 84 | YYCache is provided under the MIT license. See LICENSE file for details. 85 | 86 | 87 |

88 | --- 89 | 中文介绍 90 | ============== 91 | 高性能 iOS 缓存框架。
92 | (该项目是 [YYKit](https://github.com/ibireme/YYKit) 组件之一) 93 | 94 | 性能 95 | ============== 96 | 97 | iPhone 6 上,内存缓存每秒响应次数 (越高越好): 98 | ![Memory cache benchmark result](https://raw.github.com/ibireme/YYCache/master/Benchmark/Result_memory.png 99 | ) 100 | 101 | iPhone 6 上,磁盘缓存每秒响应次数 (越高越好): 102 | ![Disk benchmark result](https://raw.github.com/ibireme/YYCache/master/Benchmark/Result_disk.png 103 | ) 104 | 105 | 推荐到 SQLite 官网[下载](http://www.sqlite.org/download.html)和编译最新的 SQLite,以替换 iOS 自带的 libsqlite3.dylib,以获得最高 1.5~3 倍的性能提升。 106 | 107 | 更多测试代码和用例见 `Benchmark/CacheBenchmark.xcodeproj`。 108 | 109 | 110 | 特性 111 | ============== 112 | - **LRU**: 缓存支持 LRU (least-recently-used) 淘汰算法。 113 | - **缓存控制**: 支持多种缓存控制方法:总数量、总大小、存活时间、空闲空间。 114 | - **兼容性**: API 基本和 `NSCache` 保持一致, 所有方法都是线程安全的。 115 | - **内存缓存** 116 | - **对象释放控制**: 对象的释放(release) 可以配置为同步或异步进行,可以配置在主线程或后台线程进行。 117 | - **自动清空**: 当收到内存警告或 App 进入后台时,缓存可以配置为自动清空。 118 | - **磁盘缓存** 119 | - **可定制性**: 磁盘缓存支持自定义的归档解档方法,以支持那些没有实现 NSCoding 协议的对象。 120 | - **存储类型控制**: 磁盘缓存支持对每个对象的存储类型 (SQLite/文件) 进行自动或手动控制,以获得更高的存取性能。 121 | 122 | 123 | 安装 124 | ============== 125 | 126 | ### CocoaPods 127 | 128 | 1. 在 Podfile 中添加 `pod 'YYCache'`。 129 | 2. 执行 `pod install` 或 `pod update`。 130 | 3. 导入 \。 131 | 132 | 133 | ### Carthage 134 | 135 | 1. 在 Cartfile 中添加 `github "ibireme/YYCache"`。 136 | 2. 执行 `carthage update --platform ios` 并将生成的 framework 添加到你的工程。 137 | 3. 导入 \。 138 | 139 | 140 | ### 手动安装 141 | 142 | 1. 下载 YYCache 文件夹内的所有内容。 143 | 2. 将 YYCache 内的源文件添加(拖放)到你的工程。 144 | 3. 链接以下的 frameworks: 145 | * UIKit 146 | * CoreFoundation 147 | * QuartzCore 148 | * sqlite3 149 | 4. 导入 `YYCache.h`。 150 | 151 | 152 | 文档 153 | ============== 154 | 你可以在 [CocoaDocs](http://cocoadocs.org/docsets/YYCache/) 查看在线 API 文档,也可以用 [appledoc](https://github.com/tomaz/appledoc) 本地生成文档。 155 | 156 | 157 | 系统要求 158 | ============== 159 | 该项目最低支持 `iOS 6.0` 和 `Xcode 7.0`。 160 | 161 | 162 | 许可证 163 | ============== 164 | YYCache 使用 MIT 许可证,详情见 LICENSE 文件。 165 | 166 | 167 | 相关链接 168 | ============== 169 | [YYCache 设计思路与技术细节](http://blog.ibireme.com/2015/10/26/yycache/) 170 | 171 | 172 | -------------------------------------------------------------------------------- /Example/Pods/YYCache/YYCache/YYCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // YYCache.m 3 | // YYCache 4 | // 5 | // Created by ibireme on 15/2/13. 6 | // Copyright (c) 2015 ibireme. 7 | // 8 | // This source code is licensed under the MIT-style license found in the 9 | // LICENSE file in the root directory of this source tree. 10 | // 11 | 12 | #import "YYCache.h" 13 | #import "YYMemoryCache.h" 14 | #import "YYDiskCache.h" 15 | 16 | @implementation YYCache 17 | 18 | - (instancetype) init { 19 | NSLog(@"Use \"initWithName\" or \"initWithPath\" to create YYCache instance."); 20 | return [self initWithPath:@""]; 21 | } 22 | 23 | - (instancetype)initWithName:(NSString *)name { 24 | if (name.length == 0) return nil; 25 | NSString *cacheFolder = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]; 26 | NSString *path = [cacheFolder stringByAppendingPathComponent:name]; 27 | return [self initWithPath:path]; 28 | } 29 | 30 | - (instancetype)initWithPath:(NSString *)path { 31 | if (path.length == 0) return nil; 32 | YYDiskCache *diskCache = [[YYDiskCache alloc] initWithPath:path]; 33 | if (!diskCache) return nil; 34 | NSString *name = [path lastPathComponent]; 35 | YYMemoryCache *memoryCache = [YYMemoryCache new]; 36 | memoryCache.name = name; 37 | 38 | self = [super init]; 39 | _name = name; 40 | _diskCache = diskCache; 41 | _memoryCache = memoryCache; 42 | return self; 43 | } 44 | 45 | + (instancetype)cacheWithName:(NSString *)name { 46 | return [[self alloc] initWithName:name]; 47 | } 48 | 49 | + (instancetype)cacheWithPath:(NSString *)path { 50 | return [[self alloc] initWithPath:path]; 51 | } 52 | 53 | - (BOOL)containsObjectForKey:(NSString *)key { 54 | return [_memoryCache containsObjectForKey:key] || [_diskCache containsObjectForKey:key]; 55 | } 56 | 57 | - (void)containsObjectForKey:(NSString *)key withBlock:(void (^)(NSString *key, BOOL contains))block { 58 | if (!block) return; 59 | 60 | if ([_memoryCache containsObjectForKey:key]) { 61 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 62 | block(key, YES); 63 | }); 64 | } else { 65 | [_diskCache containsObjectForKey:key withBlock:block]; 66 | } 67 | } 68 | 69 | - (id)objectForKey:(NSString *)key { 70 | id object = [_memoryCache objectForKey:key]; 71 | if (!object) { 72 | object = [_diskCache objectForKey:key]; 73 | if (object) { 74 | [_memoryCache setObject:object forKey:key]; 75 | } 76 | } 77 | return object; 78 | } 79 | 80 | - (void)objectForKey:(NSString *)key withBlock:(void (^)(NSString *key, id object))block { 81 | if (!block) return; 82 | id object = [_memoryCache objectForKey:key]; 83 | if (object) { 84 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 85 | block(key, object); 86 | }); 87 | } else { 88 | [_diskCache objectForKey:key withBlock:^(NSString *key, id object) { 89 | if (object && ![_memoryCache objectForKey:key]) { 90 | [_memoryCache setObject:object forKey:key]; 91 | } 92 | block(key, object); 93 | }]; 94 | } 95 | } 96 | 97 | - (void)setObject:(id)object forKey:(NSString *)key { 98 | [_memoryCache setObject:object forKey:key]; 99 | [_diskCache setObject:object forKey:key]; 100 | } 101 | 102 | - (void)setObject:(id)object forKey:(NSString *)key withBlock:(void (^)(void))block { 103 | [_memoryCache setObject:object forKey:key]; 104 | [_diskCache setObject:object forKey:key withBlock:block]; 105 | } 106 | 107 | - (void)removeObjectForKey:(NSString *)key { 108 | [_memoryCache removeObjectForKey:key]; 109 | [_diskCache removeObjectForKey:key]; 110 | } 111 | 112 | - (void)removeObjectForKey:(NSString *)key withBlock:(void (^)(NSString *key))block { 113 | [_memoryCache removeObjectForKey:key]; 114 | [_diskCache removeObjectForKey:key withBlock:block]; 115 | } 116 | 117 | - (void)removeAllObjects { 118 | [_memoryCache removeAllObjects]; 119 | [_diskCache removeAllObjects]; 120 | } 121 | 122 | - (void)removeAllObjectsWithBlock:(void(^)(void))block { 123 | [_memoryCache removeAllObjects]; 124 | [_diskCache removeAllObjectsWithBlock:block]; 125 | } 126 | 127 | - (void)removeAllObjectsWithProgressBlock:(void(^)(int removedCount, int totalCount))progress 128 | endBlock:(void(^)(BOOL error))end { 129 | [_memoryCache removeAllObjects]; 130 | [_diskCache removeAllObjectsWithProgressBlock:progress endBlock:end]; 131 | 132 | } 133 | 134 | - (NSString *)description { 135 | if (_name) return [NSString stringWithFormat:@"<%@: %p> (%@)", self.class, self, _name]; 136 | else return [NSString stringWithFormat:@"<%@: %p>", self.class, self]; 137 | } 138 | 139 | @end 140 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 boai 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj --------------------------------------------------------------------------------