├── JSONToModel ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── Mac-128.png │ │ ├── Mac-16.png │ │ ├── Mac-256.png │ │ ├── Mac-32.png │ │ ├── Mac-512.png │ │ ├── Mac-128@2x.png │ │ ├── Mac-16@2x.png │ │ ├── Mac-256@2x.png │ │ ├── Mac-32@2x.png │ │ ├── App Store-512@2x.png │ │ └── Contents.json ├── thirdLibs │ ├── JSONToModel-Bridging-Header.h │ ├── Highlighter │ │ └── languages │ │ │ └── objectivec.min.js │ ├── AFNetClient.h │ ├── LineNumberRulerView.swift │ ├── AFNetClient.m │ └── cssjson.js ├── main.m ├── AppDelegate.h ├── Categorys │ ├── NSColor+HexColor.h │ ├── NSDictionary+JSON.h │ ├── NSColor+HexColor.m │ └── NSDictionary+JSON.m ├── JSONToModel.entitlements ├── AppDelegate.m ├── HighlightingTextStorage.h ├── ViewController.h ├── Info.plist ├── Resouces │ ├── xcodetheme.css │ └── xcodetheme.json ├── ViewController.m └── HighlightingTextStorage.m ├── Pods ├── Target Support Files │ ├── MJExtension │ │ ├── MJExtension.modulemap │ │ ├── MJExtension-dummy.m │ │ ├── MJExtension-prefix.pch │ │ ├── MJExtension.xcconfig │ │ ├── MJExtension-umbrella.h │ │ └── Info.plist │ ├── AFNetworking │ │ ├── AFNetworking.modulemap │ │ ├── AFNetworking-dummy.m │ │ ├── AFNetworking-prefix.pch │ │ ├── AFNetworking-umbrella.h │ │ ├── AFNetworking.xcconfig │ │ └── Info.plist │ └── Pods-JSONToModel │ │ ├── Pods-JSONToModel.modulemap │ │ ├── Pods-JSONToModel-dummy.m │ │ ├── Pods-JSONToModel-umbrella.h │ │ ├── Pods-JSONToModel.debug.xcconfig │ │ ├── Pods-JSONToModel.release.xcconfig │ │ ├── Info.plist │ │ ├── Pods-JSONToModel-acknowledgements.markdown │ │ ├── Pods-JSONToModel-acknowledgements.plist │ │ ├── Pods-JSONToModel-resources.sh │ │ └── Pods-JSONToModel-frameworks.sh ├── MJExtension │ ├── MJExtension │ │ ├── MJFoundation.h │ │ ├── MJExtension.h │ │ ├── MJPropertyKey.h │ │ ├── MJPropertyKey.m │ │ ├── MJExtensionConst.m │ │ ├── MJPropertyType.h │ │ ├── NSObject+MJCoding.h │ │ ├── NSString+MJExtension.h │ │ ├── MJProperty.h │ │ ├── MJFoundation.m │ │ ├── NSObject+MJCoding.m │ │ ├── MJPropertyType.m │ │ ├── MJExtensionConst.h │ │ ├── NSObject+MJClass.h │ │ ├── NSObject+MJProperty.h │ │ ├── NSString+MJExtension.m │ │ ├── MJProperty.m │ │ ├── NSObject+MJClass.m │ │ ├── NSObject+MJKeyValue.h │ │ └── NSObject+MJProperty.m │ └── LICENSE ├── Pods.xcodeproj │ └── xcuserdata │ │ ├── jenkins.xcuserdatad │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ │ └── luo.h.xcuserdatad │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ ├── AFNetworking.xcscheme │ │ ├── MJExtension.xcscheme │ │ └── Pods-JSONToModel.xcscheme ├── Manifest.lock └── AFNetworking │ ├── LICENSE │ └── AFNetworking │ ├── AFNetworking.h │ ├── AFSecurityPolicy.h │ ├── AFNetworkReachabilityManager.h │ ├── AFNetworkReachabilityManager.m │ └── AFURLResponseSerialization.h ├── JSONToModel.xcworkspace ├── xcuserdata │ ├── luo.h.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ └── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ └── jenkins.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── contents.xcworkspacedata └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── JSONToModel.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── luo.h.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── luo.h.xcuserdatad │ └── xcschemes │ │ └── xcschememanagement.plist │ └── jenkins.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── Podfile ├── Podfile.lock └── README.md /JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huluo666/JSONToModel/HEAD/JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-128.png -------------------------------------------------------------------------------- /JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huluo666/JSONToModel/HEAD/JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-16.png -------------------------------------------------------------------------------- /JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huluo666/JSONToModel/HEAD/JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-256.png -------------------------------------------------------------------------------- /JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huluo666/JSONToModel/HEAD/JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-32.png -------------------------------------------------------------------------------- /JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huluo666/JSONToModel/HEAD/JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-512.png -------------------------------------------------------------------------------- /JSONToModel/thirdLibs/JSONToModel-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huluo666/JSONToModel/HEAD/JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-128@2x.png -------------------------------------------------------------------------------- /JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huluo666/JSONToModel/HEAD/JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-16@2x.png -------------------------------------------------------------------------------- /JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huluo666/JSONToModel/HEAD/JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-256@2x.png -------------------------------------------------------------------------------- /JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huluo666/JSONToModel/HEAD/JSONToModel/Assets.xcassets/AppIcon.appiconset/Mac-32@2x.png -------------------------------------------------------------------------------- /JSONToModel/Assets.xcassets/AppIcon.appiconset/App Store-512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huluo666/JSONToModel/HEAD/JSONToModel/Assets.xcassets/AppIcon.appiconset/App Store-512@2x.png -------------------------------------------------------------------------------- /Pods/Target Support Files/MJExtension/MJExtension.modulemap: -------------------------------------------------------------------------------- 1 | framework module MJExtension { 2 | umbrella header "MJExtension-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MJExtension/MJExtension-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MJExtension : NSObject 3 | @end 4 | @implementation PodsDummy_MJExtension 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_AFNetworking : NSObject 3 | @end 4 | @implementation PodsDummy_AFNetworking 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JSONToModel/Pods-JSONToModel.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_JSONToModel { 2 | umbrella header "Pods-JSONToModel-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /JSONToModel.xcworkspace/xcuserdata/luo.h.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huluo666/JSONToModel/HEAD/JSONToModel.xcworkspace/xcuserdata/luo.h.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JSONToModel/Pods-JSONToModel-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_JSONToModel : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_JSONToModel 5 | @end 6 | -------------------------------------------------------------------------------- /JSONToModel.xcworkspace/xcuserdata/jenkins.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huluo666/JSONToModel/HEAD/JSONToModel.xcworkspace/xcuserdata/jenkins.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /JSONToModel.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /JSONToModel.xcodeproj/project.xcworkspace/xcuserdata/luo.h.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huluo666/JSONToModel/HEAD/JSONToModel.xcodeproj/project.xcworkspace/xcuserdata/luo.h.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /JSONToModel/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // JSONToModel 4 | // 5 | // Created by luo.h on 2018/3/14. 6 | // Copyright © 2018年 hl.com.cn. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | return NSApplicationMain(argc, argv); 13 | } 14 | -------------------------------------------------------------------------------- /JSONToModel.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /JSONToModel/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // JSONToModel 4 | // 5 | // Created by luo.h on 2018/3/14. 6 | // Copyright © 2018年 hl.com.cn. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : NSObject 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /JSONToModel.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /JSONToModel/Categorys/NSColor+HexColor.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSColor+HexColor.h 3 | // JSONToModel 4 | // 5 | // Created by luo.h on 2018/3/15. 6 | // Copyright © 2018年 hl.com.cn. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSColor (HexColor) 12 | + (NSColor *) colorFromHexCode:(NSString *)hexString; 13 | @end 14 | -------------------------------------------------------------------------------- /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 | + (BOOL)isClassFromFoundation:(Class)c; 13 | @end 14 | -------------------------------------------------------------------------------- /JSONToModel/JSONToModel.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JSONToModel/Pods-JSONToModel-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_JSONToModelVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_JSONToModelVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | def shared_dependencies 4 | pod 'MJExtension', '~> 3.0.13' 5 | pod 'AFNetworking', '~> 3.1.0' 6 | end 7 | 8 | 9 | target 'JSONToModel' do 10 | # Uncomment the next line if you're using Swift or would like to use dynamic frameworks 11 | use_frameworks! 12 | 13 | # Pods for JSONToModel 14 | platform :osx, '10.9' 15 | shared_dependencies 16 | end -------------------------------------------------------------------------------- /JSONToModel.xcodeproj/xcuserdata/luo.h.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | JSONToModel.xcscheme 8 | 9 | orderHint 10 | 3 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /JSONToModel.xcodeproj/xcuserdata/jenkins.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | JSONToModel.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 1 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /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 | #ifndef TARGET_OS_IOS 14 | #define TARGET_OS_IOS TARGET_OS_IPHONE 15 | #endif 16 | 17 | #ifndef TARGET_OS_WATCH 18 | #define TARGET_OS_WATCH 0 19 | #endif 20 | 21 | #ifndef TARGET_OS_TV 22 | #define TARGET_OS_TV 0 23 | #endif 24 | -------------------------------------------------------------------------------- /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 | // 代码地址:https://github.com/CoderMJLee/MJExtension 8 | // 代码地址:http://code4app.com/ios/%E5%AD%97%E5%85%B8-JSON-%E4%B8%8E%E6%A8%A1%E5%9E%8B%E7%9A%84%E8%BD%AC%E6%8D%A2/5339992a933bf062608b4c57 9 | 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" -------------------------------------------------------------------------------- /Pods/Target Support Files/MJExtension/MJExtension.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MJExtension 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/MJExtension 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /JSONToModel/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // JSONToModel 4 | // 5 | // Created by luo.h on 2018/3/14. 6 | // Copyright © 2018年 hl.com.cn. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 18 | // Insert code here to initialize your application 19 | } 20 | 21 | 22 | - (void)applicationWillTerminate:(NSNotification *)aNotification { 23 | // Insert code here to tear down your application 24 | } 25 | 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /JSONToModel/HighlightingTextStorage.h: -------------------------------------------------------------------------------- 1 | // 2 | // PCHighlightingTextStorage.h 3 | // JSON_Model 4 | // 5 | // Created by luo.h on 2018/3/14. 6 | // Copyright © 2018年 meet.com.cn. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | typedef NS_ENUM(NSInteger,HighlightType) { 13 | HighlightType_None, 14 | HighlightType_OC, 15 | HighlightType_JSON, 16 | HighlightType_Auto 17 | }; 18 | 19 | 20 | @interface HighlightingTextStorage : NSTextStorage 21 | 22 | @property(nonatomic,assign) NSString *language; 23 | @property(nonatomic,strong) NSColor *defaultTextColor; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /JSONToModel/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // JSONToModel 4 | // 5 | // Created by luo.h on 2018/3/14. 6 | // Copyright © 2018年 hl.com.cn. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : NSViewController 12 | 13 | @property (unsafe_unretained) IBOutlet NSTextView *inputTextView; 14 | @property (unsafe_unretained) IBOutlet NSTextView *outPutTextView; 15 | - (IBAction)autoCodeCreate:(id)sender; 16 | @property (weak) IBOutlet NSTextField *vildJSONLabel; 17 | @property (weak) IBOutlet NSTextField *urlTextField; 18 | @property (weak) IBOutlet NSButton *goHttpButton; 19 | 20 | - (IBAction)goHttpAction:(id)sender; 21 | 22 | @end 23 | 24 | -------------------------------------------------------------------------------- /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 "AFNetworkReachabilityManager.h" 17 | #import "AFSecurityPolicy.h" 18 | #import "AFURLRequestSerialization.h" 19 | #import "AFURLResponseSerialization.h" 20 | 21 | FOUNDATION_EXPORT double AFNetworkingVersionNumber; 22 | FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[]; 23 | 24 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 5 | OTHER_LDFLAGS = -framework "CoreServices" -framework "Security" -framework "SystemConfiguration" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT} 9 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/AFNetworking 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/jenkins.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | AFNetworking.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | MJExtension.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 2 16 | 17 | Pods-JSONToModel.xcscheme_^#shared#^_ 18 | 19 | orderHint 20 | 3 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MJExtension/MJExtension-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 "MJExtension.h" 14 | #import "MJExtensionConst.h" 15 | #import "MJFoundation.h" 16 | #import "MJProperty.h" 17 | #import "MJPropertyKey.h" 18 | #import "MJPropertyType.h" 19 | #import "NSObject+MJClass.h" 20 | #import "NSObject+MJCoding.h" 21 | #import "NSObject+MJKeyValue.h" 22 | #import "NSObject+MJProperty.h" 23 | #import "NSString+MJExtension.h" 24 | 25 | FOUNDATION_EXPORT double MJExtensionVersionNumber; 26 | FOUNDATION_EXPORT const unsigned char MJExtensionVersionString[]; 27 | 28 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JSONToModel/Pods-JSONToModel.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/MJExtension" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/MJExtension/MJExtension.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "AFNetworking" -framework "MJExtension" 7 | PODS_BUILD_DIR = ${BUILD_DIR} 8 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 9 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 10 | PODS_ROOT = ${SRCROOT}/Pods 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JSONToModel/Pods-JSONToModel.release.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/MJExtension" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/MJExtension/MJExtension.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "AFNetworking" -framework "MJExtension" 7 | PODS_BUILD_DIR = ${BUILD_DIR} 8 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 9 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 10 | PODS_ROOT = ${SRCROOT}/Pods 11 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (3.1.0): 3 | - AFNetworking/NSURLSession (= 3.1.0) 4 | - AFNetworking/Reachability (= 3.1.0) 5 | - AFNetworking/Security (= 3.1.0) 6 | - AFNetworking/Serialization (= 3.1.0) 7 | - AFNetworking/UIKit (= 3.1.0) 8 | - AFNetworking/NSURLSession (3.1.0): 9 | - AFNetworking/Reachability 10 | - AFNetworking/Security 11 | - AFNetworking/Serialization 12 | - AFNetworking/Reachability (3.1.0) 13 | - AFNetworking/Security (3.1.0) 14 | - AFNetworking/Serialization (3.1.0) 15 | - MJExtension (3.0.13) 16 | 17 | DEPENDENCIES: 18 | - AFNetworking (~> 3.1.0) 19 | - MJExtension (~> 3.0.13) 20 | 21 | SPEC CHECKSUMS: 22 | AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 23 | MJExtension: 5932755f451458eefa24239358817f8d291240c7 24 | 25 | PODFILE CHECKSUM: f127c379c57021229b90ac29229e4e34d7d6ec42 26 | 27 | COCOAPODS: 1.4.0 28 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (3.1.0): 3 | - AFNetworking/NSURLSession (= 3.1.0) 4 | - AFNetworking/Reachability (= 3.1.0) 5 | - AFNetworking/Security (= 3.1.0) 6 | - AFNetworking/Serialization (= 3.1.0) 7 | - AFNetworking/UIKit (= 3.1.0) 8 | - AFNetworking/NSURLSession (3.1.0): 9 | - AFNetworking/Reachability 10 | - AFNetworking/Security 11 | - AFNetworking/Serialization 12 | - AFNetworking/Reachability (3.1.0) 13 | - AFNetworking/Security (3.1.0) 14 | - AFNetworking/Serialization (3.1.0) 15 | - MJExtension (3.0.13) 16 | 17 | DEPENDENCIES: 18 | - AFNetworking (~> 3.1.0) 19 | - MJExtension (~> 3.0.13) 20 | 21 | SPEC CHECKSUMS: 22 | AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 23 | MJExtension: 5932755f451458eefa24239358817f8d291240c7 24 | 25 | PODFILE CHECKSUM: f127c379c57021229b90ac29229e4e34d7d6ec42 26 | 27 | COCOAPODS: 1.4.0 28 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/luo.h.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | AFNetworking.xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | MJExtension.xcscheme 15 | 16 | isShown 17 | 18 | orderHint 19 | 1 20 | 21 | Pods-JSONToModel.xcscheme 22 | 23 | isShown 24 | 25 | orderHint 26 | 2 27 | 28 | 29 | SuppressBuildableAutocreation 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /JSONToModel/Categorys/NSDictionary+JSON.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+JSON.h 3 | // JSON_Model 4 | // 5 | // Created by luo.h on 2017/12/7. 6 | // Copyright © 2017年 meet.com.cn. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSDictionary (JSON) 12 | 13 | 14 | /** 15 | * 转换成JSON串字符串(没有可读性) 16 | * 17 | * @return JSON字符串 18 | */ 19 | - (NSString *)toJSONString; 20 | 21 | /** 22 | * 转换成JSON串字符串(有可读性) 23 | * 24 | * @return JSON字符串 25 | */ 26 | - (NSString *)toReadableJSONString; 27 | 28 | /** 29 | * 转换成JSON数据 30 | * 31 | * @return JSON数据 32 | */ 33 | - (NSData *)toJSONData; 34 | 35 | @end 36 | 37 | @interface NSString (JSON) 38 | 39 | + (NSString *)removeSpaceAndNewline:(NSString *)str; 40 | +(NSString *)removeAllSpace:(NSString *)str; 41 | - (NSString *)uppercaseFirstCharacter; 42 | 43 | -(id)objectFromJSONString;//JSONString to NSDictionary 44 | 45 | @end 46 | 47 | -------------------------------------------------------------------------------- /Pods/Target Support Files/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.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MJExtension/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.0.13 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JSONToModel/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 | -------------------------------------------------------------------------------- /JSONToModel/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | {"images":[{"size":"16x16","idiom":"mac","filename":"Mac-16.png","appearances":null,"scale":"1x"},{"size":"16x16","idiom":"mac","filename":"Mac-16@2x.png","appearances":null,"scale":"2x"},{"size":"32x32","idiom":"mac","filename":"Mac-32.png","appearances":null,"scale":"1x"},{"size":"32x32","idiom":"mac","filename":"Mac-32@2x.png","appearances":null,"scale":"2x"},{"size":"128x128","idiom":"mac","filename":"Mac-128.png","appearances":null,"scale":"1x"},{"size":"128x128","idiom":"mac","filename":"Mac-128@2x.png","appearances":null,"scale":"2x"},{"size":"256x256","idiom":"mac","filename":"Mac-256.png","appearances":null,"scale":"1x"},{"size":"256x256","idiom":"mac","filename":"Mac-256@2x.png","appearances":null,"scale":"2x"},{"size":"512x512","idiom":"mac","filename":"Mac-512.png","appearances":null,"scale":"1x"},{"size":"512x512","idiom":"mac","filename":"App Store-512@2x.png","appearances":null,"scale":"2x"}],"info":{"version":1,"author":"xcode"}} -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /Pods/AFNetworking/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011–2016 Alamofire Software Foundation (http://alamofire.org/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /Pods/MJExtension/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2015 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 | -------------------------------------------------------------------------------- /JSONToModel/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2018年 hl.com.cn. All rights reserved. 27 | NSMainStoryboardFile 28 | Main 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /JSONToModel/Resouces/xcodetheme.css: -------------------------------------------------------------------------------- 1 | .hljs { 2 | display:block; 3 | overflow-x:auto; 4 | padding:0.5em; 5 | background:#fff; 6 | color:black 7 | } 8 | .hljs-comment,.hljs-quote { 9 | color:#006a00 10 | } 11 | .hljs-keyword,.hljs-selector-tag,.hljs-literal { 12 | color:#aa0d91 13 | } 14 | .hljs-name { 15 | color:#008 16 | } 17 | .hljs-variable,.hljs-template-variable { 18 | color:#660 19 | } 20 | .hljs-string { 21 | color:#c41a16 22 | } 23 | .hljs-regexp,.hljs-link { 24 | color:#080 25 | } 26 | .hljs-title,.hljs-tag,.hljs-symbol,.hljs-bullet,.hljs-number,.hljs-meta { 27 | color:#1c00cf 28 | } 29 | .hljs-section,.hljs-class .hljs-title,.hljs-type,.hljs-attr,.hljs-built_in,.hljs-builtin-name,.hljs-params { 30 | color:#5c2699 31 | } 32 | .hljs-attribute,.hljs-subst { 33 | color:#000 34 | } 35 | .hljs-formula { 36 | background-color:#eee; 37 | font-style:italic 38 | } 39 | .hljs-addition { 40 | background-color:#baeeba 41 | } 42 | .hljs-deletion { 43 | background-color:#ffc8bd 44 | } 45 | .hljs-selector-id,.hljs-selector-class { 46 | color:#9b703f 47 | } 48 | .hljs-doctag,.hljs-strong { 49 | font-weight:bold 50 | } 51 | .hljs-emphasis { 52 | font-style:italic 53 | } 54 | -------------------------------------------------------------------------------- /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 | 35 | @interface NSString (MJExtensionDeprecated_v_2_5_16) 36 | - (NSString *)underlineFromCamel MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 37 | - (NSString *)camelFromUnderline MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 38 | - (NSString *)firstCharUpper MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 39 | - (NSString *)firstCharLower MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 40 | - (BOOL)isPureInt MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 41 | - (NSURL *)url MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 42 | @end 43 | -------------------------------------------------------------------------------- /JSONToModel/Resouces/xcodetheme.json: -------------------------------------------------------------------------------- 1 | { 2 | ".hljs": { 3 | "display": "block", 4 | "overflow-x": "auto", 5 | "padding": "0.5em", 6 | "background": "#fff", 7 | "color": "black" 8 | }, 9 | ".hljs-comment,.hljs-quote": { 10 | "color": "#006a00" 11 | }, 12 | ".hljs-keyword,.hljs-selector-tag,.hljs-literal": { 13 | "color": "#aa0d91" 14 | }, 15 | ".hljs-name": { 16 | "color": "#008" 17 | }, 18 | ".hljs-variable,.hljs-template-variable": { 19 | "color": "#660" 20 | }, 21 | ".hljs-string": { 22 | "color": "#c41a16" 23 | }, 24 | ".hljs-regexp,.hljs-link": { 25 | "color": "#080" 26 | }, 27 | ".hljs-title,.hljs-tag,.hljs-symbol,.hljs-bullet,.hljs-number,.hljs-meta": { 28 | "color": "#1c00cf" 29 | }, 30 | ".hljs-section,.hljs-class .hljs-title,.hljs-type,.hljs-attr,.hljs-built_in,.hljs-builtin-name,.hljs-params": { 31 | "color": "#00AFCA" 32 | }, 33 | ".hljs-attribute,.hljs-subst": { 34 | "color": "#000" 35 | }, 36 | ".hljs-formula": { 37 | "background-color": "#eee", 38 | "font-style": "italic" 39 | }, 40 | ".hljs-addition": { 41 | "background-color": "#baeeba" 42 | }, 43 | ".hljs-deletion": { 44 | "background-color": "#ffc8bd" 45 | }, 46 | ".hljs-selector-id,.hljs-selector-class": { 47 | "color": "#9b703f" 48 | }, 49 | ".hljs-doctag,.hljs-strong": { 50 | "font-weight": "bold" 51 | }, 52 | ".hljs-emphasis": { 53 | "font-style": "italic" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JSONToModel 2 | 工欲善其事,必先利其器,要想不加班、少加班,进行高效率工作,开发辅助工具是必不可少的,JSONToModel就是这样一款将JSON字符转换成model代码的开源工具。虽然网上有很多类似工具,但有个共同特点就是没有代码高亮,不美观,有的不支持网络请求将直接JSON数据生成模型代码。 3 | 4 | 其实整个工程主要技术要点在于如何使用Textkit进行代码高亮,模型生成功能就百来行代码,更像一个附加功能,但基本能满足正常开发需求。 5 | 6 | 功能及技术点: 7 | 一、字典转模型代码 8 | 对粘贴JSON字符进行空格过滤处理,减少出现JSON数据不合法情况 9 | 支持网络请求JSON数据进行模型转换 10 | 11 | 二、代码高亮 12 | 使用正则匹配关键词进行代码高亮 13 | 使用highlight.jsjs库进行代码高亮 14 | 正则匹配与js库2种方式进行进行代码高亮,JavaScript有很多优秀的代码高亮库,以后用到代码高亮功能可以直接用js库来处理,在高亮效率,支持语言数量上都是一个不错的选择。 15 | 具体实现移步代码:JSONToModel 16 | 17 | 效果 18 | ![UC20180319_143058.png](https://upload-images.jianshu.io/upload_images/328273-f9848cf7ee69bfd0..png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp) 19 | 20 | BugFIX: 21 | 使用TextKit进行代码高亮时,在iOS上正常,但在Mac OSX上会出现光标错位情况 22 | https://stackoverflow.com/questions/35522394/nstextstorage-syntax-markdown 23 | Why the Selection Changes When You Do Syntax Highlighting in a NSTextView and What You Can Do About It 24 | 25 | Thanks: 26 | AFNetworking 27 | MJExtension 28 | NSTextView-LineNumberView 29 | highlightjs 30 | 31 | 下版本功能: 32 | 1、支持Swift模型代码生成 33 | 2、支持GET参数请求,支持POST请求 34 | 3、敬请期待 35 | 36 | Github:https://github.com/huluo666/JSONToModel 37 | 38 | 相关:CSS转JSON 39 | 40 | 参考文档 41 | https://github.com/objcio/issue-5-textkit 42 | https://github.com/objcio/S01E91-rendering-markdown-with-syntax-highlighting 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /JSONToModel/Categorys/NSColor+HexColor.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSColor+HexColor.m 3 | // JSONToModel 4 | // 5 | // Created by luo.h on 2018/3/15. 6 | // Copyright © 2018年 hl.com.cn. All rights reserved. 7 | // 8 | 9 | #import "NSColor+HexColor.h" 10 | 11 | @implementation NSColor (HexColor) 12 | 13 | + (NSColor *) colorFromHexCode:(NSString *)hexString { 14 | NSString *cleanString = [hexString stringByReplacingOccurrencesOfString:@"#" withString:@""]; 15 | if([cleanString length] == 3) { 16 | cleanString = [NSString stringWithFormat:@"%@%@%@%@%@%@", 17 | [cleanString substringWithRange:NSMakeRange(0, 1)],[cleanString substringWithRange:NSMakeRange(0, 1)], 18 | [cleanString substringWithRange:NSMakeRange(1, 1)],[cleanString substringWithRange:NSMakeRange(1, 1)], 19 | [cleanString substringWithRange:NSMakeRange(2, 1)],[cleanString substringWithRange:NSMakeRange(2, 1)]]; 20 | } 21 | if([cleanString length] == 6) { 22 | cleanString = [cleanString stringByAppendingString:@"ff"]; 23 | } 24 | 25 | unsigned int baseValue; 26 | [[NSScanner scannerWithString:cleanString] scanHexInt:&baseValue]; 27 | 28 | float red = ((baseValue >> 24) & 0xFF)/255.0f; 29 | float green = ((baseValue >> 16) & 0xFF)/255.0f; 30 | float blue = ((baseValue >> 8) & 0xFF)/255.0f; 31 | float alpha = ((baseValue >> 0) & 0xFF)/255.0f; 32 | 33 | return [NSColor colorWithRed:red green:green blue:blue alpha:alpha]; 34 | } 35 | 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /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 | 13 | static NSSet *foundationClasses_; 14 | 15 | @implementation MJFoundation 16 | 17 | + (NSSet *)foundationClasses 18 | { 19 | if (foundationClasses_ == nil) { 20 | // 集合中没有NSObject,因为几乎所有的类都是继承自NSObject,具体是不是NSObject需要特殊判断 21 | foundationClasses_ = [NSSet setWithObjects: 22 | [NSURL class], 23 | [NSDate class], 24 | [NSValue class], 25 | [NSData class], 26 | [NSError class], 27 | [NSArray class], 28 | [NSDictionary class], 29 | [NSString class], 30 | [NSAttributedString class], nil]; 31 | } 32 | return foundationClasses_; 33 | } 34 | 35 | + (BOOL)isClassFromFoundation:(Class)c 36 | { 37 | if (c == [NSObject class] || c == [NSManagedObject class]) return YES; 38 | 39 | __block BOOL result = NO; 40 | [[self foundationClasses] enumerateObjectsUsingBlock:^(Class foundationClass, BOOL *stop) { 41 | if ([c isSubclassOfClass:foundationClass]) { 42 | result = YES; 43 | *stop = YES; 44 | } 45 | }]; 46 | return result; 47 | } 48 | @end 49 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /JSONToModel/thirdLibs/Highlighter/languages/objectivec.min.js: -------------------------------------------------------------------------------- 1 | hljs.registerLanguage("objectivec",function(e){var t={cN:"built_in",b:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},_={keyword:"int float while char export sizeof typedef const struct for union unsigned long volatile static bool mutable if do return goto void enum else break extern asm case short default double register explicit signed typename this switch continue wchar_t inline readonly assign readwrite self @synchronized id typeof nonatomic super unichar IBOutlet IBAction strong weak copy in out inout bycopy byref oneway __strong __weak __block __autoreleasing @private @protected @public @try @property @end @throw @catch @finally @autoreleasepool @synthesize @dynamic @selector @optional @required @encode @package @import @defs @compatibility_alias __bridge __bridge_transfer __bridge_retained __bridge_retain __covariant __contravariant __kindof _Nonnull _Nullable _Null_unspecified __FUNCTION__ __PRETTY_FUNCTION__ __attribute__ getter setter retain unsafe_unretained nonnull nullable null_unspecified null_resettable class instancetype NS_DESIGNATED_INITIALIZER NS_UNAVAILABLE NS_REQUIRES_SUPER NS_RETURNS_INNER_POINTER NS_INLINE NS_AVAILABLE NS_DEPRECATED NS_ENUM NS_OPTIONS NS_SWIFT_UNAVAILABLE NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END NS_REFINED_FOR_SWIFT NS_SWIFT_NAME NS_SWIFT_NOTHROW NS_DURING NS_HANDLER NS_ENDHANDLER NS_VALUERETURN NS_VOIDRETURN",literal:"false true FALSE TRUE nil YES NO NULL",built_in:"BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once"},i=/[a-zA-Z@][a-zA-Z0-9_]*/,n="@interface @class @protocol @implementation";return{aliases:["mm","objc","obj-c"],k:_,l:i,i:""}]}]},{cN:"class",b:"("+n.split(" ").join("|")+")\\b",e:"({|$)",eE:!0,k:n,l:i,c:[e.UTM]},{b:"\\."+e.UIR,r:0}]}}); -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /JSONToModel/thirdLibs/AFNetClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // AFNetClient.h 3 | // MLSocketioChat 4 | // 5 | // Created by luo.h on 2017/10/13. 6 | // Copyright © 2017年 apple.com..cn. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AFNetworking.h" 11 | 12 | typedef void (^MTSuccessBlock)(NSHTTPURLResponse *response,id JSONDict); 13 | typedef void (^MTFailedBlock)(NSError *error); 14 | 15 | @interface AFNetClient : NSObject 16 | 17 | + (AFHTTPSessionManager *)defaultManager; 18 | 19 | + (void)uploadImage; 20 | 21 | 22 | /** 23 | @ get 请求 24 | @param path 无参数 25 | */ 26 | + (NSURLSessionTask *)GET_Path:(NSString *)path completed:(MTSuccessBlock )successBlock failed:(MTFailedBlock )faileBlock; 27 | 28 | +(NSURLSessionTask *)GET_Path:(NSString *)path 29 | params:(NSDictionary *)params 30 | headers:(NSDictionary *)headers 31 | completed:(MTSuccessBlock )successBlock failed:(MTFailedBlock )faileBlock; 32 | /** 33 | @ get 请求 34 | @param path 有参数 35 | */ 36 | +(NSURLSessionTask *)GET_Path:(NSString *)path params:(NSDictionary *)params completed:(MTSuccessBlock )successBlock failed:(MTFailedBlock )faileBlock; 37 | 38 | /** 39 | @ POST 请求 无参数 40 | */ 41 | + (void)POST_Path:(NSString *)path completed:(MTSuccessBlock )successBlock failed:(MTFailedBlock )faileBlock; 42 | 43 | 44 | /** 45 | @ POST 请求 有参数 46 | */ 47 | + (void)POST_Path:(NSString *)path params:(NSDictionary *)paramsDic completed:(MTSuccessBlock )successBlock failed:(MTFailedBlock )faileBlock; 48 | 49 | 50 | +(void)POST_Path:(NSString *)path 51 | params:(NSDictionary *)params 52 | headers:(NSDictionary *)headers 53 | completed:(MTSuccessBlock )successBlock failed:(MTFailedBlock )faileBlock; 54 | 55 | 56 | 57 | 58 | #pragma mark=================监测网络状态================ 59 | /**网络状态Block*/ 60 | typedef void(^AFNetworkStatusBlock)(AFNetworkReachabilityStatus status); 61 | 62 | /*实时获取网络状态,此方法可多次调用*/ 63 | + (void)networkStatusWithBlock:(AFNetworkStatusBlock)networkStatus; 64 | 65 | /*判断是否有网*/ 66 | + (BOOL)isNetwork; 67 | 68 | /*是否是手机网络*/ 69 | + (BOOL)isWWANNetwork; 70 | 71 | /*是否是WiFi网络*/ 72 | + (BOOL)isWiFiNetwork; 73 | 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/luo.h.xcuserdatad/xcschemes/AFNetworking.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/luo.h.xcuserdatad/xcschemes/MJExtension.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /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 | static NSMutableDictionary *types_; 17 | + (void)initialize 18 | { 19 | types_ = [NSMutableDictionary dictionary]; 20 | } 21 | 22 | + (instancetype)cachedTypeWithCode:(NSString *)code 23 | { 24 | MJExtensionAssertParamNotNil2(code, nil); 25 | @synchronized (self) { 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 | 36 | #pragma mark - 公共方法 37 | - (void)setCode:(NSString *)code 38 | { 39 | _code = code; 40 | 41 | MJExtensionAssertParamNotNil(code); 42 | 43 | if ([code isEqualToString:MJPropertyTypeId]) { 44 | _idType = YES; 45 | } else if (code.length == 0) { 46 | _KVCDisabled = YES; 47 | } else if (code.length > 3 && [code hasPrefix:@"@\""]) { 48 | // 去掉@"和",截取中间的类型名称 49 | _code = [code substringWithRange:NSMakeRange(2, code.length - 3)]; 50 | _typeClass = NSClassFromString(_code); 51 | _fromFoundation = [MJFoundation isClassFromFoundation:_typeClass]; 52 | _numberType = [_typeClass isSubclassOfClass:[NSNumber class]]; 53 | 54 | } else if ([code isEqualToString:MJPropertyTypeSEL] || 55 | [code isEqualToString:MJPropertyTypeIvar] || 56 | [code isEqualToString:MJPropertyTypeMethod]) { 57 | _KVCDisabled = YES; 58 | } 59 | 60 | // 是否为数字类型 61 | NSString *lowerCode = _code.lowercaseString; 62 | NSArray *numberTypes = @[MJPropertyTypeInt, MJPropertyTypeShort, MJPropertyTypeBOOL1, MJPropertyTypeBOOL2, MJPropertyTypeFloat, MJPropertyTypeDouble, MJPropertyTypeLong, MJPropertyTypeLongLong, MJPropertyTypeChar]; 63 | if ([numberTypes containsObject:lowerCode]) { 64 | _numberType = YES; 65 | 66 | if ([lowerCode isEqualToString:MJPropertyTypeBOOL1] 67 | || [lowerCode isEqualToString:MJPropertyTypeBOOL2]) { 68 | _boolType = YES; 69 | } 70 | } 71 | } 72 | @end 73 | -------------------------------------------------------------------------------- /JSONToModel.xcworkspace/xcuserdata/luo.h.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 18 | 24 | 25 | 26 | 27 | 28 | 30 | 42 | 43 | 44 | 46 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /Pods/MJExtension/MJExtension/MJExtensionConst.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __MJExtensionConst__H__ 3 | #define __MJExtensionConst__H__ 4 | 5 | #import 6 | 7 | // 过期 8 | #define MJExtensionDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead) 9 | 10 | // 构建错误 11 | #define MJExtensionBuildError(clazz, msg) \ 12 | NSError *error = [NSError errorWithDomain:msg code:250 userInfo:nil]; \ 13 | [clazz setMj_error:error]; 14 | 15 | // 日志输出 16 | #ifdef DEBUG 17 | #define MJExtensionLog(...) NSLog(__VA_ARGS__) 18 | #else 19 | #define MJExtensionLog(...) 20 | #endif 21 | 22 | /** 23 | * 断言 24 | * @param condition 条件 25 | * @param returnValue 返回值 26 | */ 27 | #define MJExtensionAssertError(condition, returnValue, clazz, msg) \ 28 | [clazz setMj_error:nil]; \ 29 | if ((condition) == NO) { \ 30 | MJExtensionBuildError(clazz, msg); \ 31 | return returnValue;\ 32 | } 33 | 34 | #define MJExtensionAssert2(condition, returnValue) \ 35 | if ((condition) == NO) return returnValue; 36 | 37 | /** 38 | * 断言 39 | * @param condition 条件 40 | */ 41 | #define MJExtensionAssert(condition) MJExtensionAssert2(condition, ) 42 | 43 | /** 44 | * 断言 45 | * @param param 参数 46 | * @param returnValue 返回值 47 | */ 48 | #define MJExtensionAssertParamNotNil2(param, returnValue) \ 49 | MJExtensionAssert2((param) != nil, returnValue) 50 | 51 | /** 52 | * 断言 53 | * @param param 参数 54 | */ 55 | #define MJExtensionAssertParamNotNil(param) MJExtensionAssertParamNotNil2(param, ) 56 | 57 | /** 58 | * 打印所有的属性 59 | */ 60 | #define MJLogAllIvars \ 61 | -(NSString *)description \ 62 | { \ 63 | return [self mj_keyValues].description; \ 64 | } 65 | #define MJExtensionLogAllProperties MJLogAllIvars 66 | 67 | /** 68 | * 类型(属性类型) 69 | */ 70 | extern NSString *const MJPropertyTypeInt; 71 | extern NSString *const MJPropertyTypeShort; 72 | extern NSString *const MJPropertyTypeFloat; 73 | extern NSString *const MJPropertyTypeDouble; 74 | extern NSString *const MJPropertyTypeLong; 75 | extern NSString *const MJPropertyTypeLongLong; 76 | extern NSString *const MJPropertyTypeChar; 77 | extern NSString *const MJPropertyTypeBOOL1; 78 | extern NSString *const MJPropertyTypeBOOL2; 79 | extern NSString *const MJPropertyTypePointer; 80 | 81 | extern NSString *const MJPropertyTypeIvar; 82 | extern NSString *const MJPropertyTypeMethod; 83 | extern NSString *const MJPropertyTypeBlock; 84 | extern NSString *const MJPropertyTypeClass; 85 | extern NSString *const MJPropertyTypeSEL; 86 | extern NSString *const MJPropertyTypeId; 87 | 88 | #endif -------------------------------------------------------------------------------- /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)(); 18 | /** 这个数组中的属性名才会进行归档 */ 19 | typedef NSArray * (^MJAllowedCodingPropertyNames)(); 20 | 21 | /** 这个数组中的属性名将会被忽略:不进行字典和模型的转换 */ 22 | typedef NSArray * (^MJIgnoredPropertyNames)(); 23 | /** 这个数组中的属性名将会被忽略:不进行归档 */ 24 | typedef NSArray * (^MJIgnoredCodingPropertyNames)(); 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 (^)())block key:(const char *)key; 90 | @end 91 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JSONToModel/Pods-JSONToModel-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## AFNetworking 5 | 6 | Copyright (c) 2011–2016 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 | ## MJExtension 28 | 29 | Copyright (c) 2013-2015 MJExtension (https://github.com/CoderMJLee/MJExtension) 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 | Generated by CocoaPods - https://cocoapods.org 50 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/luo.h.xcuserdatad/xcschemes/Pods-JSONToModel.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 47 | 48 | 54 | 55 | 56 | 57 | 58 | 59 | 65 | 66 | 68 | 69 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /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)(); 24 | typedef id (^MJReplacedKeyFromPropertyName121)(NSString *propertyName); 25 | /** 数组中需要转换的模型类 */ 26 | typedef NSDictionary * (^MJObjectClassInArray)(); 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 | 72 | @interface NSObject (MJPropertyDeprecated_v_2_5_16) 73 | + (void)enumerateProperties:(MJPropertiesEnumeration)enumeration MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 74 | + (void)setupNewValueFromOldValue:(MJNewValueFromOldValue)newValueFormOldValue MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 75 | + (id)getNewValueFromObject:(__unsafe_unretained id)object oldValue:(__unsafe_unretained id)oldValue property:(__unsafe_unretained MJProperty *)property MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 76 | + (void)setupReplacedKeyFromPropertyName:(MJReplacedKeyFromPropertyName)replacedKeyFromPropertyName MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 77 | + (void)setupReplacedKeyFromPropertyName121:(MJReplacedKeyFromPropertyName121)replacedKeyFromPropertyName121 MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 78 | + (void)setupObjectClassInArray:(MJObjectClassInArray)objectClassInArray MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 79 | @end -------------------------------------------------------------------------------- /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 | 82 | @implementation NSString (MJExtensionDeprecated_v_2_5_16) 83 | - (NSString *)underlineFromCamel 84 | { 85 | return self.mj_underlineFromCamel; 86 | } 87 | 88 | - (NSString *)camelFromUnderline 89 | { 90 | return self.mj_camelFromUnderline; 91 | } 92 | 93 | - (NSString *)firstCharLower 94 | { 95 | return self.mj_firstCharLower; 96 | } 97 | 98 | - (NSString *)firstCharUpper 99 | { 100 | return self.mj_firstCharUpper; 101 | } 102 | 103 | - (BOOL)isPureInt 104 | { 105 | return self.mj_isPureInt; 106 | } 107 | 108 | - (NSURL *)url 109 | { 110 | return self.mj_url; 111 | } 112 | @end 113 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JSONToModel/Pods-JSONToModel-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2011–2016 Alamofire Software Foundation (http://alamofire.org/) 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | License 38 | MIT 39 | Title 40 | AFNetworking 41 | Type 42 | PSGroupSpecifier 43 | 44 | 45 | FooterText 46 | Copyright (c) 2013-2015 MJExtension (https://github.com/CoderMJLee/MJExtension) 47 | 48 | Permission is hereby granted, free of charge, to any person obtaining a copy 49 | of this software and associated documentation files (the "Software"), to deal 50 | in the Software without restriction, including without limitation the rights 51 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 52 | copies of the Software, and to permit persons to whom the Software is 53 | furnished to do so, subject to the following conditions: 54 | 55 | The above copyright notice and this permission notice shall be included in 56 | all copies or substantial portions of the Software. 57 | 58 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 59 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 60 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 61 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 62 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 63 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 64 | THE SOFTWARE. 65 | 66 | License 67 | MIT 68 | Title 69 | MJExtension 70 | Type 71 | PSGroupSpecifier 72 | 73 | 74 | FooterText 75 | Generated by CocoaPods - https://cocoapods.org 76 | Title 77 | 78 | Type 79 | PSGroupSpecifier 80 | 81 | 82 | StringsTable 83 | Acknowledgements 84 | Title 85 | Acknowledgements 86 | 87 | 88 | -------------------------------------------------------------------------------- /JSONToModel/Categorys/NSDictionary+JSON.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+JSON.m 3 | // JSON_Model 4 | // 5 | // Created by luo.h on 2017/12/7. 6 | // Copyright © 2017年 meet.com.cn. All rights reserved. 7 | // 8 | 9 | #import "NSDictionary+JSON.h" 10 | 11 | @implementation NSDictionary (JSON) 12 | 13 | 14 | - (NSString *)toJSONString { 15 | NSData *data = [NSJSONSerialization dataWithJSONObject:self 16 | options:NSJSONReadingMutableLeaves | NSJSONReadingAllowFragments 17 | error:nil]; 18 | 19 | if (data == nil) { 20 | return nil; 21 | } 22 | 23 | NSString *string = [[NSString alloc] initWithData:data 24 | encoding:NSUTF8StringEncoding]; 25 | return string; 26 | } 27 | 28 | - (NSString *)toReadableJSONString { 29 | NSData *data = [NSJSONSerialization dataWithJSONObject:self 30 | options:NSJSONWritingPrettyPrinted 31 | error:nil]; 32 | 33 | if (data == nil) { 34 | return nil; 35 | } 36 | 37 | NSString *string = [[NSString alloc] initWithData:data 38 | encoding:NSUTF8StringEncoding]; 39 | return string; 40 | } 41 | 42 | - (NSData *)toJSONData { 43 | NSData *data = [NSJSONSerialization dataWithJSONObject:self 44 | options:NSJSONWritingPrettyPrinted 45 | error:nil]; 46 | 47 | return data; 48 | } 49 | 50 | @end 51 | 52 | 53 | @implementation NSString (JSON) 54 | 55 | + (NSString *)removeSpaceAndNewline:(NSString *)json 56 | { 57 | NSString *st = [json stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 58 | st = [st stringByReplacingOccurrencesOfString:@"\r" withString:@""]; 59 | st = [st stringByReplacingOccurrencesOfString:@"\n" withString:@""]; 60 | st = [st stringByReplacingOccurrencesOfString:@"\t" withString:@""]; 61 | st = [st stringByReplacingOccurrencesOfString:@" " withString:@""]; 62 | return st; 63 | } 64 | 65 | +(NSString *)removeAllSpace:(NSString *)str 66 | { 67 | NSArray* words = [str componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 68 | NSString* nospacestring = [words componentsJoinedByString:@""]; 69 | return nospacestring; 70 | } 71 | 72 | - (NSString *)uppercaseFirstCharacter 73 | { 74 | if (self.length > 0) { 75 | char c = [self characterAtIndex:0]; 76 | if (c >= 'a' && c <= 'z') { 77 | return [NSString stringWithFormat:@"%c%@", toupper(c), [self substringFromIndex:1]]; 78 | } 79 | } 80 | return self; 81 | } 82 | 83 | 84 | 85 | - (id)objectFromJSONString{ 86 | NSError * error; 87 | NSData *jsonData = [self dataUsingEncoding:NSUTF8StringEncoding]; 88 | NSDictionary *jsonObj = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error]; 89 | if (!jsonObj || error) { 90 | NSLog(@"JSON解析失败,开始去除换行符等"); 91 | //当解析失败去掉可能的非法字符, 为适配部分接口问题 92 | if ([self length]) 93 | { 94 | NSString *string = [self stringByReplacingOccurrencesOfString:@"\r" withString:@""]; 95 | string = [string stringByReplacingOccurrencesOfString:@"\n" withString:@""]; 96 | string = [string stringByReplacingOccurrencesOfString:@"\t" withString:@" "]; 97 | jsonData = [string dataUsingEncoding:NSUTF8StringEncoding]; 98 | if (jsonData) { 99 | jsonObj = [NSJSONSerialization JSONObjectWithData:jsonData 100 | options:NSJSONReadingMutableContainers 101 | error:nil]; 102 | } 103 | if (!jsonObj) { 104 | NSLog(@"JSON解析仍然失败 Error: %@", error); 105 | return nil; 106 | } 107 | } 108 | return jsonObj; 109 | } else { 110 | return jsonObj; 111 | } 112 | return nil; 113 | } 114 | @end 115 | -------------------------------------------------------------------------------- /Pods/MJExtension/MJExtension/MJProperty.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJProperty.m 3 | // MJExtensionExample 4 | // 5 | // Created by MJ Lee on 15/4/17. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJProperty.h" 10 | #import "MJFoundation.h" 11 | #import "MJExtensionConst.h" 12 | #import 13 | 14 | @interface MJProperty() 15 | @property (strong, nonatomic) NSMutableDictionary *propertyKeysDict; 16 | @property (strong, nonatomic) NSMutableDictionary *objectClassInArrayDict; 17 | @end 18 | 19 | @implementation MJProperty 20 | 21 | #pragma mark - 初始化 22 | - (instancetype)init 23 | { 24 | if (self = [super init]) { 25 | _propertyKeysDict = [NSMutableDictionary dictionary]; 26 | _objectClassInArrayDict = [NSMutableDictionary dictionary]; 27 | } 28 | return self; 29 | } 30 | 31 | #pragma mark - 缓存 32 | + (instancetype)cachedPropertyWithProperty:(objc_property_t)property 33 | { 34 | MJProperty *propertyObj = objc_getAssociatedObject(self, property); 35 | if (propertyObj == nil) { 36 | propertyObj = [[self alloc] init]; 37 | propertyObj.property = property; 38 | objc_setAssociatedObject(self, property, propertyObj, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 39 | } 40 | return propertyObj; 41 | } 42 | 43 | #pragma mark - 公共方法 44 | - (void)setProperty:(objc_property_t)property 45 | { 46 | _property = property; 47 | 48 | MJExtensionAssertParamNotNil(property); 49 | 50 | // 1.属性名 51 | _name = @(property_getName(property)); 52 | 53 | // 2.成员类型 54 | NSString *attrs = @(property_getAttributes(property)); 55 | NSUInteger dotLoc = [attrs rangeOfString:@","].location; 56 | NSString *code = nil; 57 | NSUInteger loc = 1; 58 | if (dotLoc == NSNotFound) { // 没有, 59 | code = [attrs substringFromIndex:loc]; 60 | } else { 61 | code = [attrs substringWithRange:NSMakeRange(loc, dotLoc - loc)]; 62 | } 63 | _type = [MJPropertyType cachedTypeWithCode:code]; 64 | } 65 | 66 | /** 67 | * 获得成员变量的值 68 | */ 69 | - (id)valueForObject:(id)object 70 | { 71 | if (self.type.KVCDisabled) return [NSNull null]; 72 | return [object valueForKey:self.name]; 73 | } 74 | 75 | /** 76 | * 设置成员变量的值 77 | */ 78 | - (void)setValue:(id)value forObject:(id)object 79 | { 80 | if (self.type.KVCDisabled || value == nil) return; 81 | [object setValue:value forKey:self.name]; 82 | } 83 | 84 | /** 85 | * 通过字符串key创建对应的keys 86 | */ 87 | - (NSArray *)propertyKeysWithStringKey:(NSString *)stringKey 88 | { 89 | if (stringKey.length == 0) return nil; 90 | 91 | NSMutableArray *propertyKeys = [NSMutableArray array]; 92 | // 如果有多级映射 93 | NSArray *oldKeys = [stringKey componentsSeparatedByString:@"."]; 94 | 95 | for (NSString *oldKey in oldKeys) { 96 | NSUInteger start = [oldKey rangeOfString:@"["].location; 97 | if (start != NSNotFound) { // 有索引的key 98 | NSString *prefixKey = [oldKey substringToIndex:start]; 99 | NSString *indexKey = prefixKey; 100 | if (prefixKey.length) { 101 | MJPropertyKey *propertyKey = [[MJPropertyKey alloc] init]; 102 | propertyKey.name = prefixKey; 103 | [propertyKeys addObject:propertyKey]; 104 | 105 | indexKey = [oldKey stringByReplacingOccurrencesOfString:prefixKey withString:@""]; 106 | } 107 | 108 | /** 解析索引 **/ 109 | // 元素 110 | NSArray *cmps = [[indexKey stringByReplacingOccurrencesOfString:@"[" withString:@""] componentsSeparatedByString:@"]"]; 111 | for (NSInteger i = 0; i 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 | static NSMutableDictionary *allowedPropertyNamesDict_; 21 | static NSMutableDictionary *ignoredPropertyNamesDict_; 22 | static NSMutableDictionary *allowedCodingPropertyNamesDict_; 23 | static NSMutableDictionary *ignoredCodingPropertyNamesDict_; 24 | 25 | @implementation NSObject (MJClass) 26 | 27 | + (void)load 28 | { 29 | allowedPropertyNamesDict_ = [NSMutableDictionary dictionary]; 30 | ignoredPropertyNamesDict_ = [NSMutableDictionary dictionary]; 31 | allowedCodingPropertyNamesDict_ = [NSMutableDictionary dictionary]; 32 | ignoredCodingPropertyNamesDict_ = [NSMutableDictionary dictionary]; 33 | } 34 | 35 | + (NSMutableDictionary *)dictForKey:(const void *)key 36 | { 37 | @synchronized (self) { 38 | if (key == &MJAllowedPropertyNamesKey) return allowedPropertyNamesDict_; 39 | if (key == &MJIgnoredPropertyNamesKey) return ignoredPropertyNamesDict_; 40 | if (key == &MJAllowedCodingPropertyNamesKey) return allowedCodingPropertyNamesDict_; 41 | if (key == &MJIgnoredCodingPropertyNamesKey) return ignoredCodingPropertyNamesDict_; 42 | return nil; 43 | } 44 | } 45 | 46 | + (void)mj_enumerateClasses:(MJClassesEnumeration)enumeration 47 | { 48 | // 1.没有block就直接返回 49 | if (enumeration == nil) return; 50 | 51 | // 2.停止遍历的标记 52 | BOOL stop = NO; 53 | 54 | // 3.当前正在遍历的类 55 | Class c = self; 56 | 57 | // 4.开始遍历每一个类 58 | while (c && !stop) { 59 | // 4.1.执行操作 60 | enumeration(c, &stop); 61 | 62 | // 4.2.获得父类 63 | c = class_getSuperclass(c); 64 | 65 | if ([MJFoundation isClassFromFoundation:c]) break; 66 | } 67 | } 68 | 69 | + (void)mj_enumerateAllClasses:(MJClassesEnumeration)enumeration 70 | { 71 | // 1.没有block就直接返回 72 | if (enumeration == nil) return; 73 | 74 | // 2.停止遍历的标记 75 | BOOL stop = NO; 76 | 77 | // 3.当前正在遍历的类 78 | Class c = self; 79 | 80 | // 4.开始遍历每一个类 81 | while (c && !stop) { 82 | // 4.1.执行操作 83 | enumeration(c, &stop); 84 | 85 | // 4.2.获得父类 86 | c = class_getSuperclass(c); 87 | } 88 | } 89 | 90 | #pragma mark - 属性黑名单配置 91 | + (void)mj_setupIgnoredPropertyNames:(MJIgnoredPropertyNames)ignoredPropertyNames 92 | { 93 | [self mj_setupBlockReturnValue:ignoredPropertyNames key:&MJIgnoredPropertyNamesKey]; 94 | } 95 | 96 | + (NSMutableArray *)mj_totalIgnoredPropertyNames 97 | { 98 | return [self mj_totalObjectsWithSelector:@selector(mj_ignoredPropertyNames) key:&MJIgnoredPropertyNamesKey]; 99 | } 100 | 101 | #pragma mark - 归档属性黑名单配置 102 | + (void)mj_setupIgnoredCodingPropertyNames:(MJIgnoredCodingPropertyNames)ignoredCodingPropertyNames 103 | { 104 | [self mj_setupBlockReturnValue:ignoredCodingPropertyNames key:&MJIgnoredCodingPropertyNamesKey]; 105 | } 106 | 107 | + (NSMutableArray *)mj_totalIgnoredCodingPropertyNames 108 | { 109 | return [self mj_totalObjectsWithSelector:@selector(mj_ignoredCodingPropertyNames) key:&MJIgnoredCodingPropertyNamesKey]; 110 | } 111 | 112 | #pragma mark - 属性白名单配置 113 | + (void)mj_setupAllowedPropertyNames:(MJAllowedPropertyNames)allowedPropertyNames; 114 | { 115 | [self mj_setupBlockReturnValue:allowedPropertyNames key:&MJAllowedPropertyNamesKey]; 116 | } 117 | 118 | + (NSMutableArray *)mj_totalAllowedPropertyNames 119 | { 120 | return [self mj_totalObjectsWithSelector:@selector(mj_allowedPropertyNames) key:&MJAllowedPropertyNamesKey]; 121 | } 122 | 123 | #pragma mark - 归档属性白名单配置 124 | + (void)mj_setupAllowedCodingPropertyNames:(MJAllowedCodingPropertyNames)allowedCodingPropertyNames 125 | { 126 | [self mj_setupBlockReturnValue:allowedCodingPropertyNames key:&MJAllowedCodingPropertyNamesKey]; 127 | } 128 | 129 | + (NSMutableArray *)mj_totalAllowedCodingPropertyNames 130 | { 131 | return [self mj_totalObjectsWithSelector:@selector(mj_allowedCodingPropertyNames) key:&MJAllowedCodingPropertyNamesKey]; 132 | } 133 | #pragma mark - block和方法处理:存储block的返回值 134 | + (void)mj_setupBlockReturnValue:(id (^)())block key:(const char *)key 135 | { 136 | if (block) { 137 | objc_setAssociatedObject(self, key, block(), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 138 | } else { 139 | objc_setAssociatedObject(self, key, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 140 | } 141 | 142 | // 清空数据 143 | [[self dictForKey:key] removeAllObjects]; 144 | } 145 | 146 | + (NSMutableArray *)mj_totalObjectsWithSelector:(SEL)selector key:(const char *)key 147 | { 148 | NSMutableArray *array = [self dictForKey:key][NSStringFromClass(self)]; 149 | if (array) return array; 150 | 151 | // 创建、存储 152 | [self dictForKey:key][NSStringFromClass(self)] = array = [NSMutableArray array]; 153 | 154 | if ([self respondsToSelector:selector]) { 155 | #pragma clang diagnostic push 156 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 157 | NSArray *subArray = [self performSelector:selector]; 158 | #pragma clang diagnostic pop 159 | if (subArray) { 160 | [array addObjectsFromArray:subArray]; 161 | } 162 | } 163 | 164 | [self mj_enumerateAllClasses:^(__unsafe_unretained Class c, BOOL *stop) { 165 | NSArray *subArray = objc_getAssociatedObject(c, key); 166 | [array addObjectsFromArray:subArray]; 167 | }]; 168 | return array; 169 | } 170 | @end 171 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JSONToModel/Pods-JSONToModel-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 12 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 13 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 14 | 15 | case "${TARGETED_DEVICE_FAMILY}" in 16 | 1,2) 17 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 18 | ;; 19 | 1) 20 | TARGET_DEVICE_ARGS="--target-device iphone" 21 | ;; 22 | 2) 23 | TARGET_DEVICE_ARGS="--target-device ipad" 24 | ;; 25 | 3) 26 | TARGET_DEVICE_ARGS="--target-device tv" 27 | ;; 28 | 4) 29 | TARGET_DEVICE_ARGS="--target-device watch" 30 | ;; 31 | *) 32 | TARGET_DEVICE_ARGS="--target-device mac" 33 | ;; 34 | esac 35 | 36 | install_resource() 37 | { 38 | if [[ "$1" = /* ]] ; then 39 | RESOURCE_PATH="$1" 40 | else 41 | RESOURCE_PATH="${PODS_ROOT}/$1" 42 | fi 43 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 44 | cat << EOM 45 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 46 | EOM 47 | exit 1 48 | fi 49 | case $RESOURCE_PATH in 50 | *.storyboard) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.xib) 55 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true 56 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 57 | ;; 58 | *.framework) 59 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 60 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 61 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 62 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 63 | ;; 64 | *.xcdatamodel) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 67 | ;; 68 | *.xcdatamodeld) 69 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true 70 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 71 | ;; 72 | *.xcmappingmodel) 73 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true 74 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 75 | ;; 76 | *.xcassets) 77 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 78 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 79 | ;; 80 | *) 81 | echo "$RESOURCE_PATH" || true 82 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 83 | ;; 84 | esac 85 | } 86 | 87 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 89 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 90 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 91 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 92 | fi 93 | rm -f "$RESOURCES_TO_COPY" 94 | 95 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 96 | then 97 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 98 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 99 | while read line; do 100 | if [[ $line != "${PODS_ROOT}*" ]]; then 101 | XCASSET_FILES+=("$line") 102 | fi 103 | done <<<"$OTHER_XCASSETS" 104 | 105 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 106 | fi 107 | -------------------------------------------------------------------------------- /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 | By default, this property is set to any (`.cer`) certificates included in the target compiling AFNetworking. Note that if you are using AFNetworking as embedded framework, no certificates will be pinned by default. Use `certificatesInBundle` to load certificates from your target, and then create a new policy by calling `policyWithPinningMode:withPinnedCertificates`. 50 | 51 | Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches. 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 | @param pinningMode The SSL pinning mode. 95 | 96 | @return A new security policy. 97 | */ 98 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; 99 | 100 | /** 101 | Creates and returns a security policy with the specified pinning mode. 102 | 103 | @param pinningMode The SSL pinning mode. 104 | @param pinnedCertificates The certificates to pin against. 105 | 106 | @return A new security policy. 107 | */ 108 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates; 109 | 110 | ///------------------------------ 111 | /// @name Evaluating Server Trust 112 | ///------------------------------ 113 | 114 | /** 115 | Whether or not the specified server trust should be accepted, based on the security policy. 116 | 117 | This method should be used when responding to an authentication challenge from a server. 118 | 119 | @param serverTrust The X.509 certificate trust of the server. 120 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated. 121 | 122 | @return Whether or not to trust the server. 123 | */ 124 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust 125 | forDomain:(nullable NSString *)domain; 126 | 127 | @end 128 | 129 | NS_ASSUME_NONNULL_END 130 | 131 | ///---------------- 132 | /// @name Constants 133 | ///---------------- 134 | 135 | /** 136 | ## SSL Pinning Modes 137 | 138 | The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. 139 | 140 | enum { 141 | AFSSLPinningModeNone, 142 | AFSSLPinningModePublicKey, 143 | AFSSLPinningModeCertificate, 144 | } 145 | 146 | `AFSSLPinningModeNone` 147 | Do not used pinned certificates to validate servers. 148 | 149 | `AFSSLPinningModePublicKey` 150 | Validate host certificates against public keys of pinned certificates. 151 | 152 | `AFSSLPinningModeCertificate` 153 | Validate host certificates against pinned certificates. 154 | */ 155 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JSONToModel/Pods-JSONToModel-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | # Used as a return value for each invocation of `strip_invalid_archs` function. 10 | STRIP_BINARY_RETVAL=0 11 | 12 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 13 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 14 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 15 | 16 | # Copies and strips a vendored framework 17 | install_framework() 18 | { 19 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 20 | local source="${BUILT_PRODUCTS_DIR}/$1" 21 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 22 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 23 | elif [ -r "$1" ]; then 24 | local source="$1" 25 | fi 26 | 27 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 28 | 29 | if [ -L "${source}" ]; then 30 | echo "Symlinked..." 31 | source="$(readlink "${source}")" 32 | fi 33 | 34 | # Use filter instead of exclude so missing patterns don't throw errors. 35 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 36 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 37 | 38 | local basename 39 | basename="$(basename -s .framework "$1")" 40 | binary="${destination}/${basename}.framework/${basename}" 41 | if ! [ -r "$binary" ]; then 42 | binary="${destination}/${basename}" 43 | fi 44 | 45 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 46 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 47 | strip_invalid_archs "$binary" 48 | fi 49 | 50 | # Resign the code if required by the build settings to avoid unstable apps 51 | code_sign_if_enabled "${destination}/$(basename "$1")" 52 | 53 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 54 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 55 | local swift_runtime_libs 56 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 57 | for lib in $swift_runtime_libs; do 58 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 59 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 60 | code_sign_if_enabled "${destination}/${lib}" 61 | done 62 | fi 63 | } 64 | 65 | # Copies and strips a vendored dSYM 66 | install_dsym() { 67 | local source="$1" 68 | if [ -r "$source" ]; then 69 | # Copy the dSYM into a the targets temp dir. 70 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" 71 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" 72 | 73 | local basename 74 | basename="$(basename -s .framework.dSYM "$source")" 75 | binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}" 76 | 77 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 78 | if [[ "$(file "$binary")" == *"Mach-O dSYM companion"* ]]; then 79 | strip_invalid_archs "$binary" 80 | fi 81 | 82 | if [[ $STRIP_BINARY_RETVAL == 1 ]]; then 83 | # Move the stripped file into its final destination. 84 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" 85 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}" 86 | else 87 | # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. 88 | touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM" 89 | fi 90 | fi 91 | } 92 | 93 | # Signs a framework with the provided identity 94 | code_sign_if_enabled() { 95 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 96 | # Use the current code_sign_identitiy 97 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 98 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 99 | 100 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 101 | code_sign_cmd="$code_sign_cmd &" 102 | fi 103 | echo "$code_sign_cmd" 104 | eval "$code_sign_cmd" 105 | fi 106 | } 107 | 108 | # Strip invalid architectures 109 | strip_invalid_archs() { 110 | binary="$1" 111 | # Get architectures for current target binary 112 | binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" 113 | # Intersect them with the architectures we are building for 114 | intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" 115 | # If there are no archs supported by this binary then warn the user 116 | if [[ -z "$intersected_archs" ]]; then 117 | echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." 118 | STRIP_BINARY_RETVAL=0 119 | return 120 | fi 121 | stripped="" 122 | for arch in $binary_archs; do 123 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then 124 | # Strip non-valid architectures in-place 125 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 126 | stripped="$stripped $arch" 127 | fi 128 | done 129 | if [[ "$stripped" ]]; then 130 | echo "Stripped $binary of architectures:$stripped" 131 | fi 132 | STRIP_BINARY_RETVAL=1 133 | } 134 | 135 | 136 | if [[ "$CONFIGURATION" == "Debug" ]]; then 137 | install_framework "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework" 138 | install_framework "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework" 139 | fi 140 | if [[ "$CONFIGURATION" == "Release" ]]; then 141 | install_framework "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework" 142 | install_framework "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework" 143 | fi 144 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 145 | wait 146 | fi 147 | -------------------------------------------------------------------------------- /JSONToModel/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // JSONToModel 4 | // 5 | // Created by luo.h on 2018/3/14. 6 | // Copyright © 2018年 hl.com.cn. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "JSONToModel-Swift.h" 11 | 12 | #import "AFNetClient.h" 13 | #import "NSDictionary+JSON.h" 14 | #import "MJExtension.h" 15 | #import 16 | #import "HighlightingTextStorage.h" 17 | 18 | @interface ViewController() 19 | 20 | @property(nonatomic,strong) NSMutableArray *arrayModel; 21 | @property(nonatomic,strong) NSMutableArray *arrayDictModel; 22 | @property(nonatomic,strong) NSDictionary *jsonDict; 23 | @property(nonatomic,copy) NSMutableString* classString; //存类头文件内容 24 | 25 | @end 26 | 27 | @implementation ViewController 28 | 29 | 30 | #define RGB(a,b,c) [NSColor colorWithRed:(a/255.0) green:(b/255.0) blue:(c/255.0) alpha:1.00] 31 | - (void)viewDidLoad { 32 | [super viewDidLoad]; 33 | // Do any additional setup after loading the view. 34 | [self.inputTextView lnv_setUpLineNumberView]; 35 | [self.outPutTextView lnv_setUpLineNumberView]; 36 | 37 | self.inputTextView.font=[NSFont fontWithName:@"Menlo" size:13]; 38 | self.inputTextView.backgroundColor=[NSColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1.00]; 39 | self.outPutTextView.backgroundColor=RGB(40, 43, 53); 40 | self.outPutTextView.font=[NSFont systemFontOfSize:14]; 41 | 42 | self.outPutTextView.automaticDashSubstitutionEnabled = NO; 43 | self.outPutTextView.automaticTextReplacementEnabled = NO; 44 | self.outPutTextView.automaticQuoteSubstitutionEnabled = NO; 45 | self.outPutTextView.enabledTextCheckingTypes = 0; 46 | 47 | [self.outPutTextView setEnabledTextCheckingTypes:NSTextCheckingTypeLink]; 48 | [self.outPutTextView setAutomaticLinkDetectionEnabled:YES]; 49 | 50 | //光标颜色 51 | self.outPutTextView.insertionPointColor=[NSColor whiteColor]; 52 | //Replace text storage 53 | HighlightingTextStorage *textStorage = [[HighlightingTextStorage alloc]init]; 54 | textStorage.defaultTextColor=[NSColor whiteColor]; 55 | [textStorage addLayoutManager:self.outPutTextView.layoutManager]; 56 | 57 | 58 | HighlightingTextStorage *textStorage2 = [[HighlightingTextStorage alloc]init]; 59 | textStorage2.language=@"json"; 60 | [textStorage2 addLayoutManager:self.inputTextView.layoutManager]; 61 | } 62 | 63 | 64 | - (IBAction)autoCodeCreate:(id)sender { 65 | 66 | CFAbsoluteTime startTime =CFAbsoluteTimeGetCurrent(); 67 | NSString *jsonStr = self.inputTextView.textStorage.string; 68 | //json字符串转json字典,可用 69 | NSDictionary *JSONDict = [jsonStr mj_JSONObject]; 70 | self.vildJSONLabel.stringValue = @"已验证"; 71 | if(JSONDict==nil){ 72 | NSLog(@"JSON格式错误,尝试去空格"); 73 | NSString *nonSpaceStr=[NSString removeAllSpace:jsonStr]; 74 | NSLog(@"nonSpaceSt=%@",nonSpaceStr); 75 | JSONDict= [nonSpaceStr mj_JSONObject]; 76 | } 77 | 78 | if(JSONDict==nil){ 79 | self.vildJSONLabel.stringValue = @"JSON格式错误"; 80 | self.vildJSONLabel.textColor=[NSColor redColor]; 81 | return; 82 | } 83 | 84 | self.vildJSONLabel.textColor=[NSColor greenColor]; 85 | [self handleJSON:JSONDict]; 86 | 87 | CFAbsoluteTime executionTime = (CFAbsoluteTimeGetCurrent() - startTime); 88 | NSLog(@"executionTime %f ms", executionTime *1000.0); 89 | } 90 | 91 | 92 | 93 | -(void)handleJSON:(NSDictionary *)dic 94 | { 95 | self.jsonDict=dic; 96 | _classString = [NSMutableString new]; 97 | NSString *fileStr=[self autoCodeWithJsonDict:dic modelKey:nil]; 98 | NSLog(@"%@", fileStr); 99 | 100 | NSMutableString *modelCodeStr=[NSMutableString string]; 101 | [modelCodeStr appendString:fileStr]; 102 | [modelCodeStr appendString:_classString]; 103 | self.outPutTextView.string=modelCodeStr; 104 | 105 | [self.outPutTextView lnv_updateLineNumber]; 106 | } 107 | 108 | 109 | 110 | 111 | 112 | -(NSString *)autoCodeWithJsonDict:(NSDictionary *)dic modelKey:(NSString *)classKey 113 | { 114 | if (classKey.length==0||classKey==nil) { 115 | classKey=@"<#RootModel#>"; 116 | } 117 | if ([dic isKindOfClass:[NSDictionary class]]==NO) { 118 | return @""; 119 | } 120 | NSArray *keyArray = [dic allKeys]; 121 | if (keyArray.count==0) return @""; 122 | 123 | NSString *fileStr=[NSString stringWithFormat:@"@interface %@ : NSObject \r\n\n",classKey]; 124 | for(int i=0;i0) { 189 | NSString *json=[JSONDict toReadableJSONString]; 190 | weakSelf.inputTextView.string=json; 191 | [weakSelf handleJSON:JSONDict]; 192 | } 193 | } failed:^(NSError *error) { 194 | NSLog(@"error=%@",error); 195 | }]; 196 | } 197 | 198 | @end 199 | -------------------------------------------------------------------------------- /JSONToModel/thirdLibs/LineNumberRulerView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LineNumberRulerView.swift 3 | // LineNumber 4 | // 5 | // Copyright (c) 2015 Yichi Zhang. All rights reserved. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a 8 | // copy of this software and associated documentation files (the "Software"), 9 | // to deal in the Software without restriction, including without limitation 10 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | // and/or sell copies of the Software, and to permit persons to whom the 12 | // Software is furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | // DEALINGS IN THE SOFTWARE. 24 | // 25 | 26 | import AppKit 27 | import Foundation 28 | import ObjectiveC 29 | 30 | var LineNumberViewAssocObjKey: UInt8 = 0 31 | 32 | extension NSTextView { 33 | var lineNumberView:LineNumberRulerView { 34 | get { 35 | return objc_getAssociatedObject(self, &LineNumberViewAssocObjKey) as! LineNumberRulerView 36 | } 37 | set { 38 | objc_setAssociatedObject(self, &LineNumberViewAssocObjKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) 39 | } 40 | } 41 | 42 | @objc func lnv_setUpLineNumberView() { 43 | if font == nil { 44 | font = NSFont.systemFont(ofSize: 14) 45 | } 46 | 47 | if let scrollView = enclosingScrollView { 48 | lineNumberView = LineNumberRulerView(textView: self) 49 | 50 | scrollView.verticalRulerView = lineNumberView 51 | scrollView.hasVerticalRuler = true 52 | scrollView.rulersVisible = true 53 | } 54 | 55 | postsFrameChangedNotifications = true 56 | NotificationCenter.default.addObserver(self, selector: #selector(lnv_framDidChange), name: NSView.frameDidChangeNotification, object: self) 57 | 58 | NotificationCenter.default.addObserver(self, selector: #selector(lnv_textDidChange), name: NSText.didChangeNotification, object: self) 59 | } 60 | 61 | @objc func lnv_framDidChange(notification: NSNotification) { 62 | 63 | lineNumberView.needsDisplay = true 64 | } 65 | 66 | @objc func lnv_textDidChange(notification: NSNotification) { 67 | 68 | lineNumberView.needsDisplay = true 69 | } 70 | 71 | @objc func lnv_updateLineNumber() { 72 | lineNumberView.needsDisplay = true 73 | } 74 | } 75 | 76 | class LineNumberRulerView: NSRulerView { 77 | 78 | var font: NSFont! { 79 | didSet { 80 | self.needsDisplay = true 81 | } 82 | } 83 | 84 | init(textView: NSTextView) { 85 | super.init(scrollView: textView.enclosingScrollView!, orientation: NSRulerView.Orientation.verticalRuler) 86 | self.font = textView.font ?? NSFont.systemFont(ofSize: NSFont.smallSystemFontSize) 87 | self.clientView = textView 88 | 89 | self.ruleThickness = 30 //宽度 90 | } 91 | 92 | required init(coder: NSCoder) { 93 | fatalError("init(coder:) has not been implemented") 94 | } 95 | 96 | 97 | override func drawHashMarksAndLabels(in rect: NSRect) { 98 | 99 | if let textView = self.clientView as? NSTextView { 100 | if let layoutManager = textView.layoutManager { 101 | 102 | let relativePoint = self.convert(NSZeroPoint, from: textView) 103 | let lineNumberAttributes = [NSAttributedStringKey.font: textView.font!, NSAttributedStringKey.foregroundColor: NSColor.gray] as [NSAttributedStringKey : Any] 104 | 105 | let drawLineNumber = { (lineNumberString:String, y:CGFloat) -> Void in 106 | let attString = NSAttributedString(string: lineNumberString, attributes: lineNumberAttributes) 107 | let x = 30-5 - attString.size().width 108 | attString.draw(at: NSPoint(x: x, y: relativePoint.y + y)) 109 | } 110 | 111 | let visibleGlyphRange = layoutManager.glyphRange(forBoundingRect: textView.visibleRect, in: textView.textContainer!) 112 | let firstVisibleGlyphCharacterIndex = layoutManager.characterIndexForGlyph(at: visibleGlyphRange.location) 113 | 114 | let newLineRegex = try! NSRegularExpression(pattern: "\n", options: []) 115 | // The line number for the first visible line 116 | var lineNumber = newLineRegex.numberOfMatches(in: textView.string, options: [], range: NSMakeRange(0, firstVisibleGlyphCharacterIndex)) + 1 117 | 118 | var glyphIndexForStringLine = visibleGlyphRange.location 119 | 120 | // Go through each line in the string. 121 | while glyphIndexForStringLine < NSMaxRange(visibleGlyphRange) { 122 | 123 | // Range of current line in the string. 124 | let characterRangeForStringLine = (textView.string as NSString).lineRange( 125 | for: NSMakeRange( layoutManager.characterIndexForGlyph(at: glyphIndexForStringLine), 0 ) 126 | ) 127 | let glyphRangeForStringLine = layoutManager.glyphRange(forCharacterRange: characterRangeForStringLine, actualCharacterRange: nil) 128 | 129 | var glyphIndexForGlyphLine = glyphIndexForStringLine 130 | var glyphLineCount = 0 131 | 132 | while ( glyphIndexForGlyphLine < NSMaxRange(glyphRangeForStringLine) ) { 133 | 134 | // See if the current line in the string spread across 135 | // several lines of glyphs 136 | var effectiveRange = NSMakeRange(0, 0) 137 | 138 | // Range of current "line of glyphs". If a line is wrapped, 139 | // then it will have more than one "line of glyphs" 140 | let lineRect = layoutManager.lineFragmentRect(forGlyphAt: glyphIndexForGlyphLine, effectiveRange: &effectiveRange, withoutAdditionalLayout: true) 141 | 142 | if glyphLineCount > 0 { 143 | drawLineNumber("-", lineRect.minY) 144 | } else { 145 | drawLineNumber("\(lineNumber)", lineRect.minY) 146 | } 147 | 148 | // Move to next glyph line 149 | glyphLineCount += 1 150 | glyphIndexForGlyphLine = NSMaxRange(effectiveRange) 151 | } 152 | 153 | glyphIndexForStringLine = NSMaxRange(glyphRangeForStringLine) 154 | lineNumber += 1 155 | } 156 | 157 | // Draw line number for the extra line at the end of the text 158 | if layoutManager.extraLineFragmentTextContainer != nil { 159 | drawLineNumber("\(lineNumber)", layoutManager.extraLineFragmentRect.minY) 160 | } 161 | } 162 | } 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkReachabilityManager.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #if !TARGET_OS_WATCH 25 | #import 26 | 27 | typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) { 28 | AFNetworkReachabilityStatusUnknown = -1, 29 | AFNetworkReachabilityStatusNotReachable = 0, 30 | AFNetworkReachabilityStatusReachableViaWWAN = 1, 31 | AFNetworkReachabilityStatusReachableViaWiFi = 2, 32 | }; 33 | 34 | NS_ASSUME_NONNULL_BEGIN 35 | 36 | /** 37 | `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. 38 | 39 | Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability. 40 | 41 | See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ ) 42 | 43 | @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. 44 | */ 45 | @interface AFNetworkReachabilityManager : NSObject 46 | 47 | /** 48 | The current network reachability status. 49 | */ 50 | @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; 51 | 52 | /** 53 | Whether or not the network is currently reachable. 54 | */ 55 | @property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable; 56 | 57 | /** 58 | Whether or not the network is currently reachable via WWAN. 59 | */ 60 | @property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN; 61 | 62 | /** 63 | Whether or not the network is currently reachable via WiFi. 64 | */ 65 | @property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi; 66 | 67 | ///--------------------- 68 | /// @name Initialization 69 | ///--------------------- 70 | 71 | /** 72 | Returns the shared network reachability manager. 73 | */ 74 | + (instancetype)sharedManager; 75 | 76 | /** 77 | Creates and returns a network reachability manager with the default socket address. 78 | 79 | @return An initialized network reachability manager, actively monitoring the default socket address. 80 | */ 81 | + (instancetype)manager; 82 | 83 | /** 84 | Creates and returns a network reachability manager for the specified domain. 85 | 86 | @param domain The domain used to evaluate network reachability. 87 | 88 | @return An initialized network reachability manager, actively monitoring the specified domain. 89 | */ 90 | + (instancetype)managerForDomain:(NSString *)domain; 91 | 92 | /** 93 | Creates and returns a network reachability manager for the socket address. 94 | 95 | @param address The socket address (`sockaddr_in6`) used to evaluate network reachability. 96 | 97 | @return An initialized network reachability manager, actively monitoring the specified socket address. 98 | */ 99 | + (instancetype)managerForAddress:(const void *)address; 100 | 101 | /** 102 | Initializes an instance of a network reachability manager from the specified reachability object. 103 | 104 | @param reachability The reachability object to monitor. 105 | 106 | @return An initialized network reachability manager, actively monitoring the specified reachability. 107 | */ 108 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER; 109 | 110 | ///-------------------------------------------------- 111 | /// @name Starting & Stopping Reachability Monitoring 112 | ///-------------------------------------------------- 113 | 114 | /** 115 | Starts monitoring for changes in network reachability status. 116 | */ 117 | - (void)startMonitoring; 118 | 119 | /** 120 | Stops monitoring for changes in network reachability status. 121 | */ 122 | - (void)stopMonitoring; 123 | 124 | ///------------------------------------------------- 125 | /// @name Getting Localized Reachability Description 126 | ///------------------------------------------------- 127 | 128 | /** 129 | Returns a localized string representation of the current network reachability status. 130 | */ 131 | - (NSString *)localizedNetworkReachabilityStatusString; 132 | 133 | ///--------------------------------------------------- 134 | /// @name Setting Network Reachability Change Callback 135 | ///--------------------------------------------------- 136 | 137 | /** 138 | Sets a callback to be executed when the network availability of the `baseURL` host changes. 139 | 140 | @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`. 141 | */ 142 | - (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block; 143 | 144 | @end 145 | 146 | ///---------------- 147 | /// @name Constants 148 | ///---------------- 149 | 150 | /** 151 | ## Network Reachability 152 | 153 | The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses. 154 | 155 | enum { 156 | AFNetworkReachabilityStatusUnknown, 157 | AFNetworkReachabilityStatusNotReachable, 158 | AFNetworkReachabilityStatusReachableViaWWAN, 159 | AFNetworkReachabilityStatusReachableViaWiFi, 160 | } 161 | 162 | `AFNetworkReachabilityStatusUnknown` 163 | The `baseURL` host reachability is not known. 164 | 165 | `AFNetworkReachabilityStatusNotReachable` 166 | The `baseURL` host cannot be reached. 167 | 168 | `AFNetworkReachabilityStatusReachableViaWWAN` 169 | The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. 170 | 171 | `AFNetworkReachabilityStatusReachableViaWiFi` 172 | The `baseURL` host can be reached via a Wi-Fi connection. 173 | 174 | ### Keys for Notification UserInfo Dictionary 175 | 176 | Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. 177 | 178 | `AFNetworkingReachabilityNotificationStatusItem` 179 | A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. 180 | The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. 181 | */ 182 | 183 | ///-------------------- 184 | /// @name Notifications 185 | ///-------------------- 186 | 187 | /** 188 | Posted when network reachability changes. 189 | This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability. 190 | 191 | @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). 192 | */ 193 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification; 194 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem; 195 | 196 | ///-------------------- 197 | /// @name Functions 198 | ///-------------------- 199 | 200 | /** 201 | Returns a localized string representation of an `AFNetworkReachabilityStatus` value. 202 | */ 203 | FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status); 204 | 205 | NS_ASSUME_NONNULL_END 206 | #endif 207 | -------------------------------------------------------------------------------- /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 | * 53 | * @param oldValue 旧值 54 | * 55 | * @return 新值 56 | */ 57 | - (id)mj_newValueFromOldValue:(id)oldValue property:(MJProperty *)property; 58 | 59 | /** 60 | * 当字典转模型完毕时调用 61 | */ 62 | - (void)mj_keyValuesDidFinishConvertingToObject; 63 | 64 | /** 65 | * 当模型转字典完毕时调用 66 | */ 67 | - (void)mj_objectDidFinishConvertingToKeyValues; 68 | @end 69 | 70 | @interface NSObject (MJKeyValue) 71 | #pragma mark - 类方法 72 | /** 73 | * 字典转模型过程中遇到的错误 74 | */ 75 | + (NSError *)mj_error; 76 | 77 | /** 78 | * 模型转字典时,字典的key是否参考replacedKeyFromPropertyName等方法(父类设置了,子类也会继承下来) 79 | */ 80 | + (void)mj_referenceReplacedKeyWhenCreatingKeyValues:(BOOL)reference; 81 | 82 | #pragma mark - 对象方法 83 | /** 84 | * 将字典的键值对转成模型属性 85 | * @param keyValues 字典(可以是NSDictionary、NSData、NSString) 86 | */ 87 | - (instancetype)mj_setKeyValues:(id)keyValues; 88 | 89 | /** 90 | * 将字典的键值对转成模型属性 91 | * @param keyValues 字典(可以是NSDictionary、NSData、NSString) 92 | * @param context CoreData上下文 93 | */ 94 | - (instancetype)mj_setKeyValues:(id)keyValues context:(NSManagedObjectContext *)context; 95 | 96 | /** 97 | * 将模型转成字典 98 | * @return 字典 99 | */ 100 | - (NSMutableDictionary *)mj_keyValues; 101 | - (NSMutableDictionary *)mj_keyValuesWithKeys:(NSArray *)keys; 102 | - (NSMutableDictionary *)mj_keyValuesWithIgnoredKeys:(NSArray *)ignoredKeys; 103 | 104 | /** 105 | * 通过模型数组来创建一个字典数组 106 | * @param objectArray 模型数组 107 | * @return 字典数组 108 | */ 109 | + (NSMutableArray *)mj_keyValuesArrayWithObjectArray:(NSArray *)objectArray; 110 | + (NSMutableArray *)mj_keyValuesArrayWithObjectArray:(NSArray *)objectArray keys:(NSArray *)keys; 111 | + (NSMutableArray *)mj_keyValuesArrayWithObjectArray:(NSArray *)objectArray ignoredKeys:(NSArray *)ignoredKeys; 112 | 113 | #pragma mark - 字典转模型 114 | /** 115 | * 通过字典来创建一个模型 116 | * @param keyValues 字典(可以是NSDictionary、NSData、NSString) 117 | * @return 新建的对象 118 | */ 119 | + (instancetype)mj_objectWithKeyValues:(id)keyValues; 120 | 121 | /** 122 | * 通过字典来创建一个CoreData模型 123 | * @param keyValues 字典(可以是NSDictionary、NSData、NSString) 124 | * @param context CoreData上下文 125 | * @return 新建的对象 126 | */ 127 | + (instancetype)mj_objectWithKeyValues:(id)keyValues context:(NSManagedObjectContext *)context; 128 | 129 | /** 130 | * 通过plist来创建一个模型 131 | * @param filename 文件名(仅限于mainBundle中的文件) 132 | * @return 新建的对象 133 | */ 134 | + (instancetype)mj_objectWithFilename:(NSString *)filename; 135 | 136 | /** 137 | * 通过plist来创建一个模型 138 | * @param file 文件全路径 139 | * @return 新建的对象 140 | */ 141 | + (instancetype)mj_objectWithFile:(NSString *)file; 142 | 143 | #pragma mark - 字典数组转模型数组 144 | /** 145 | * 通过字典数组来创建一个模型数组 146 | * @param keyValuesArray 字典数组(可以是NSDictionary、NSData、NSString) 147 | * @return 模型数组 148 | */ 149 | + (NSMutableArray *)mj_objectArrayWithKeyValuesArray:(id)keyValuesArray; 150 | 151 | /** 152 | * 通过字典数组来创建一个模型数组 153 | * @param keyValuesArray 字典数组(可以是NSDictionary、NSData、NSString) 154 | * @param context CoreData上下文 155 | * @return 模型数组 156 | */ 157 | + (NSMutableArray *)mj_objectArrayWithKeyValuesArray:(id)keyValuesArray context:(NSManagedObjectContext *)context; 158 | 159 | /** 160 | * 通过plist来创建一个模型数组 161 | * @param filename 文件名(仅限于mainBundle中的文件) 162 | * @return 模型数组 163 | */ 164 | + (NSMutableArray *)mj_objectArrayWithFilename:(NSString *)filename; 165 | 166 | /** 167 | * 通过plist来创建一个模型数组 168 | * @param file 文件全路径 169 | * @return 模型数组 170 | */ 171 | + (NSMutableArray *)mj_objectArrayWithFile:(NSString *)file; 172 | 173 | #pragma mark - 转换为JSON 174 | /** 175 | * 转换为JSON Data 176 | */ 177 | - (NSData *)mj_JSONData; 178 | /** 179 | * 转换为字典或者数组 180 | */ 181 | - (id)mj_JSONObject; 182 | /** 183 | * 转换为JSON 字符串 184 | */ 185 | - (NSString *)mj_JSONString; 186 | @end 187 | 188 | @interface NSObject (MJKeyValueDeprecated_v_2_5_16) 189 | - (instancetype)setKeyValues:(id)keyValue MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 190 | - (instancetype)setKeyValues:(id)keyValues error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 191 | - (instancetype)setKeyValues:(id)keyValues context:(NSManagedObjectContext *)context MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 192 | - (instancetype)setKeyValues:(id)keyValues context:(NSManagedObjectContext *)context error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 193 | + (void)referenceReplacedKeyWhenCreatingKeyValues:(BOOL)reference MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 194 | - (NSMutableDictionary *)keyValues MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 195 | - (NSMutableDictionary *)keyValuesWithError:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 196 | - (NSMutableDictionary *)keyValuesWithKeys:(NSArray *)keys MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 197 | - (NSMutableDictionary *)keyValuesWithKeys:(NSArray *)keys error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 198 | - (NSMutableDictionary *)keyValuesWithIgnoredKeys:(NSArray *)ignoredKeys MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 199 | - (NSMutableDictionary *)keyValuesWithIgnoredKeys:(NSArray *)ignoredKeys error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 200 | + (NSMutableArray *)keyValuesArrayWithObjectArray:(NSArray *)objectArray MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 201 | + (NSMutableArray *)keyValuesArrayWithObjectArray:(NSArray *)objectArray error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 202 | + (NSMutableArray *)keyValuesArrayWithObjectArray:(NSArray *)objectArray keys:(NSArray *)keys MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 203 | + (NSMutableArray *)keyValuesArrayWithObjectArray:(NSArray *)objectArray keys:(NSArray *)keys error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 204 | + (NSMutableArray *)keyValuesArrayWithObjectArray:(NSArray *)objectArray ignoredKeys:(NSArray *)ignoredKeys MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 205 | + (NSMutableArray *)keyValuesArrayWithObjectArray:(NSArray *)objectArray ignoredKeys:(NSArray *)ignoredKeys error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 206 | + (instancetype)objectWithKeyValues:(id)keyValues MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 207 | + (instancetype)objectWithKeyValues:(id)keyValues error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 208 | + (instancetype)objectWithKeyValues:(id)keyValues context:(NSManagedObjectContext *)context MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 209 | + (instancetype)objectWithKeyValues:(id)keyValues context:(NSManagedObjectContext *)context error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 210 | + (instancetype)objectWithFilename:(NSString *)filename MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 211 | + (instancetype)objectWithFilename:(NSString *)filename error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 212 | + (instancetype)objectWithFile:(NSString *)file MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 213 | + (instancetype)objectWithFile:(NSString *)file error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 214 | + (NSMutableArray *)objectArrayWithKeyValuesArray:(id)keyValuesArray MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 215 | + (NSMutableArray *)objectArrayWithKeyValuesArray:(id)keyValuesArray error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 216 | + (NSMutableArray *)objectArrayWithKeyValuesArray:(id)keyValuesArray context:(NSManagedObjectContext *)context MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 217 | + (NSMutableArray *)objectArrayWithKeyValuesArray:(id)keyValuesArray context:(NSManagedObjectContext *)context error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 218 | + (NSMutableArray *)objectArrayWithFilename:(NSString *)filename MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 219 | + (NSMutableArray *)objectArrayWithFilename:(NSString *)filename error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 220 | + (NSMutableArray *)objectArrayWithFile:(NSString *)file MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 221 | + (NSMutableArray *)objectArrayWithFile:(NSString *)file error:(NSError **)error MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 222 | - (NSData *)JSONData MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 223 | - (id)JSONObject MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 224 | - (NSString *)JSONString MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***"); 225 | @end 226 | -------------------------------------------------------------------------------- /JSONToModel/HighlightingTextStorage.m: -------------------------------------------------------------------------------- 1 | // 2 | // PCHighlightingTextStorage.m 3 | // JSON_Model 4 | // 5 | // Created by luo.h on 2018/3/14. 6 | // Copyright © 2018年 meet.com.cn. All rights reserved. 7 | // 8 | 9 | #import "HighlightingTextStorage.h" 10 | #import 11 | #import "NSDictionary+JSON.h" 12 | #import "NSColor+HexColor.h" 13 | 14 | @interface HighlightingTextStorage() 15 | 16 | @property(nonatomic,strong) JSContext *context; 17 | 18 | @end 19 | 20 | @implementation HighlightingTextStorage 21 | { 22 | NSMutableAttributedString *_imp; 23 | NSDictionary *_replacements; 24 | NSDictionary *_CSSDict; 25 | 26 | } 27 | 28 | // 设置高亮正则表达式 29 | static NSString *const kUserPattern = @"\\@\\w+"; // "@用户名 @interface" 30 | static NSString *const kNSClassPattern = @"\\b((NS|UI|CG)\\w+?)"; // "NSxxx" 31 | static NSString *const kTopicPattern = @"\\#\\w+\\#"; // "#话题#" 32 | static NSString *const kEmotionPattern = @"\\[\\w+\\]"; // "[]"表情 33 | #define REGEX_STRING @"\".*?\"" //字符串 34 | #define REGEX_KEY @"\".*?\" :" //键值对中的key 35 | #define REGEX_VALUE @"(?<=: )\".*?\"" //键值对中的value 36 | #define REGEX_BRACES @"\\{|\\}" //大括号 37 | #define REGEX_BRACKETS @"\\[|\\]" //中括号 38 | #define REGEX_NUM @"\\d+" //键值对中的value 39 | #define REGEX_URL @"(((ht|f)tp(s?))\\://)?(www.|[a-zA-Z].)[a-zA-Z0-9\\-\\.]+\\.(com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk)(\\:[0-9]+)*(/($|[a-zA-Z0-9\\.\\,\\;\\?\\'\\\\\\+&%\\$#\\=~_\\-]+))*"; // URL 过滤 40 | #define RGB(a,b,c) [NSColor colorWithRed:(a/255.0) green:(b/255.0) blue:(c/255.0) alpha:1.00] 41 | 42 | - (instancetype)init 43 | { 44 | self = [super init]; 45 | if (self) { 46 | _imp = [[NSMutableAttributedString alloc] init]; 47 | [self configHighlightPatterns]; 48 | [self setUpContext]; 49 | _CSSDict=kThemeInfo(); 50 | } 51 | return self; 52 | } 53 | 54 | #pragma mark - Reading Text 55 | - (NSString *)string 56 | { 57 | return _imp.string; 58 | } 59 | 60 | - (NSDictionary *)attributesAtIndex:(NSUInteger)location effectiveRange:(NSRangePointer)range 61 | { 62 | return [_imp attributesAtIndex:location effectiveRange:range]; 63 | } 64 | 65 | #pragma mark - Text Editing 66 | - (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str 67 | { 68 | if (str) { 69 | [self beginEditing]; 70 | [_imp replaceCharactersInRange:range withString:str]; 71 | [self edited:NSTextStorageEditedCharacters range:range changeInLength:(NSInteger)str.length - (NSInteger)range.length]; 72 | [self endEditing]; 73 | } 74 | } 75 | 76 | - (void)setAttributes:(NSDictionary *)attrs range:(NSRange)range 77 | { 78 | [self beginEditing]; 79 | [_imp setAttributes:attrs range:range]; 80 | [self edited:NSTextStorageEditedAttributes range:range changeInLength:0]; 81 | [self endEditing]; 82 | } 83 | 84 | 85 | - (void)fixAttributesInRange:(NSRange)range { 86 | [self performReplacementsForRange:range]; 87 | [super fixAttributesInRange:(NSRange)range]; 88 | } 89 | 90 | #pragma mark - Syntax highlighting 91 | - (void)performReplacementsForRange:(NSRange)changedRange { 92 | //默认是黑色--这里设置白色-Menlo字体 93 | NSLog(@"foregroundColor=%@",self.foregroundColor); 94 | if (self.defaultTextColor) { 95 | NSDictionary *atts=@{NSFontAttributeName :[NSFont fontWithName:@"Menlo" size:14],NSForegroundColorAttributeName:self.defaultTextColor}; 96 | [self addAttributes:atts range:changedRange]; 97 | } 98 | 99 | 100 | NSString *language=[self.language lowercaseString]; 101 | NSRange paragaphRange = [self.string paragraphRangeForRange:self.editedRange]; 102 | __weak typeof(self)weakSelf = self; 103 | if ([language isEqualToString:@"objectivec"]) { 104 | for (NSString* key in _replacements) { 105 | NSDictionary* attributes = _replacements[key]; 106 | [RegexWithPattern(key) enumerateMatchesInString:self.string options:0 range:paragaphRange usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) { 107 | [weakSelf addAttributes:attributes range:result.range]; 108 | }]; 109 | } 110 | }else if ([language isEqualToString:@"json"]){ 111 | //数字高亮 112 | [RegexWithPattern(REGEX_NUM) enumerateMatchesInString:self.string options:0 range:paragaphRange usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) { 113 | // Add red highlight color 114 | [weakSelf addAttribute:NSForegroundColorAttributeName value:RGB(194, 53, 154) range:result.range]; 115 | }]; 116 | 117 | //value高亮 118 | [RegexWithPattern(REGEX_VALUE) enumerateMatchesInString:self.string options:0 range:paragaphRange usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) { 119 | // Add red highlight color 120 | [weakSelf addAttribute:NSForegroundColorAttributeName value:RGB(221,18,67) range:result.range]; 121 | }]; 122 | }else{ 123 | [self highligtCodeForRange:paragaphRange]; 124 | } 125 | } 126 | 127 | - (void)configHighlightPatterns{ 128 | //属性 @name 129 | NSString *keyWordsRegex = [NSString stringWithFormat:@"%@|nonatomic|strong|copy|assign",kUserPattern]; 130 | //NSString、NSArray、NSDictionary...NS 131 | NSString *regex_NS = [NSString stringWithFormat:@"%@",kNSClassPattern]; 132 | _replacements = @{ 133 | keyWordsRegex :AttributesWithColor(RGB(194, 53, 154)), 134 | regex_NS : AttributesWithColor(RGB(0,175,202)) 135 | }; 136 | } 137 | 138 | 139 | #pragma mark--使用JavaScript库渲染 140 | - (void)highligtCodeForRange:(NSRange)paragaphRange 141 | { 142 | NSString *content=[self.string substringWithRange:paragaphRange]; 143 | // #Fix JS Exception: SyntaxError: Unexpected EOF 144 | // NSString *command= [NSString stringWithFormat:@"window.hljs.highlightAuto(\"%@\").value;",escapeContent(content)]; 145 | NSString *command = [NSString stringWithFormat:@"window.hljs.highlight(\"%@\",\"%@\").value;",@"objectivec",escapeContent(content)]; 146 | NSString *highlightString = [[self.context evaluateScript:command] toString]; 147 | NSLog(@"highlight:%@",highlightString); 148 | [self renderContent:highlightString withRange:paragaphRange]; 149 | } 150 | 151 | 152 | 153 | 154 | static NSDictionary * kThemeInfo() { 155 | static NSDictionary *_themeInfo = nil; 156 | static dispatch_once_t onceToken; 157 | dispatch_once(&onceToken, ^{ 158 | NSError *error; 159 | // 获取文件路径 160 | NSString *filePath = [[NSBundle mainBundle] pathForResource:@"xcodetheme" ofType:@"json"]; 161 | // 根据文件路径读取数据 162 | NSData *jdata = [[NSData alloc] initWithContentsOfFile:filePath]; 163 | // 格式化成json数据 164 | NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:jdata options:kNilOptions error:&error]; 165 | NSLog(@"jsonObject=%@",jsonObject); 166 | _themeInfo=jsonObject; 167 | }); 168 | return _themeInfo; 169 | } 170 | 171 | 172 | 173 | -(void)setUpContext 174 | { 175 | JSContext *context=[[JSContext alloc]init]; 176 | [context evaluateScript:@"var window = {};"]; 177 | context.exceptionHandler = ^(JSContext *context, JSValue *exception) { 178 | NSLog(@"# JS Exception: %@", exception); 179 | context.exception = exception; 180 | }; 181 | self.context=context; 182 | NSString *path = [[NSBundle mainBundle] pathForResource:@"highlight.min" ofType:@"js"]; 183 | NSString *js = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; 184 | JSValue *value= [self.context evaluateScript:js]; 185 | if ([value toBool]==NO) { 186 | NSLog(@"初始化失败"); 187 | }else{ 188 | NSLog(@"初始化成功"); 189 | } 190 | } 191 | 192 | 193 | -(void)renderContent:(NSString *)content withRange:(NSRange)paragaphRange 194 | { 195 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(.*?)<\\/span>" options:NSRegularExpressionCaseInsensitive error:nil]; 196 | if (content.length>0) { 197 | //匹配第一个 198 | NSArray *results = [regex matchesInString:content options:NSMatchingReportProgress range:NSMakeRange(0, [content length])]; 199 | for (NSTextCheckingResult *result in results) { 200 | NSString *className= [content substringWithRange:[result rangeAtIndex:1]]; 201 | NSRange wordRange=[result rangeAtIndex:2]; 202 | NSString *word= [content substringWithRange:wordRange]; 203 | NSDictionary *attributs=[NSDictionary dictionary]; 204 | NSString *subKey = findKey(className, _CSSDict); 205 | NSDictionary *atts=_CSSDict[subKey]; 206 | NSString *color_hex=atts[@"color"]; 207 | if (color_hex.length>0) { 208 | // NSLog(@"高亮:%@=%@=%@-%@",word,className,subKey,color_hex); 209 | attributs=AttributesWithColor([NSColor colorFromHexCode:color_hex]); 210 | } 211 | [RegexWithPattern(word) enumerateMatchesInString:self.string options:0 range:paragaphRange usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) { 212 | //高亮关键词 213 | [self addAttributes:attributs range:result.range]; 214 | }]; 215 | } 216 | } 217 | } 218 | 219 | 220 | #pragma mark---内联函数-- 221 | static inline NSString *escapeContent(NSString *content) { 222 | NSString *html =content; 223 | html = [html stringByReplacingOccurrencesOfString:@"\'" withString:@"\\\'"]; 224 | html = [html stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]; 225 | html = [html stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"]; 226 | html = [html stringByReplacingOccurrencesOfString:@"\r" withString:@""]; 227 | return html; 228 | } 229 | 230 | static inline NSDictionary *AttributesWithColor(NSColor *color) { 231 | return @{NSFontAttributeName :[NSFont fontWithName:@"Menlo" size:14],NSForegroundColorAttributeName:color}; 232 | } 233 | 234 | static inline NSRegularExpression *RegexWithPattern(NSString *pattern) { 235 | return [NSRegularExpression regularExpressionWithPattern:pattern options:NSRegularExpressionCaseInsensitive error:nil]; 236 | } 237 | 238 | static inline NSString *findKey(NSString *subKey,NSDictionary *dict) { 239 | NSArray *keys = [dict allKeys]; 240 | for(NSString *key in keys){ 241 | if([key containsString:subKey]){ 242 | return key; 243 | } 244 | } 245 | return nil; 246 | } 247 | 248 | @end 249 | -------------------------------------------------------------------------------- /Pods/MJExtension/MJExtension/NSObject+MJProperty.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+MJProperty.m 3 | // MJExtensionExample 4 | // 5 | // Created by MJ Lee on 15/4/17. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "NSObject+MJProperty.h" 10 | #import "NSObject+MJKeyValue.h" 11 | #import "NSObject+MJCoding.h" 12 | #import "NSObject+MJClass.h" 13 | #import "MJProperty.h" 14 | #import "MJFoundation.h" 15 | #import 16 | 17 | #pragma clang diagnostic push 18 | #pragma clang diagnostic ignored "-Wundeclared-selector" 19 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 20 | 21 | static const char MJReplacedKeyFromPropertyNameKey = '\0'; 22 | static const char MJReplacedKeyFromPropertyName121Key = '\0'; 23 | static const char MJNewValueFromOldValueKey = '\0'; 24 | static const char MJObjectClassInArrayKey = '\0'; 25 | 26 | static const char MJCachedPropertiesKey = '\0'; 27 | 28 | @implementation NSObject (Property) 29 | 30 | static NSMutableDictionary *replacedKeyFromPropertyNameDict_; 31 | static NSMutableDictionary *replacedKeyFromPropertyName121Dict_; 32 | static NSMutableDictionary *newValueFromOldValueDict_; 33 | static NSMutableDictionary *objectClassInArrayDict_; 34 | static NSMutableDictionary *cachedPropertiesDict_; 35 | 36 | + (void)load 37 | { 38 | replacedKeyFromPropertyNameDict_ = [NSMutableDictionary dictionary]; 39 | replacedKeyFromPropertyName121Dict_ = [NSMutableDictionary dictionary]; 40 | newValueFromOldValueDict_ = [NSMutableDictionary dictionary]; 41 | objectClassInArrayDict_ = [NSMutableDictionary dictionary]; 42 | cachedPropertiesDict_ = [NSMutableDictionary dictionary]; 43 | } 44 | 45 | + (NSMutableDictionary *)dictForKey:(const void *)key 46 | { 47 | @synchronized (self) { 48 | if (key == &MJReplacedKeyFromPropertyNameKey) return replacedKeyFromPropertyNameDict_; 49 | if (key == &MJReplacedKeyFromPropertyName121Key) return replacedKeyFromPropertyName121Dict_; 50 | if (key == &MJNewValueFromOldValueKey) return newValueFromOldValueDict_; 51 | if (key == &MJObjectClassInArrayKey) return objectClassInArrayDict_; 52 | if (key == &MJCachedPropertiesKey) return cachedPropertiesDict_; 53 | return nil; 54 | } 55 | } 56 | 57 | #pragma mark - --私有方法-- 58 | + (id)propertyKey:(NSString *)propertyName 59 | { 60 | MJExtensionAssertParamNotNil2(propertyName, nil); 61 | 62 | __block id key = nil; 63 | // 查看有没有需要替换的key 64 | if ([self respondsToSelector:@selector(mj_replacedKeyFromPropertyName121:)]) { 65 | key = [self mj_replacedKeyFromPropertyName121:propertyName]; 66 | } 67 | // 兼容旧版本 68 | if ([self respondsToSelector:@selector(replacedKeyFromPropertyName121:)]) { 69 | key = [self performSelector:@selector(replacedKeyFromPropertyName121) withObject:propertyName]; 70 | } 71 | 72 | // 调用block 73 | if (!key) { 74 | [self mj_enumerateAllClasses:^(__unsafe_unretained Class c, BOOL *stop) { 75 | MJReplacedKeyFromPropertyName121 block = objc_getAssociatedObject(c, &MJReplacedKeyFromPropertyName121Key); 76 | if (block) { 77 | key = block(propertyName); 78 | } 79 | if (key) *stop = YES; 80 | }]; 81 | } 82 | 83 | // 查看有没有需要替换的key 84 | if ((!key || [key isEqual:propertyName]) && [self respondsToSelector:@selector(mj_replacedKeyFromPropertyName)]) { 85 | key = [self mj_replacedKeyFromPropertyName][propertyName]; 86 | } 87 | // 兼容旧版本 88 | if ((!key || [key isEqual:propertyName]) && [self respondsToSelector:@selector(replacedKeyFromPropertyName)]) { 89 | key = [self performSelector:@selector(replacedKeyFromPropertyName)][propertyName]; 90 | } 91 | 92 | if (!key || [key isEqual:propertyName]) { 93 | [self mj_enumerateAllClasses:^(__unsafe_unretained Class c, BOOL *stop) { 94 | NSDictionary *dict = objc_getAssociatedObject(c, &MJReplacedKeyFromPropertyNameKey); 95 | if (dict) { 96 | key = dict[propertyName]; 97 | } 98 | if (key && ![key isEqual:propertyName]) *stop = YES; 99 | }]; 100 | } 101 | 102 | // 2.用属性名作为key 103 | if (!key) key = propertyName; 104 | 105 | return key; 106 | } 107 | 108 | + (Class)propertyObjectClassInArray:(NSString *)propertyName 109 | { 110 | __block id clazz = nil; 111 | if ([self respondsToSelector:@selector(mj_objectClassInArray)]) { 112 | clazz = [self mj_objectClassInArray][propertyName]; 113 | } 114 | // 兼容旧版本 115 | if ([self respondsToSelector:@selector(objectClassInArray)]) { 116 | clazz = [self performSelector:@selector(objectClassInArray)][propertyName]; 117 | } 118 | 119 | if (!clazz) { 120 | [self mj_enumerateAllClasses:^(__unsafe_unretained Class c, BOOL *stop) { 121 | NSDictionary *dict = objc_getAssociatedObject(c, &MJObjectClassInArrayKey); 122 | if (dict) { 123 | clazz = dict[propertyName]; 124 | } 125 | if (clazz) *stop = YES; 126 | }]; 127 | } 128 | 129 | // 如果是NSString类型 130 | if ([clazz isKindOfClass:[NSString class]]) { 131 | clazz = NSClassFromString(clazz); 132 | } 133 | return clazz; 134 | } 135 | 136 | #pragma mark - --公共方法-- 137 | + (void)mj_enumerateProperties:(MJPropertiesEnumeration)enumeration 138 | { 139 | // 获得成员变量 140 | NSArray *cachedProperties = [self properties]; 141 | 142 | // 遍历成员变量 143 | BOOL stop = NO; 144 | for (MJProperty *property in cachedProperties) { 145 | enumeration(property, &stop); 146 | if (stop) break; 147 | } 148 | } 149 | 150 | #pragma mark - 公共方法 151 | + (NSMutableArray *)properties 152 | { 153 | NSMutableArray *cachedProperties = [self dictForKey:&MJCachedPropertiesKey][NSStringFromClass(self)]; 154 | 155 | if (cachedProperties == nil) { 156 | cachedProperties = [NSMutableArray array]; 157 | 158 | [self mj_enumerateClasses:^(__unsafe_unretained Class c, BOOL *stop) { 159 | // 1.获得所有的成员变量 160 | unsigned int outCount = 0; 161 | objc_property_t *properties = class_copyPropertyList(c, &outCount); 162 | 163 | // 2.遍历每一个成员变量 164 | for (unsigned int i = 0; i 26 | #import 27 | #import 28 | #import 29 | #import 30 | 31 | NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; 32 | NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; 33 | 34 | typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); 35 | 36 | NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) { 37 | switch (status) { 38 | case AFNetworkReachabilityStatusNotReachable: 39 | return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil); 40 | case AFNetworkReachabilityStatusReachableViaWWAN: 41 | return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil); 42 | case AFNetworkReachabilityStatusReachableViaWiFi: 43 | return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil); 44 | case AFNetworkReachabilityStatusUnknown: 45 | default: 46 | return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil); 47 | } 48 | } 49 | 50 | static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { 51 | BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); 52 | BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); 53 | BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); 54 | BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0); 55 | BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction)); 56 | 57 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; 58 | if (isNetworkReachable == NO) { 59 | status = AFNetworkReachabilityStatusNotReachable; 60 | } 61 | #if TARGET_OS_IPHONE 62 | else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { 63 | status = AFNetworkReachabilityStatusReachableViaWWAN; 64 | } 65 | #endif 66 | else { 67 | status = AFNetworkReachabilityStatusReachableViaWiFi; 68 | } 69 | 70 | return status; 71 | } 72 | 73 | /** 74 | * Queue a status change notification for the main thread. 75 | * 76 | * This is done to ensure that the notifications are received in the same order 77 | * as they are sent. If notifications are sent directly, it is possible that 78 | * a queued notification (for an earlier status condition) is processed after 79 | * the later update, resulting in the listener being left in the wrong state. 80 | */ 81 | static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusBlock block) { 82 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); 83 | dispatch_async(dispatch_get_main_queue(), ^{ 84 | if (block) { 85 | block(status); 86 | } 87 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 88 | NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) }; 89 | [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo]; 90 | }); 91 | } 92 | 93 | static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { 94 | AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusBlock)info); 95 | } 96 | 97 | 98 | static const void * AFNetworkReachabilityRetainCallback(const void *info) { 99 | return Block_copy(info); 100 | } 101 | 102 | static void AFNetworkReachabilityReleaseCallback(const void *info) { 103 | if (info) { 104 | Block_release(info); 105 | } 106 | } 107 | 108 | @interface AFNetworkReachabilityManager () 109 | @property (readonly, nonatomic, assign) SCNetworkReachabilityRef networkReachability; 110 | @property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; 111 | @property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; 112 | @end 113 | 114 | @implementation AFNetworkReachabilityManager 115 | 116 | + (instancetype)sharedManager { 117 | static AFNetworkReachabilityManager *_sharedManager = nil; 118 | static dispatch_once_t onceToken; 119 | dispatch_once(&onceToken, ^{ 120 | _sharedManager = [self manager]; 121 | }); 122 | 123 | return _sharedManager; 124 | } 125 | 126 | + (instancetype)managerForDomain:(NSString *)domain { 127 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]); 128 | 129 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; 130 | 131 | CFRelease(reachability); 132 | 133 | return manager; 134 | } 135 | 136 | + (instancetype)managerForAddress:(const void *)address { 137 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address); 138 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; 139 | 140 | CFRelease(reachability); 141 | 142 | return manager; 143 | } 144 | 145 | + (instancetype)manager 146 | { 147 | #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 148 | struct sockaddr_in6 address; 149 | bzero(&address, sizeof(address)); 150 | address.sin6_len = sizeof(address); 151 | address.sin6_family = AF_INET6; 152 | #else 153 | struct sockaddr_in address; 154 | bzero(&address, sizeof(address)); 155 | address.sin_len = sizeof(address); 156 | address.sin_family = AF_INET; 157 | #endif 158 | return [self managerForAddress:&address]; 159 | } 160 | 161 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability { 162 | self = [super init]; 163 | if (!self) { 164 | return nil; 165 | } 166 | 167 | _networkReachability = CFRetain(reachability); 168 | self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; 169 | 170 | return self; 171 | } 172 | 173 | - (instancetype)init NS_UNAVAILABLE 174 | { 175 | return nil; 176 | } 177 | 178 | - (void)dealloc { 179 | [self stopMonitoring]; 180 | 181 | if (_networkReachability != NULL) { 182 | CFRelease(_networkReachability); 183 | } 184 | } 185 | 186 | #pragma mark - 187 | 188 | - (BOOL)isReachable { 189 | return [self isReachableViaWWAN] || [self isReachableViaWiFi]; 190 | } 191 | 192 | - (BOOL)isReachableViaWWAN { 193 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN; 194 | } 195 | 196 | - (BOOL)isReachableViaWiFi { 197 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi; 198 | } 199 | 200 | #pragma mark - 201 | 202 | - (void)startMonitoring { 203 | [self stopMonitoring]; 204 | 205 | if (!self.networkReachability) { 206 | return; 207 | } 208 | 209 | __weak __typeof(self)weakSelf = self; 210 | AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { 211 | __strong __typeof(weakSelf)strongSelf = weakSelf; 212 | 213 | strongSelf.networkReachabilityStatus = status; 214 | if (strongSelf.networkReachabilityStatusBlock) { 215 | strongSelf.networkReachabilityStatusBlock(status); 216 | } 217 | 218 | }; 219 | 220 | SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; 221 | SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); 222 | SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); 223 | 224 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ 225 | SCNetworkReachabilityFlags flags; 226 | if (SCNetworkReachabilityGetFlags(self.networkReachability, &flags)) { 227 | AFPostReachabilityStatusChange(flags, callback); 228 | } 229 | }); 230 | } 231 | 232 | - (void)stopMonitoring { 233 | if (!self.networkReachability) { 234 | return; 235 | } 236 | 237 | SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); 238 | } 239 | 240 | #pragma mark - 241 | 242 | - (NSString *)localizedNetworkReachabilityStatusString { 243 | return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus); 244 | } 245 | 246 | #pragma mark - 247 | 248 | - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { 249 | self.networkReachabilityStatusBlock = block; 250 | } 251 | 252 | #pragma mark - NSKeyValueObserving 253 | 254 | + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { 255 | if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) { 256 | return [NSSet setWithObject:@"networkReachabilityStatus"]; 257 | } 258 | 259 | return [super keyPathsForValuesAffectingValueForKey:key]; 260 | } 261 | 262 | @end 263 | #endif 264 | -------------------------------------------------------------------------------- /JSONToModel/thirdLibs/AFNetClient.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // AFNetClient.m 4 | // MLSocketioChat 5 | // 6 | // Created by luo.h on 2017/10/13. 7 | // Copyright © 2017年 apple.com..cn. All rights reserved. 8 | // 9 | 10 | #import "AFNetClient.h" 11 | 12 | static NSTimeInterval KAFRequestTimeout = 20.f; 13 | @implementation AFNetClient 14 | 15 | #pragma mark - manager 16 | + (AFHTTPSessionManager *)defaultManager { 17 | //1.初始化 18 | AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; 19 | 20 | //2.1设置网络请求超时时间 21 | manager.requestSerializer = [AFHTTPRequestSerializer serializer]; 22 | manager.requestSerializer.timeoutInterval = KAFRequestTimeout; 23 | 24 | //3.1配置请求序列化 25 | AFJSONResponseSerializer *serializer = [AFJSONResponseSerializer serializer]; 26 | [serializer setRemovesKeysWithNullValues:YES]; 27 | manager.responseSerializer = serializer; 28 | 29 | NSMutableSet *ContentTypes = [NSMutableSet setWithSet:manager.responseSerializer.acceptableContentTypes]; 30 | [ContentTypes addObjectsFromArray:@[@"text/html"]]; 31 | //3.2设置格式 (默认二进制, 这里不用改也OK)-配置响应序列化 32 | manager.responseSerializer.acceptableContentTypes=ContentTypes; 33 | 34 | return manager; 35 | } 36 | 37 | 38 | 39 | 40 | /** 41 | @ get 请求 42 | @param path 无参数 43 | */ 44 | + (NSURLSessionTask *)GET_Path:(NSString *)path completed:(MTSuccessBlock )successBlock failed:(MTFailedBlock )faileBlock 45 | { 46 | return [self GET_Path:path params:nil headers:nil completed:successBlock failed:faileBlock]; 47 | } 48 | 49 | /** 50 | @ get 请求 51 | @param path 有参数 52 | */ 53 | //https://stackoverflow.com/questions/19114623/request-failed-unacceptable-content-type-text-html-using-afnetworking-2-0 54 | +(NSURLSessionTask *)GET_Path:(NSString *)path params:(NSDictionary *)params completed:(MTSuccessBlock )successBlock failed:(MTFailedBlock )faileBlock 55 | { 56 | return [self GET_Path:path params:params headers:nil completed:successBlock failed:faileBlock]; 57 | } 58 | 59 | 60 | +(NSURLSessionTask *)GET_Path:(NSString *)path 61 | params:(NSDictionary *)params 62 | headers:(NSDictionary *)headers 63 | completed:(MTSuccessBlock )successBlock failed:(MTFailedBlock )faileBlock 64 | { 65 | // 1.初始化 66 | AFHTTPSessionManager *manager = [self defaultManager]; 67 | 68 | // 2.设置请求头 69 | if (headers&&headers.count>0) { 70 | for (NSString *key in [headers allKeys]) { 71 | [manager.requestSerializer setValue:headers[key] forHTTPHeaderField:key]; 72 | } 73 | } 74 | NSLog(@"GET请求信息(%@=%@=%@)",path,params,headers); 75 | NSURLSessionDataTask *sessionTask = [manager GET:path parameters:params progress:^(NSProgress * _Nonnull downloadProgress) { 76 | 77 | } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { 78 | if (successBlock){ 79 | if ([responseObject isKindOfClass:[NSDictionary class]]) { 80 | 81 | }else{ 82 | responseObject = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];//把NSData转换成字典类型 83 | } 84 | NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response; 85 | successBlock(response,responseObject); 86 | } 87 | } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { 88 | if (faileBlock){ 89 | faileBlock(error); 90 | } 91 | }]; 92 | return sessionTask; 93 | } 94 | 95 | 96 | 97 | /** 98 | @ POST 请求 无参数 99 | */ 100 | + (void)POST_Path:(NSString *)path completed:(MTSuccessBlock )successBlock failed:(MTFailedBlock )faileBlock 101 | { 102 | [self POST_Path:path params:nil headers:nil completed:successBlock failed:faileBlock]; 103 | } 104 | 105 | 106 | /** 107 | @ POST 请求 有参数 108 | */ 109 | + (void)POST_Path:(NSString *)path params:(NSDictionary *)paramsDic completed:(MTSuccessBlock )successBlock failed:(MTFailedBlock )faileBlock 110 | { 111 | [self POST_Path:path params:paramsDic headers:nil completed:successBlock failed:faileBlock]; 112 | } 113 | 114 | 115 | +(void)POST_Path:(NSString *)path 116 | params:(NSDictionary *)params 117 | headers:(NSDictionary *)headers 118 | completed:(MTSuccessBlock )successBlock failed:(MTFailedBlock )faileBlock 119 | { 120 | // 1.获取默认manager 121 | AFHTTPSessionManager *manager = [self defaultManager]; 122 | 123 | //若有汉语进行UTF8转码(这个方法是iOS9之后的方法) 124 | //path = [path stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; 125 | 126 | // 2.设置请求头 127 | if (headers&&headers.count>0) { 128 | for (NSString *key in [headers allKeys]) { 129 | [manager.requestSerializer setValue:headers[key] forHTTPHeaderField:key]; 130 | } 131 | } 132 | NSLog(@"POST请求信息(Path=%@ params=%@ headers=%@)",path,params,headers); 133 | [manager POST:path parameters:params progress:^(NSProgress * _Nonnull uploadProgress) { 134 | 135 | } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { 136 | if (successBlock){ 137 | if ([responseObject isKindOfClass:[NSDictionary class]]) { 138 | }else{ 139 | responseObject = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];//把NSData转换成字典类型 140 | } 141 | NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response; 142 | successBlock(response,responseObject); 143 | } 144 | } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { 145 | if (faileBlock){ 146 | faileBlock(error); 147 | } 148 | }]; 149 | } 150 | 151 | 152 | 153 | +(void)Request_Path:(NSString *)path 154 | method:(NSString *)method 155 | params:(NSDictionary *)params 156 | headers:(NSDictionary *)headers 157 | completed:(MTSuccessBlock )successBlock failed:(MTFailedBlock )faileBlock 158 | { 159 | // need add 160 | } 161 | 162 | 163 | 164 | #pragma mark--- 165 | #pragma mark - 检查网络 166 | + (void)checkNetworkStatus { 167 | AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager]; 168 | [manager startMonitoring]; 169 | [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { 170 | switch (status) { 171 | case AFNetworkReachabilityStatusNotReachable: 172 | break; 173 | case AFNetworkReachabilityStatusUnknown: 174 | break; 175 | case AFNetworkReachabilityStatusReachableViaWWAN: 176 | break; 177 | case AFNetworkReachabilityStatusReachableViaWiFi: 178 | break; 179 | default: 180 | break; 181 | } 182 | 183 | }]; 184 | } 185 | 186 | 187 | /*实时获取网络状态,此方法可多次调用*/ 188 | + (void)networkStatusWithBlock:(AFNetworkStatusBlock)networkStatus{ 189 | static dispatch_once_t onceToken; 190 | dispatch_once(&onceToken, ^{ 191 | [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { 192 | networkStatus ? networkStatus(status) : nil; 193 | }]; 194 | }); 195 | } 196 | 197 | + (BOOL)isNetwork{ 198 | return [AFNetworkReachabilityManager sharedManager].reachable; 199 | } 200 | 201 | + (BOOL)isWiFiNetwork{ 202 | return [AFNetworkReachabilityManager sharedManager].reachableViaWiFi; 203 | } 204 | 205 | + (BOOL)isWWANNetwork{ 206 | return [AFNetworkReachabilityManager sharedManager].reachableViaWWAN; 207 | } 208 | 209 | 210 | @end 211 | 212 | 213 | #pragma mark -- NSDictionary,NSArray的分类------ 214 | /* 215 | *************************************************************************** 216 | * 新建NSDictionary与NSArray的分类, 控制台打印json数据中的中文 * 217 | *************************************************************************** 218 | */ 219 | @implementation NSArray (AFNET) 220 | 221 | - (NSString *)descriptionWithLocale:(id)locale{ 222 | 223 | NSMutableString *strM = [NSMutableString stringWithString:@"(\n"]; 224 | [self enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 225 | [strM appendFormat:@"\t%@,\n",obj]; 226 | }]; 227 | [strM appendString:@")\n"]; 228 | return strM; 229 | } 230 | @end 231 | 232 | @implementation NSDictionary (AFNET) 233 | 234 | - (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level { 235 | NSMutableString *desc = [NSMutableString string]; 236 | NSMutableString *tabString = [[NSMutableString alloc] initWithCapacity:level]; 237 | for (NSUInteger i = 0; i < level; ++i) { 238 | [tabString appendString:@"\t"]; 239 | } 240 | 241 | NSString *tab = @""; 242 | if (level > 0) { 243 | tab = tabString; 244 | } 245 | 246 | [desc appendString:@"\t{\n"]; 247 | 248 | // Through array, self is array 249 | for (id key in self.allKeys) { 250 | id obj = [self objectForKey:key]; 251 | 252 | if ([obj isKindOfClass:[NSString class]]) { 253 | [desc appendFormat:@"%@\t%@ = \"%@\",\n", tab, key, obj]; 254 | } else if ([obj isKindOfClass:[NSArray class]] 255 | || [obj isKindOfClass:[NSDictionary class]] 256 | || [obj isKindOfClass:[NSSet class]]) { 257 | [desc appendFormat:@"%@\t%@ = %@,\n", tab, key, [obj descriptionWithLocale:locale indent:level + 1]]; 258 | } else if ([obj isKindOfClass:[NSData class]]) { 259 | 260 | NSError *error = nil; 261 | NSObject *result = [NSJSONSerialization JSONObjectWithData:obj 262 | options:NSJSONReadingMutableContainers 263 | error:&error]; 264 | 265 | if (error == nil && result != nil) { 266 | if ([result isKindOfClass:[NSDictionary class]] 267 | || [result isKindOfClass:[NSArray class]] 268 | || [result isKindOfClass:[NSSet class]]) { 269 | NSString *str = [((NSDictionary *)result) descriptionWithLocale:locale indent:level + 1]; 270 | [desc appendFormat:@"%@\t%@ = %@,\n", tab, key, str]; 271 | } else if ([obj isKindOfClass:[NSString class]]) { 272 | [desc appendFormat:@"%@\t%@ = \"%@\",\n", tab, key, result]; 273 | } 274 | } else { 275 | @try { 276 | NSString *str = [[NSString alloc] initWithData:obj encoding:NSUTF8StringEncoding]; 277 | if (str != nil) { 278 | [desc appendFormat:@"%@\t%@ = \"%@\",\n", tab, key, str]; 279 | } else { 280 | [desc appendFormat:@"%@\t%@ = %@,\n", tab, key, obj]; 281 | } 282 | } 283 | @catch (NSException *exception) { 284 | [desc appendFormat:@"%@\t%@ = %@,\n", tab, key, obj]; 285 | } 286 | } 287 | } else { 288 | [desc appendFormat:@"%@\t%@ = %@,\n", tab, key, obj]; 289 | } 290 | } 291 | 292 | [desc appendFormat:@"%@}", tab]; 293 | 294 | return desc; 295 | } 296 | 297 | @end 298 | 299 | 300 | 301 | 302 | 303 | //acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html", @"text/json", @"text/plain", @"text/javascript", @"text/xml", @"image/*", nil]; 304 | 305 | -------------------------------------------------------------------------------- /JSONToModel/thirdLibs/cssjson.js: -------------------------------------------------------------------------------- 1 | /** 2 | * CSS-JSON Converter for JavaScript 3 | * Converts CSS to JSON and back. 4 | * Version 2.1 5 | * 6 | * Released under the MIT license. 7 | * 8 | * Copyright (c) 2013 Aram Kocharyan, http://aramk.com/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 11 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation 12 | the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 13 | to permit persons to whom the Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all copies or substantial portions 16 | of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 19 | THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | */ 24 | 25 | var CSSJSON = new function () { 26 | 27 | var base = this; 28 | 29 | base.init = function () { 30 | // String functions 31 | String.prototype.trim = function () { 32 | return this.replace(/^\s+|\s+$/g, ''); 33 | }; 34 | 35 | String.prototype.repeat = function (n) { 36 | return new Array(1 + n).join(this); 37 | }; 38 | }; 39 | base.init(); 40 | 41 | var selX = /([^\s\;\{\}][^\;\{\}]*)\{/g; 42 | var endX = /\}/g; 43 | var lineX = /([^\;\{\}]*)\;/g; 44 | var commentX = /\/\*[\s\S]*?\*\//g; 45 | var lineAttrX = /([^\:]+):([^\;]*);/; 46 | 47 | // This is used, a concatenation of all above. We use alternation to 48 | // capture. 49 | var altX = /(\/\*[\s\S]*?\*\/)|([^\s\;\{\}][^\;\{\}]*(?=\{))|(\})|([^\;\{\}]+\;(?!\s*\*\/))/gmi; 50 | 51 | // Capture groups 52 | var capComment = 1; 53 | var capSelector = 2; 54 | var capEnd = 3; 55 | var capAttr = 4; 56 | 57 | var isEmpty = function (x) { 58 | return typeof x == 'undefined' || x.length == 0 || x == null; 59 | }; 60 | 61 | var isCssJson = function (node) { 62 | return !isEmpty(node) ? (node.attributes && node.children) : false; 63 | } 64 | 65 | /** 66 | * Input is css string and current pos, returns JSON object 67 | * 68 | * @param cssString 69 | * The CSS string. 70 | * @param args 71 | * An optional argument object. ordered: Whether order of 72 | * comments and other nodes should be kept in the output. This 73 | * will return an object where all the keys are numbers and the 74 | * values are objects containing "name" and "value" keys for each 75 | * node. comments: Whether to capture comments. split: Whether to 76 | * split each comma separated list of selectors. 77 | */ 78 | base.toJSON = function (cssString, args) { 79 | var node = { 80 | children: {}, 81 | attributes: {} 82 | }; 83 | var match = null; 84 | var count = 0; 85 | 86 | if (typeof args == 'undefined') { 87 | var args = { 88 | ordered: false, 89 | comments: false, 90 | stripComments: false, 91 | split: false 92 | }; 93 | } 94 | if (args.stripComments) { 95 | args.comments = false; 96 | cssString = cssString.replace(commentX, ''); 97 | } 98 | 99 | while ((match = altX.exec(cssString)) != null) { 100 | if (!isEmpty(match[capComment]) && args.comments) { 101 | // Comment 102 | var add = match[capComment].trim(); 103 | node[count++] = add; 104 | } else if (!isEmpty(match[capSelector])) { 105 | // New node, we recurse 106 | var name = match[capSelector].trim(); 107 | // This will return when we encounter a closing brace 108 | var newNode = base.toJSON(cssString, args); 109 | if (args.ordered) { 110 | var obj = {}; 111 | obj['name'] = name; 112 | obj['value'] = newNode; 113 | // Since we must use key as index to keep order and not 114 | // name, this will differentiate between a Rule Node and an 115 | // Attribute, since both contain a name and value pair. 116 | obj['type'] = 'rule'; 117 | node[count++] = obj; 118 | } else { 119 | if (args.split) { 120 | var bits = name.split(','); 121 | } else { 122 | var bits = [name]; 123 | } 124 | for (var i = 0; i < bits.length; i++) { 125 | var sel = bits[i].trim(); 126 | if (sel in node.children) { 127 | for (var att in newNode.attributes) { 128 | node.children[sel].attributes[att] = newNode.attributes[att]; 129 | } 130 | } else { 131 | node.children[sel] = newNode; 132 | } 133 | } 134 | } 135 | } else if (!isEmpty(match[capEnd])) { 136 | // Node has finished 137 | return node; 138 | } else if (!isEmpty(match[capAttr])) { 139 | var line = match[capAttr].trim(); 140 | var attr = lineAttrX.exec(line); 141 | if (attr) { 142 | // Attribute 143 | var name = attr[1].trim(); 144 | var value = attr[2].trim(); 145 | if (args.ordered) { 146 | var obj = {}; 147 | obj['name'] = name; 148 | obj['value'] = value; 149 | obj['type'] = 'attr'; 150 | node[count++] = obj; 151 | } else { 152 | if (name in node.attributes) { 153 | var currVal = node.attributes[name]; 154 | if (!(currVal instanceof Array)) { 155 | node.attributes[name] = [currVal]; 156 | } 157 | node.attributes[name].push(value); 158 | } else { 159 | node.attributes[name] = value; 160 | } 161 | } 162 | } else { 163 | // Semicolon terminated line 164 | node[count++] = line; 165 | } 166 | } 167 | } 168 | 169 | return node; 170 | }; 171 | 172 | /** 173 | * @param node 174 | * A JSON node. 175 | * @param depth 176 | * The depth of the current node; used for indentation and 177 | * optional. 178 | * @param breaks 179 | * Whether to add line breaks in the output. 180 | */ 181 | base.toCSS = function (node, depth, breaks) { 182 | var cssString = ''; 183 | if (typeof depth == 'undefined') { 184 | depth = 0; 185 | } 186 | if (typeof breaks == 'undefined') { 187 | breaks = false; 188 | } 189 | if (node.attributes) { 190 | for (i in node.attributes) { 191 | var att = node.attributes[i]; 192 | if (att instanceof Array) { 193 | for (var j = 0; j < att.length; j++) { 194 | cssString += strAttr(i, att[j], depth); 195 | } 196 | } else { 197 | cssString += strAttr(i, att, depth); 198 | } 199 | } 200 | } 201 | if (node.children) { 202 | var first = true; 203 | for (i in node.children) { 204 | if (breaks && !first) { 205 | cssString += '\n'; 206 | } else { 207 | first = false; 208 | } 209 | cssString += strNode(i, node.children[i], depth); 210 | } 211 | } 212 | return cssString; 213 | }; 214 | 215 | /** 216 | * @param data 217 | * You can pass css string or the CSSJS.toJSON return value. 218 | * @param id (Optional) 219 | * To identify and easy removable of the style element 220 | * @param replace (Optional. defaults to TRUE) 221 | * Whether to remove or simply do nothing 222 | * @return HTMLLinkElement 223 | */ 224 | base.toHEAD = function (data, id, replace) { 225 | var head = document.getElementsByTagName('head')[0]; 226 | var xnode = document.getElementById(id); 227 | var _xnodeTest = (xnode !== null && xnode instanceof HTMLStyleElement); 228 | 229 | if (isEmpty(data) || !(head instanceof HTMLHeadElement)) return; 230 | if (_xnodeTest) { 231 | if (replace === true || isEmpty(replace)) { 232 | xnode.removeAttribute('id'); 233 | } else return; 234 | } 235 | if (isCssJson(data)) { 236 | data = base.toCSS(data); 237 | } 238 | 239 | var node = document.createElement('style'); 240 | node.type = 'text/css'; 241 | 242 | if (!isEmpty(id)) { 243 | node.id = id; 244 | } else { 245 | node.id = 'cssjson_' + timestamp(); 246 | } 247 | if (node.styleSheet) { 248 | node.styleSheet.cssText = data; 249 | } else { 250 | node.appendChild(document.createTextNode(data)); 251 | } 252 | 253 | head.appendChild(node); 254 | 255 | if (isValidStyleNode(node)) { 256 | if (_xnodeTest) { 257 | xnode.parentNode.removeChild(xnode); 258 | } 259 | } else { 260 | node.parentNode.removeChild(node); 261 | if (_xnodeTest) { 262 | xnode.setAttribute('id', id); 263 | node = xnode; 264 | } else return; 265 | } 266 | 267 | return node; 268 | }; 269 | 270 | // Alias 271 | 272 | if (typeof window != 'undefined') { 273 | window.createCSS = base.toHEAD; 274 | } 275 | 276 | // Helpers 277 | 278 | var isValidStyleNode = function (node) { 279 | return (node instanceof HTMLStyleElement) && node.sheet.cssRules.length > 0; 280 | } 281 | 282 | var timestamp = function () { 283 | return Date.now() || +new Date(); 284 | }; 285 | 286 | var strAttr = function (name, value, depth) { 287 | return '\t'.repeat(depth) + name + ': ' + value + ';\n'; 288 | }; 289 | 290 | var strNode = function (name, value, depth) { 291 | var cssString = '\t'.repeat(depth) + name + ' {\n'; 292 | cssString += base.toCSS(value, depth + 1); 293 | cssString += '\t'.repeat(depth) + '}\n'; 294 | return cssString; 295 | }; 296 | 297 | }; 298 | 299 | 300 | function exampleCSSJSON(cssString) { 301 | var json = CSSJSON.toJSON(cssString); 302 | var jsonStr = JSON.stringify(json); 303 | return jsonStr; 304 | } 305 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | // AFURLResponseSerialization.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | #import 24 | 25 | NS_ASSUME_NONNULL_BEGIN 26 | 27 | /** 28 | The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data. 29 | 30 | For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object. 31 | */ 32 | @protocol AFURLResponseSerialization 33 | 34 | /** 35 | The response object decoded from the data associated with a specified response. 36 | 37 | @param response The response to be processed. 38 | @param data The response data to be decoded. 39 | @param error The error that occurred while attempting to decode the response data. 40 | 41 | @return The object decoded from the specified response data. 42 | */ 43 | - (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response 44 | data:(nullable NSData *)data 45 | error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW; 46 | 47 | @end 48 | 49 | #pragma mark - 50 | 51 | /** 52 | `AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. 53 | 54 | Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior. 55 | */ 56 | @interface AFHTTPResponseSerializer : NSObject 57 | 58 | - (instancetype)init; 59 | 60 | /** 61 | The string encoding used to serialize data received from the server, when no string encoding is specified by the response. `NSUTF8StringEncoding` by default. 62 | */ 63 | @property (nonatomic, assign) NSStringEncoding stringEncoding; 64 | 65 | /** 66 | Creates and returns a serializer with default configuration. 67 | */ 68 | + (instancetype)serializer; 69 | 70 | ///----------------------------------------- 71 | /// @name Configuring Response Serialization 72 | ///----------------------------------------- 73 | 74 | /** 75 | The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation. 76 | 77 | See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 78 | */ 79 | @property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes; 80 | 81 | /** 82 | The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation. 83 | */ 84 | @property (nonatomic, copy, nullable) NSSet *acceptableContentTypes; 85 | 86 | /** 87 | Validates the specified response and data. 88 | 89 | In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks. 90 | 91 | @param response The response to be validated. 92 | @param data The data associated with the response. 93 | @param error The error that occurred while attempting to validate the response. 94 | 95 | @return `YES` if the response is valid, otherwise `NO`. 96 | */ 97 | - (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response 98 | data:(nullable NSData *)data 99 | error:(NSError * _Nullable __autoreleasing *)error; 100 | 101 | @end 102 | 103 | #pragma mark - 104 | 105 | 106 | /** 107 | `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses. 108 | 109 | By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types: 110 | 111 | - `application/json` 112 | - `text/json` 113 | - `text/javascript` 114 | */ 115 | @interface AFJSONResponseSerializer : AFHTTPResponseSerializer 116 | 117 | - (instancetype)init; 118 | 119 | /** 120 | Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. 121 | */ 122 | @property (nonatomic, assign) NSJSONReadingOptions readingOptions; 123 | 124 | /** 125 | Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`. 126 | */ 127 | @property (nonatomic, assign) BOOL removesKeysWithNullValues; 128 | 129 | /** 130 | Creates and returns a JSON serializer with specified reading and writing options. 131 | 132 | @param readingOptions The specified JSON reading options. 133 | */ 134 | + (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions; 135 | 136 | @end 137 | 138 | #pragma mark - 139 | 140 | /** 141 | `AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects. 142 | 143 | By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: 144 | 145 | - `application/xml` 146 | - `text/xml` 147 | */ 148 | @interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer 149 | 150 | @end 151 | 152 | #pragma mark - 153 | 154 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED 155 | 156 | /** 157 | `AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. 158 | 159 | By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: 160 | 161 | - `application/xml` 162 | - `text/xml` 163 | */ 164 | @interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer 165 | 166 | - (instancetype)init; 167 | 168 | /** 169 | Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. 170 | */ 171 | @property (nonatomic, assign) NSUInteger options; 172 | 173 | /** 174 | Creates and returns an XML document serializer with the specified options. 175 | 176 | @param mask The XML document options. 177 | */ 178 | + (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask; 179 | 180 | @end 181 | 182 | #endif 183 | 184 | #pragma mark - 185 | 186 | /** 187 | `AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. 188 | 189 | By default, `AFPropertyListResponseSerializer` accepts the following MIME types: 190 | 191 | - `application/x-plist` 192 | */ 193 | @interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer 194 | 195 | - (instancetype)init; 196 | 197 | /** 198 | The property list format. Possible values are described in "NSPropertyListFormat". 199 | */ 200 | @property (nonatomic, assign) NSPropertyListFormat format; 201 | 202 | /** 203 | The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions." 204 | */ 205 | @property (nonatomic, assign) NSPropertyListReadOptions readOptions; 206 | 207 | /** 208 | Creates and returns a property list serializer with a specified format, read options, and write options. 209 | 210 | @param format The property list format. 211 | @param readOptions The property list reading options. 212 | */ 213 | + (instancetype)serializerWithFormat:(NSPropertyListFormat)format 214 | readOptions:(NSPropertyListReadOptions)readOptions; 215 | 216 | @end 217 | 218 | #pragma mark - 219 | 220 | /** 221 | `AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses. 222 | 223 | By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage: 224 | 225 | - `image/tiff` 226 | - `image/jpeg` 227 | - `image/gif` 228 | - `image/png` 229 | - `image/ico` 230 | - `image/x-icon` 231 | - `image/bmp` 232 | - `image/x-bmp` 233 | - `image/x-xbitmap` 234 | - `image/x-win-bitmap` 235 | */ 236 | @interface AFImageResponseSerializer : AFHTTPResponseSerializer 237 | 238 | #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH 239 | /** 240 | The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance. 241 | */ 242 | @property (nonatomic, assign) CGFloat imageScale; 243 | 244 | /** 245 | Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default. 246 | */ 247 | @property (nonatomic, assign) BOOL automaticallyInflatesResponseImage; 248 | #endif 249 | 250 | @end 251 | 252 | #pragma mark - 253 | 254 | /** 255 | `AFCompoundSerializer` is a subclass of `AFHTTPResponseSerializer` that delegates the response serialization to the first `AFHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `AFHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer. 256 | */ 257 | @interface AFCompoundResponseSerializer : AFHTTPResponseSerializer 258 | 259 | /** 260 | The component response serializers. 261 | */ 262 | @property (readonly, nonatomic, copy) NSArray > *responseSerializers; 263 | 264 | /** 265 | Creates and returns a compound serializer comprised of the specified response serializers. 266 | 267 | @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`. 268 | */ 269 | + (instancetype)compoundSerializerWithResponseSerializers:(NSArray > *)responseSerializers; 270 | 271 | @end 272 | 273 | ///---------------- 274 | /// @name Constants 275 | ///---------------- 276 | 277 | /** 278 | ## Error Domains 279 | 280 | The following error domain is predefined. 281 | 282 | - `NSString * const AFURLResponseSerializationErrorDomain` 283 | 284 | ### Constants 285 | 286 | `AFURLResponseSerializationErrorDomain` 287 | AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. 288 | */ 289 | FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain; 290 | 291 | /** 292 | ## User info dictionary keys 293 | 294 | These keys may exist in the user info dictionary, in addition to those defined for NSError. 295 | 296 | - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey` 297 | - `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey` 298 | 299 | ### Constants 300 | 301 | `AFNetworkingOperationFailingURLResponseErrorKey` 302 | The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. 303 | 304 | `AFNetworkingOperationFailingURLResponseDataErrorKey` 305 | The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. 306 | */ 307 | FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey; 308 | 309 | FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey; 310 | 311 | NS_ASSUME_NONNULL_END 312 | --------------------------------------------------------------------------------