├── .gitignore ├── Example ├── Podfile ├── Podfile.lock ├── Pods │ ├── HZFoundation │ │ ├── HZFoundation │ │ │ └── Classes │ │ │ │ ├── Foundation │ │ │ │ ├── HZConst.h │ │ │ │ ├── HZMacro.h │ │ │ │ ├── HZSingleton.h │ │ │ │ ├── NSArray+HZExtend.h │ │ │ │ ├── NSArray+HZExtend.m │ │ │ │ ├── NSData+HZExtend.h │ │ │ │ ├── NSData+HZExtend.m │ │ │ │ ├── NSDate+HZExtend.h │ │ │ │ ├── NSDate+HZExtend.m │ │ │ │ ├── NSDictionary+HZExtend.h │ │ │ │ ├── NSDictionary+HZExtend.m │ │ │ │ ├── NSObject+HZExtend.h │ │ │ │ ├── NSObject+HZExtend.m │ │ │ │ ├── NSObject+HZKVO.h │ │ │ │ ├── NSObject+HZKVO.m │ │ │ │ ├── NSString+HZExtend.h │ │ │ │ ├── NSString+HZExtend.m │ │ │ │ ├── NSTimer+HZExtend.h │ │ │ │ ├── NSTimer+HZExtend.m │ │ │ │ ├── NSURL+HZExtend.h │ │ │ │ ├── NSURL+HZExtend.m │ │ │ │ ├── UIAlertController+HZExtend.h │ │ │ │ ├── UIAlertController+HZExtend.m │ │ │ │ ├── UIApplication+HZExtend.h │ │ │ │ ├── UIApplication+HZExtend.m │ │ │ │ ├── UIColor+HZExtend.h │ │ │ │ ├── UIColor+HZExtend.m │ │ │ │ ├── UIDevice+HZExtend.h │ │ │ │ ├── UIDevice+HZExtend.m │ │ │ │ ├── UIResponder+HZExtend.h │ │ │ │ ├── UIResponder+HZExtend.m │ │ │ │ ├── UIScrollView+HZExtend.h │ │ │ │ ├── UIScrollView+HZExtend.m │ │ │ │ ├── UIView+HZExtend.h │ │ │ │ └── UIView+HZExtend.m │ │ │ │ └── HZFoundation.h │ │ ├── LICENSE │ │ └── README.md │ ├── Headers │ │ ├── Private │ │ │ ├── HZFoundation │ │ │ │ ├── HZConst.h │ │ │ │ ├── HZFoundation.h │ │ │ │ ├── HZMacro.h │ │ │ │ ├── HZSingleton.h │ │ │ │ ├── NSArray+HZExtend.h │ │ │ │ ├── NSData+HZExtend.h │ │ │ │ ├── NSDate+HZExtend.h │ │ │ │ ├── NSDictionary+HZExtend.h │ │ │ │ ├── NSObject+HZExtend.h │ │ │ │ ├── NSObject+HZKVO.h │ │ │ │ ├── NSString+HZExtend.h │ │ │ │ ├── NSTimer+HZExtend.h │ │ │ │ ├── NSURL+HZExtend.h │ │ │ │ ├── UIAlertController+HZExtend.h │ │ │ │ ├── UIApplication+HZExtend.h │ │ │ │ ├── UIColor+HZExtend.h │ │ │ │ ├── UIDevice+HZExtend.h │ │ │ │ ├── UIResponder+HZExtend.h │ │ │ │ ├── UIScrollView+HZExtend.h │ │ │ │ └── UIView+HZExtend.h │ │ │ └── HZURLManager │ │ │ │ ├── HZErrorViewController.h │ │ │ │ ├── HZNavigationController.h │ │ │ │ ├── HZURLHandler.h │ │ │ │ ├── HZURLManager.h │ │ │ │ ├── HZURLManagerConfig.h │ │ │ │ ├── HZURLNavigation.h │ │ │ │ ├── HZURLRewrite.h │ │ │ │ ├── NSObject+HZURLHandler.h │ │ │ │ └── UIViewController+HZURLManager.h │ │ └── Public │ │ │ ├── HZFoundation │ │ │ ├── HZConst.h │ │ │ ├── HZFoundation.h │ │ │ ├── HZMacro.h │ │ │ ├── HZSingleton.h │ │ │ ├── NSArray+HZExtend.h │ │ │ ├── NSData+HZExtend.h │ │ │ ├── NSDate+HZExtend.h │ │ │ ├── NSDictionary+HZExtend.h │ │ │ ├── NSObject+HZExtend.h │ │ │ ├── NSObject+HZKVO.h │ │ │ ├── NSString+HZExtend.h │ │ │ ├── NSTimer+HZExtend.h │ │ │ ├── NSURL+HZExtend.h │ │ │ ├── UIAlertController+HZExtend.h │ │ │ ├── UIApplication+HZExtend.h │ │ │ ├── UIColor+HZExtend.h │ │ │ ├── UIDevice+HZExtend.h │ │ │ ├── UIResponder+HZExtend.h │ │ │ ├── UIScrollView+HZExtend.h │ │ │ └── UIView+HZExtend.h │ │ │ └── HZURLManager │ │ │ ├── HZErrorViewController.h │ │ │ ├── HZNavigationController.h │ │ │ ├── HZURLHandler.h │ │ │ ├── HZURLManager.h │ │ │ ├── HZURLManagerConfig.h │ │ │ ├── HZURLNavigation.h │ │ │ ├── HZURLRewrite.h │ │ │ ├── NSObject+HZURLHandler.h │ │ │ └── UIViewController+HZURLManager.h │ ├── Local Podspecs │ │ ├── HZFoundation.podspec.json │ │ └── HZURLManager.podspec.json │ ├── Manifest.lock │ ├── Pods.xcodeproj │ │ └── project.pbxproj │ └── Target Support Files │ │ ├── HZFoundation │ │ ├── HZFoundation-dummy.m │ │ ├── HZFoundation-prefix.pch │ │ └── HZFoundation.xcconfig │ │ ├── HZURLManager │ │ ├── HZURLManager-dummy.m │ │ ├── HZURLManager-prefix.pch │ │ └── HZURLManager.xcconfig │ │ └── Pods-URLManager │ │ ├── Pods-URLManager-acknowledgements.markdown │ │ ├── Pods-URLManager-acknowledgements.plist │ │ ├── Pods-URLManager-dummy.m │ │ ├── Pods-URLManager-frameworks.sh │ │ ├── Pods-URLManager-resources.sh │ │ ├── Pods-URLManager.debug.xcconfig │ │ └── Pods-URLManager.release.xcconfig ├── URLManager.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── URLManager.xcworkspace │ └── contents.xcworkspacedata └── URLManager │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ └── LaunchScreen.storyboard │ ├── Info.plist │ ├── ShowAlertURLHandler.h │ ├── ShowAlertURLHandler.m │ ├── URL-Controller-Config.plist │ ├── URL-Method-Config.plist │ ├── URLItemViewController.h │ ├── URLItemViewController.m │ ├── ViewController.h │ ├── ViewController.m │ ├── WebViewController.h │ ├── WebViewController.m │ └── main.m ├── HZURLManager.podspec ├── HZURLManager ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ ├── Controller │ ├── HZErrorViewController.h │ ├── HZErrorViewController.m │ ├── HZNavigationController.h │ └── HZNavigationController.m │ └── Core │ ├── HZURLHandler.h │ ├── HZURLManager.h │ ├── HZURLManager.m │ ├── HZURLManagerConfig.h │ ├── HZURLManagerConfig.m │ ├── HZURLNavigation.h │ ├── HZURLNavigation.m │ ├── HZURLRewrite.h │ ├── HZURLRewrite.m │ ├── NSObject+HZURLHandler.h │ ├── NSObject+HZURLHandler.m │ ├── UIViewController+HZURLManager.h │ └── UIViewController+HZURLManager.m ├── LICENSE ├── README.md └── Screenshoot └── screentshoot.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | .DS_Store 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | platform :ios, '8.0' 3 | 4 | target 'URLManager' do 5 | # Uncomment the next line if you're using Swift or would like to use dynamic frameworks 6 | # use_frameworks! 7 | 8 | # Pods for URLManager 9 | pod 'HZURLManager', :path => '../' 10 | pod 'HZFoundation', :git => 'https://github.com/GeniusBrother/HZFoundation',:branch => 'dev' 11 | end 12 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - HZFoundation (0.1.3) 3 | - HZURLManager (0.1.1) 4 | 5 | DEPENDENCIES: 6 | - HZFoundation (from `https://github.com/GeniusBrother/HZFoundation`, branch `dev`) 7 | - HZURLManager (from `../`) 8 | 9 | EXTERNAL SOURCES: 10 | HZFoundation: 11 | :branch: dev 12 | :git: https://github.com/GeniusBrother/HZFoundation 13 | HZURLManager: 14 | :path: ../ 15 | 16 | CHECKOUT OPTIONS: 17 | HZFoundation: 18 | :commit: 5b541398a8ff97dae359f02b940086084c56cd34 19 | :git: https://github.com/GeniusBrother/HZFoundation 20 | 21 | SPEC CHECKSUMS: 22 | HZFoundation: 6dce609c11a0d9671020921207ea813a37da2b38 23 | HZURLManager: 87f2e040810d2c10da85692128e374cf198b942e 24 | 25 | PODFILE CHECKSUM: 3162d8dcc3682184cee62b23be9a1b9f9f49431a 26 | 27 | COCOAPODS: 1.3.1 28 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/HZConst.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZConst.h 3 | // Pods 4 | // 5 | // Created by xzh on 2017/8/10. 6 | // 7 | // 8 | 9 | #ifndef HZConst_h 10 | #define HZConst_h 11 | 12 | typedef void(^HZVoidBlock)(void); 13 | typedef void(^HZCompletionBlock)(NSError *error); 14 | 15 | 16 | #endif /* HZConst_h */ 17 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/HZMacro.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZMacro.h 3 | // Pods 4 | // 5 | // Created by xzh on 16/8/22. 6 | // 7 | // 8 | 9 | #ifndef HZMacro_h 10 | #define HZMacro_h 11 | 12 | //对象 13 | #define HZNotificationCenter [NSNotificationCenter defaultCenter] 14 | #define HZUserDefaults [NSUserDefaults standardUserDefaults] 15 | #define HZSharedApplication [UIApplication sharedApplication] 16 | #define HZMainBundle [NSBundle mainBundle] 17 | #define HZMainScreen [UIScreen mainScreen] 18 | #define HZDevice [UIDevice currentDevice] 19 | 20 | //屏幕信息 21 | #define HZDeviceWidth ([[UIScreen mainScreen] bounds].size.width) 22 | #define HZDeviceHeight ([[UIScreen mainScreen] bounds].size.height) 23 | #define HZIsIphoneX ((HZDeviceHeight == 812)?YES:NO) 24 | 25 | //常用数值 26 | #define HZTabBarHeight (49.f+HZHomeIndicatorHeight) 27 | #define HZNavBarHeight (HZIsIphoneX?88.f:64.f) 28 | #define HZStatusBarHeight (HZIsIphoneX?44.f:20.f) 29 | #define HZHomeIndicatorHeight (HZIsIphoneX?34.f:0) 30 | #define HZNavBarContentHeight 44.f 31 | 32 | //引用 33 | #define HZWeakObj(Obj) __weak typeof(Obj) weak##_##Obj = Obj 34 | #define HZStrongObj(Obj) __strong typeof(weak##_##Obj) strong##_##Obj = weak##_##Obj 35 | 36 | //路径 37 | #define HZAssetPath(fileName) [[NSBundle mainBundle] pathForResource:fileName ofType:nil] 38 | 39 | #define HZLocalString(key) NSLocalizedString(key, nil) 40 | 41 | #define HZString(...) [NSString stringWithFormat:__VA_ARGS__] 42 | 43 | //返回属性字符串,结合HZObserver使用 44 | #define HZKeyPath(keyPath) NSStringFromSelector(@selector(keyPath)) 45 | 46 | //颜色 47 | #define HZRGB(R,G,B) [UIColor colorWithRed:R/255.0f green:G/255.0f blue:B/255.0f alpha:1.0f] 48 | #define HZRGBA(R,G,B,A) [UIColor colorWithRed:R/255.0f green:G/255.0f blue:B/255.0f alpha:A] 49 | 50 | //限内部使用 51 | #ifdef DEBUG 52 | #define HZLog(format,...) printf("[%s] %s %s\n", __TIME__, __FUNCTION__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]) 53 | #else 54 | #define HZLog(format,...) 55 | #endif 56 | 57 | NS_INLINE NSRange NSMakeRangeLen(NSRange range,NSInteger len) { 58 | NSRange r = range; 59 | r.length = len; 60 | return r; 61 | } 62 | 63 | NS_INLINE NSRange NSMakeRangeLoc(NSRange range,NSInteger loc) { 64 | NSRange r = range; 65 | r.location = loc; 66 | return r; 67 | } 68 | 69 | #endif /* HZMacro_h */ 70 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/HZSingleton.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZSingleton.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/7/26. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | // ## : 连接字符串和参数 9 | #define singleton_h(name) + (instancetype)shared##name; 10 | 11 | #if __has_feature(objc_arc) // ARC 12 | 13 | #define singleton_m \ 14 | static id _instance; \ 15 | + (id)allocWithZone:(struct _NSZone *)zone \ 16 | { \ 17 | static dispatch_once_t onceToken; \ 18 | dispatch_once(&onceToken, ^{ \ 19 | _instance = [super allocWithZone:zone]; \ 20 | }); \ 21 | return _instance; \ 22 | } \ 23 | \ 24 | + (id)copyWithZone:(struct _NSZone *)zone \ 25 | { \ 26 | return _instance; \ 27 | } 28 | 29 | #else // 非ARC 30 | 31 | #define singleton_m(name) \ 32 | static id _instance; \ 33 | + (id)allocWithZone:(struct _NSZone *)zone \ 34 | { \ 35 | static dispatch_once_t onceToken; \ 36 | dispatch_once(&onceToken, ^{ \ 37 | _instance = [super allocWithZone:zone]; \ 38 | }); \ 39 | return _instance; \ 40 | } \ 41 | \ 42 | + (instancetype)shared##name \ 43 | { \ 44 | static dispatch_once_t onceToken; \ 45 | dispatch_once(&onceToken, ^{ \ 46 | _instance = [[self alloc] init]; \ 47 | }); \ 48 | return _instance; \ 49 | } \ 50 | \ 51 | - (oneway void)release \ 52 | { \ 53 | \ 54 | } \ 55 | \ 56 | - (id)autorelease \ 57 | { \ 58 | return _instance; \ 59 | } \ 60 | \ 61 | - (id)retain \ 62 | { \ 63 | return _instance; \ 64 | } \ 65 | \ 66 | - (NSUInteger)retainCount \ 67 | { \ 68 | return 1; \ 69 | } \ 70 | \ 71 | + (id)copyWithZone:(struct _NSZone *)zone \ 72 | { \ 73 | return _instance; \ 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSArray+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+HZExtend.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/7/20. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSObject+HZExtend.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | /** 15 | Provides extensions for `NSArray`. 16 | */ 17 | @interface NSArray (HZExtend) 18 | 19 | /** 20 | Returns the object located at index, or return nil when out of bounds 21 | 22 | @param index index of the object 23 | */ 24 | - (nullable id)objectAtSafeIndex:(NSInteger)index; 25 | 26 | /** 27 | Returns a new array containing the receiving array’s elements that fall within the limits specified by a given range, or return nil if range isn’t within the receiving array’s range of elements. 28 | 29 | @param A range within the receiving array’s range of elements. 30 | */ 31 | - (nullable NSArray *)subarrayWithSafeRange:(NSRange)range; 32 | 33 | /** 34 | Applies the callback to the elements of the given arrays. 35 | 36 | @return an new array containing all the elements of receiver after applying the callback function to each one. 37 | */ 38 | - (NSArray *)map:(id (^)(id obj))block; 39 | 40 | /** 41 | Returns a reversed Array 42 | */ 43 | - (NSArray *)reversedArray; 44 | 45 | /** 46 | Converts receiver to json string. return nil if an error occurs. 47 | */ 48 | - (NSString *)jsonString; 49 | 50 | @end 51 | 52 | 53 | 54 | typedef NSComparisonResult (^NSMutableArrayCompareBlock)(id left, id right); 55 | @interface NSMutableArray (HZExtend) 56 | 57 | /** 58 | Removes the object located at index. 59 | 60 | @discussion If index is out of bounds, the method has no effect and never throw exception. 61 | 62 | @param index index of the object 63 | */ 64 | - (void)safeRemoveObjectAtIndex:(NSInteger)index; 65 | 66 | /** 67 | Adds unique objects. 68 | 69 | @param object the object to be added. 70 | @param compare A comparator block. 71 | */ 72 | - (void)addUniqueObject:(id)object compare:(NSMutableArrayCompareBlock)compare; 73 | 74 | @end 75 | 76 | 77 | 78 | /** 79 | Provide some some common method for `NSMutableArray`. 80 | */ 81 | @interface NSMutableArray (HZDeprecated) 82 | 83 | - (void)appendPageArray:(NSArray *)pageArray pageNumber:(NSInteger)currentPageNumber pageSize:(NSInteger)pageSize __deprecated_msg("已经废弃"); 84 | 85 | - (void)removeDataForPage:(NSInteger)page pageSize:(NSInteger)pageSize __deprecated_msg("已经废弃"); 86 | 87 | @end 88 | 89 | NS_ASSUME_NONNULL_END 90 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSArray+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+HZExtend.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/7/20. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "NSArray+HZExtend.h" 10 | @implementation NSArray (HZExtend) 11 | 12 | - (id)objectAtSafeIndex:(NSInteger)index 13 | { 14 | if (self.count == 0 || index == NSNotFound || (index >(self.count-1)) || index < 0) 15 | { 16 | return nil; 17 | } 18 | 19 | return [self objectAtIndex:index]; 20 | } 21 | 22 | - (NSArray *)subarrayWithSafeRange:(NSRange)range 23 | { 24 | if ( 0 == self.count ) 25 | return nil; 26 | 27 | if ( range.location >= self.count ) 28 | return nil; 29 | 30 | if ( range.location + range.length >= self.count ) 31 | return nil; 32 | 33 | return [self subarrayWithRange:NSMakeRange(range.location, range.length)]; 34 | } 35 | 36 | - (NSArray *)map:(id _Nonnull (^)(id _Nonnull))block 37 | { 38 | __block NSMutableArray *array = [NSMutableArray arrayWithCapacity:[self count]]; 39 | [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { 40 | [array addObject:block(obj)]; 41 | }]; 42 | return array; 43 | } 44 | 45 | 46 | - (NSArray *)reversedArray 47 | { 48 | return self.reverseObjectEnumerator.allObjects; 49 | } 50 | 51 | - (NSString *)jsonString 52 | { 53 | if ([NSJSONSerialization isValidJSONObject:self]) { 54 | NSError *error; 55 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self options:0 error:&error]; 56 | NSString *json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; 57 | return json; 58 | } 59 | return nil; 60 | } 61 | 62 | @end 63 | 64 | 65 | @implementation NSMutableArray (HZExtend) 66 | 67 | - (void)safeRemoveObjectAtIndex:(NSInteger)index 68 | { 69 | if (index >(self.count-1) || index < 0) 70 | { 71 | NSAssert(NO, @"out of bound"); 72 | return; 73 | } 74 | [self removeObjectAtIndex:index]; 75 | } 76 | 77 | - (void)addUniqueObject:(id)object compare:(NSMutableArrayCompareBlock)compare 78 | { 79 | __block BOOL isUnique = YES; 80 | [self enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 81 | if (compare) { 82 | 83 | NSComparisonResult result = compare(obj,object); 84 | if (NSOrderedSame == result) 85 | { 86 | isUnique = NO; 87 | *stop = YES; 88 | } 89 | }else if ([obj class] == [object class] && [obj respondsToSelector:@selector(compare:)]) { 90 | 91 | NSComparisonResult result = [obj compare:object]; 92 | if (NSOrderedSame == result) 93 | { 94 | isUnique = NO; 95 | *stop = YES; 96 | } 97 | } 98 | }]; 99 | 100 | if (isUnique) [self addObject:object]; 101 | } 102 | 103 | @end 104 | 105 | @implementation NSMutableArray (HZDeprecated) 106 | 107 | - (void)appendPageArray:(NSArray *)pageArray pageNumber:(NSInteger)pageNumber pageSize:(NSInteger)pageSize 108 | { 109 | if (!pageArray.isNoEmpty) return; 110 | if (pageNumber == 1) { //1.第一页时对数组进行初始化 111 | [self setArray:pageArray]; 112 | }else if (pageNumber >1) { //2.大于第一页时如果有缓存数据去掉缓存数据 113 | NSInteger preCount = (pageNumber - 1) * pageSize; 114 | if (self.count > preCount) { 115 | [self removeObjectsInRange:NSMakeRange(preCount, self.count - preCount)]; 116 | } 117 | //3.追加数据 118 | [self addObjectsFromArray:pageArray]; 119 | } 120 | } 121 | 122 | - (void)removeDataForPage:(NSInteger)page pageSize:(NSInteger)pageSize 123 | { 124 | NSInteger reserverCount = (page - 1) * pageSize; 125 | if (self.count > reserverCount && reserverCount >= 0) { 126 | NSArray *reserveArray = [self subarrayWithRange:NSMakeRange(0, reserverCount)]; 127 | [self setArray:reserveArray]; 128 | } 129 | } 130 | 131 | @end 132 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSData+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+HZExtend.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/7/26. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSObject+HZExtend.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | /** 15 | Provides extensions method for `NSData`. 16 | */ 17 | @interface NSData (HZExtend) 18 | 19 | /** 20 | Returns an NSData for md5 hash. 21 | */ 22 | - (NSData *)md5Data; 23 | 24 | /** 25 | Returns a NSString for md5 hash. 26 | */ 27 | - (NSString *)md5String; 28 | 29 | @end 30 | 31 | NS_ASSUME_NONNULL_END 32 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSData+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+HZExtend.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/7/26. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "NSData+HZExtend.h" 10 | #import 11 | @implementation NSData (HZExtend) 12 | 13 | - (NSData *)md5Data 14 | { 15 | unsigned char md5Result[CC_MD5_DIGEST_LENGTH + 1]; 16 | CC_LONG md5Length = (CC_LONG)[self length]; 17 | CC_MD5( [self bytes], md5Length, md5Result ); 18 | 19 | NSMutableData * retData = [[NSMutableData alloc] init]; 20 | [retData appendBytes:md5Result length:CC_MD5_DIGEST_LENGTH]; 21 | return retData; 22 | } 23 | 24 | - (NSString *)md5String 25 | { 26 | NSData * value = [self md5Data]; 27 | char tmp[16]; 28 | unsigned char * hex = (unsigned char *)malloc( 2048 + 1 ); 29 | unsigned char * bytes = (unsigned char *)[value bytes]; 30 | unsigned long length = [value length]; 31 | 32 | hex[0] = '\0'; 33 | 34 | for ( unsigned long i = 0; i < length; ++i ) 35 | { 36 | sprintf( tmp, "%02X", bytes[i] ); 37 | strcat( (char *)hex, tmp ); 38 | } 39 | 40 | NSString * result = [NSString stringWithUTF8String:(const char *)hex]; 41 | free( hex ); 42 | return result; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSDate+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+HZExtend.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2017/2/17. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | #import 9 | 10 | #define CURRENT_CALENDAR [NSCalendar currentCalendar] 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | /** 15 | Provides extensions method for `NSDate`. 16 | */ 17 | @interface NSDate (HZExtend) 18 | 19 | #pragma mark - Properties 20 | ///============================================================================= 21 | /// @name Properties 22 | ///============================================================================= 23 | 24 | /** The number of timestamp for the receiver. */ 25 | @property(nonatomic, readonly) NSUInteger timeStamp; 26 | 27 | /** The number of Year units for the receiver. */ 28 | @property (nonatomic, readonly) NSInteger year; 29 | 30 | /** The number of Month units for the receiver (1~12). */ 31 | @property (nonatomic, readonly) NSInteger month; 32 | 33 | /** The number of Day units for the receiver (1~31). */ 34 | @property (nonatomic, readonly) NSInteger day; 35 | 36 | /** The number of Hour units for the receiver (0~23). */ 37 | @property (nonatomic, readonly) NSInteger hour; 38 | 39 | /** The number of Minute units for the receiver (0~59). */ 40 | @property (nonatomic, readonly) NSInteger minute; 41 | 42 | /** The number of Second units for the receiver (0~59). */ 43 | @property (nonatomic, readonly) NSInteger second; 44 | 45 | /** The number of Nanosecond units for the receiver (0~999). */ 46 | @property (nonatomic, readonly) NSInteger nanosecond; 47 | 48 | /** The number of Weekday units for the receiver (1~7, first day is based on user setting). */ 49 | @property (nonatomic, readonly) NSInteger weekday; 50 | 51 | /** The ordinal number of weekday units for the receiver (1~5). */ 52 | @property (nonatomic, readonly) NSInteger weekdayOrdinal; 53 | 54 | /** The week number of the month for the receiver (1~5). */ 55 | @property (nonatomic, readonly) NSInteger weekOfMonth; 56 | 57 | /** The week number of the year for the receiver (1~53). */ 58 | @property (nonatomic, readonly) NSInteger weekOfYear; 59 | 60 | /** The ISO 8601 week-numbering year of the receiver. */ 61 | @property (nonatomic, readonly) NSInteger yearForWeekOfYear; 62 | 63 | /** The number of quarters for the receiver. */ 64 | @property (nonatomic, readonly) NSInteger quarter; 65 | 66 | /** Boolean value that indicates whether the month is a leap month. */ 67 | @property (nonatomic, readonly) BOOL isLeapMonth; 68 | 69 | /** Boolean value that indicates whether the month is a leap year. */ 70 | @property (nonatomic, readonly) BOOL isLeapYear; 71 | 72 | 73 | #pragma mark - Date modify 74 | ///============================================================================= 75 | /// @name Date modify 76 | ///============================================================================= 77 | 78 | /** 79 | Returns a date representing the receiver date shifted later by the provided number of seconds. 80 | 81 | @param seconds Number of seconds to add. 82 | */ 83 | - (nullable NSDate *)dateByAddingSeconds:(NSInteger)seconds; 84 | 85 | /** 86 | Returns a date representing the receiver date shifted later by the provided number of minutes. 87 | 88 | @param minutes Number of minutes to add. 89 | */ 90 | - (nullable NSDate *)dateByAddingMinutes:(NSInteger)minutes; 91 | 92 | /** 93 | Returns a date representing the receiver date shifted later by the provided number of hours. 94 | 95 | @param hours Number of hours to add. 96 | */ 97 | - (nullable NSDate *)dateByAddingHours:(NSInteger)hours; 98 | 99 | /** 100 | Returns a date representing the receiver date shifted later by the provided number of days. 101 | 102 | @param days Number of days to add. 103 | */ 104 | - (nullable NSDate *)dateByAddingDays:(NSInteger)days; 105 | 106 | /** 107 | Returns a date representing the receiver date shifted later by the provided number of weeks. 108 | 109 | @param weeks Number of weeks to add. 110 | */ 111 | - (nullable NSDate *)dateByAddingWeeks:(NSInteger)weeks; 112 | 113 | /** 114 | Returns a date representing the receiver date shifted later by the provided number of months. 115 | 116 | @param months Number of months to add. 117 | */ 118 | - (nullable NSDate *)dateByAddingMonths:(NSInteger)months; 119 | 120 | /** 121 | Returns a date representing the receiver date shifted later by the provided number of years. 122 | 123 | @param years Number of years to add. 124 | */ 125 | - (nullable NSDate *)dateByAddingYears:(NSInteger)years; 126 | 127 | 128 | #pragma mark - Convert 129 | ///============================================================================= 130 | /// @name Convert 131 | ///============================================================================= 132 | 133 | /** 134 | Returns a date parsed from given string interpreted using the format. 135 | 136 | @param dateString The string to parse. 137 | @param format The string's date format. 138 | 139 | @return A date representation of string interpreted using the format. 140 | If can not parse the string, returns nil. 141 | */ 142 | + (nullable NSDate *)dateWithString:(NSString *)dateString format:(NSString *)format; 143 | 144 | /** 145 | Return a formate date string using the separator. e.g 2017-08-08 146 | */ 147 | - (NSString *)formatDateWithSeparator:(NSString *)separator; 148 | 149 | /** 150 | Return a formate time string using the separator. e.g 08:08 151 | */ 152 | - (NSString *)formatTimeWithSeparator:(NSString *)separator; 153 | 154 | /** 155 | Returns current timestamp. 156 | */ 157 | + (NSUInteger)timeStamp; 158 | 159 | /** 160 | Return a Boolean value that indicates whether the data within today. 161 | */ 162 | - (BOOL)isInToday; 163 | 164 | /** 165 | Return a Boolean value that indicates whether the data within yesterday. 166 | */ 167 | - (BOOL)isInYesterday; 168 | 169 | /** 170 | Return a Boolean value that indicates whether the data within tomorrow. 171 | */ 172 | - (BOOL)isInTomorrow; 173 | 174 | /** 175 | Return a Boolean value that indicates whether the data within current week. 176 | */ 177 | - (BOOL)isInThisWeek; 178 | 179 | /** 180 | Return a Boolean value that indicates whether the data within current month. 181 | */ 182 | - (BOOL)isInThisMonth; 183 | 184 | /** 185 | Return a Boolean value that indicates whether the data within current year. 186 | */ 187 | - (BOOL)isInThisYear; 188 | 189 | 190 | @end 191 | 192 | NS_ASSUME_NONNULL_END 193 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSDate+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+HZExtend.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2017/2/17. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "NSDate+HZExtend.h" 10 | #import "NSObject+HZExtend.h" 11 | @implementation NSDate (HZExtend) 12 | 13 | #pragma mark - Properties 14 | #define DATE_COMPONENT(_type_, _conponent_) [[[NSCalendar currentCalendar] components:_type_ fromDate:self] _conponent_] 15 | - (NSInteger)year { return DATE_COMPONENT(NSCalendarUnitYear, year); } 16 | - (NSInteger)month { return DATE_COMPONENT(NSCalendarUnitMonth, month); } 17 | - (NSInteger)hour{ return DATE_COMPONENT(NSCalendarUnitHour, hour); } 18 | - (NSInteger)day{ return DATE_COMPONENT(NSCalendarUnitDay, day); } 19 | - (NSInteger)minute{ return DATE_COMPONENT(NSCalendarUnitMinute, minute); } 20 | - (NSInteger)second{ return DATE_COMPONENT(NSCalendarUnitSecond, second); } 21 | - (NSInteger)nanosecond{ return DATE_COMPONENT(NSCalendarUnitNanosecond, nanosecond); } 22 | - (NSInteger)weekday{ return DATE_COMPONENT(NSCalendarUnitNanosecond, nanosecond);} 23 | - (NSInteger)weekdayOrdinal{ return DATE_COMPONENT(NSCalendarUnitNanosecond, nanosecond); } 24 | - (NSInteger)weekOfYear{ return DATE_COMPONENT(NSCalendarUnitNanosecond, nanosecond); } 25 | - (NSInteger)weekOfMonth{ return DATE_COMPONENT(NSCalendarUnitWeekOfMonth, weekOfMonth); } 26 | - (NSInteger)yearForWeekOfYear{ return DATE_COMPONENT(NSCalendarUnitYearForWeekOfYear, yearForWeekOfYear);} 27 | - (NSInteger)quarter{ return DATE_COMPONENT(NSCalendarUnitQuarter, quarter); } 28 | - (BOOL)isLeapMonth{ return DATE_COMPONENT(NSCalendarUnitMonth, isLeapMonth); } 29 | - (BOOL)isLeapYear 30 | { 31 | NSUInteger year = self.year; 32 | return ((year % 400 == 0) || ((year % 100 != 0) && (year % 4 == 0))); 33 | } 34 | 35 | 36 | - (NSUInteger)timeStamp 37 | { 38 | return (NSUInteger)self.timeIntervalSince1970; 39 | } 40 | 41 | #pragma mark - Date modify 42 | - (NSDate *)dateByAddingYears:(NSInteger)years { 43 | NSCalendar *calendar = [NSCalendar currentCalendar]; 44 | NSDateComponents *components = [[NSDateComponents alloc] init]; 45 | [components setYear:years]; 46 | return [calendar dateByAddingComponents:components toDate:self options:0]; 47 | } 48 | 49 | - (NSDate *)dateByAddingMonths:(NSInteger)months { 50 | NSCalendar *calendar = [NSCalendar currentCalendar]; 51 | NSDateComponents *components = [[NSDateComponents alloc] init]; 52 | [components setMonth:months]; 53 | return [calendar dateByAddingComponents:components toDate:self options:0]; 54 | } 55 | 56 | - (NSDate *)dateByAddingWeeks:(NSInteger)weeks { 57 | NSCalendar *calendar = [NSCalendar currentCalendar]; 58 | NSDateComponents *components = [[NSDateComponents alloc] init]; 59 | [components setWeekOfYear:weeks]; 60 | return [calendar dateByAddingComponents:components toDate:self options:0]; 61 | } 62 | 63 | - (NSDate *)dateByAddingDays:(NSInteger)days { 64 | NSTimeInterval aTimeInterval = [self timeIntervalSinceReferenceDate] + 86400 * days; 65 | NSDate *newDate = [NSDate dateWithTimeIntervalSinceReferenceDate:aTimeInterval]; 66 | return newDate; 67 | } 68 | 69 | - (NSDate *)dateByAddingHours:(NSInteger)hours { 70 | NSTimeInterval aTimeInterval = [self timeIntervalSinceReferenceDate] + 3600 * hours; 71 | NSDate *newDate = [NSDate dateWithTimeIntervalSinceReferenceDate:aTimeInterval]; 72 | return newDate; 73 | } 74 | 75 | - (NSDate *)dateByAddingMinutes:(NSInteger)minutes { 76 | NSTimeInterval aTimeInterval = [self timeIntervalSinceReferenceDate] + 60 * minutes; 77 | NSDate *newDate = [NSDate dateWithTimeIntervalSinceReferenceDate:aTimeInterval]; 78 | return newDate; 79 | } 80 | 81 | - (NSDate *)dateByAddingSeconds:(NSInteger)seconds { 82 | NSTimeInterval aTimeInterval = [self timeIntervalSinceReferenceDate] + seconds; 83 | NSDate *newDate = [NSDate dateWithTimeIntervalSinceReferenceDate:aTimeInterval]; 84 | return newDate; 85 | } 86 | 87 | #pragma mark Range 88 | - (BOOL)isInToday 89 | { 90 | return [CURRENT_CALENDAR isDateInToday:self]; 91 | } 92 | 93 | - (BOOL)isInTomorrow 94 | { 95 | return [CURRENT_CALENDAR isDateInTomorrow:self]; 96 | } 97 | 98 | - (BOOL)isInYesterday 99 | { 100 | return [CURRENT_CALENDAR isDateInYesterday:self]; 101 | } 102 | 103 | - (BOOL)isInThisMonth 104 | { 105 | NSDateComponents *nowComponents = [CURRENT_CALENDAR components:NSCalendarUnitMonth fromDate:[NSDate date]]; 106 | NSDateComponents *selfComponents = [CURRENT_CALENDAR components:NSCalendarUnitMonth fromDate:self]; 107 | return nowComponents.month == selfComponents.month; 108 | } 109 | 110 | - (BOOL)isInThisWeek 111 | { 112 | NSDateComponents *nowComponents = [CURRENT_CALENDAR components:NSCalendarUnitWeekOfYear fromDate:[NSDate date]]; 113 | NSDateComponents *selfComponents = [CURRENT_CALENDAR components:NSCalendarUnitWeekOfYear fromDate:self]; 114 | return nowComponents.weekOfYear == selfComponents.weekOfYear; 115 | } 116 | 117 | - (BOOL)isInThisYear 118 | { 119 | NSDateComponents *nowComponents = [CURRENT_CALENDAR components:NSCalendarUnitYear fromDate:[NSDate date]]; 120 | NSDateComponents *selfComponents = [CURRENT_CALENDAR components:NSCalendarUnitYear fromDate:self]; 121 | 122 | return nowComponents.year == selfComponents.year; 123 | } 124 | 125 | #pragma mark Convert 126 | + (NSDate *)dateWithString:(NSString *)dateString format:(NSString *)format 127 | { 128 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 129 | [formatter setDateFormat:format]; 130 | return [formatter dateFromString:dateString]; 131 | } 132 | 133 | - (NSString *)formatDateWithSeparator:(NSString *)separator 134 | { 135 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 136 | [formatter setDateFormat:[NSString stringWithFormat:@"yyyy%@MM%@dd",separator,separator]]; 137 | return [formatter stringFromDate:self]; 138 | } 139 | 140 | - (NSString *)formatTimeWithSeparator:(NSString *)separator 141 | { 142 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 143 | [formatter setDateFormat:[NSString stringWithFormat:@"HH%@mm",separator]]; 144 | return [formatter stringFromDate:self]; 145 | } 146 | 147 | + (NSUInteger)timeStamp 148 | { 149 | return [[[NSDate alloc] init] timeStamp]; 150 | } 151 | 152 | 153 | @end 154 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSDictionary+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+HZExtend.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/7/26. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSObject+HZExtend.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | /** 15 | Provides extensions method for `NSDictionary`. 16 | */ 17 | @interface NSDictionary (HZExtend) 18 | 19 | /** 20 | Returns the Object specified by the given keyPath. 21 | 22 | @param keyPath A key path of the form relationship.property (with one or more relationships); for example “department.name” or “department.manager.lastName”. 23 | */ 24 | - (nullable id)objectForKeyPath:(NSString *)keyPath; 25 | 26 | /** 27 | Returns the Object specified by the given keyPath. return def object if no object is found. 28 | 29 | @param keyPath A key path of the form relationship.property (with one or more relationships); for example “department.name” or “department.manager.lastName”. 30 | @param def Returns def if no object is found. 31 | */ 32 | - (nullable id)objectForKeyPath:(NSString *)keyPath otherwise:(id)def; 33 | 34 | /** 35 | Returns the integer value specified by the given keyPath. return def if no value is found. 36 | 37 | @param keyPath A key path of the form relationship.property (with one or more relationships); for example “department.name” or “department.manager.lastName”. 38 | @param def Returns def if no object is found. 39 | */ 40 | - (NSInteger)integerValueForKeyPath:(NSString *)keyPath def:(NSInteger)def; 41 | 42 | /** 43 | Returns the double value specified by the given keyPath. return def if no value is found. 44 | 45 | @param keyPath A key path of the form relationship.property (with one or more relationships); for example “department.name” or “department.manager.lastName”. 46 | @param def Returns def if no object is found. 47 | */ 48 | - (double)doubleValueForKeyPath:(NSString *)keyPath def:(double)def; 49 | - (float)floatValueForKey:(NSString *)keyPath def:(float)def; 50 | 51 | /** 52 | Returns the bool value specified by the given keyPath. return def if no value is found. 53 | 54 | @param keyPath A key path of the form relationship.property (with one or more relationships); for example “department.name” or “department.manager.lastName”. 55 | @param def Returns def if no object is found. 56 | */ 57 | - (BOOL)boolValueForKeyPath:(NSString *)keyPath def:(BOOL)def; 58 | 59 | /** 60 | Returns the long long value specified by the given keyPath. return def if no value is found. 61 | 62 | @param keyPath A key path of the form relationship.property (with one or more relationships); for example “department.name” or “department.manager.lastName”. 63 | @param def Returns def if no object is found. 64 | */ 65 | - (long)longLongValueForKey:(NSString *)keyPath def:(long)def; 66 | 67 | 68 | /** 69 | Returns a new dictionary containing the entries for keys. 70 | return nil if the keys is empty or nil. 71 | 72 | @param keys The keys. 73 | */ 74 | - (nullable NSDictionary *)entriesForKeys:(NSArray *)keys; 75 | 76 | /** 77 | Returns a string in key1=value1&key2=value2... format. return nil if an empty dictionary. 78 | */ 79 | - (nullable NSString *)keyValueString; 80 | 81 | /** 82 | Converts dictionary to json string. return nil if an error occurs. 83 | */ 84 | - (nullable NSString *)jsonString; 85 | 86 | 87 | @end 88 | 89 | NS_ASSUME_NONNULL_END 90 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSDictionary+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+HZExtend.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/7/26. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "NSDictionary+HZExtend.h" 10 | 11 | @implementation NSDictionary (HZExtend) 12 | 13 | - (id)objectForKeyPath:(NSString *)keyPath 14 | { 15 | if (!keyPath.isNoEmpty) return nil; 16 | 17 | NSArray * array = [keyPath componentsSeparatedByString:@"."]; 18 | if ( 0 == array.count ) return nil; 19 | 20 | NSObject * result = nil; 21 | NSDictionary * dict = self; 22 | 23 | for (NSString * subPath in array ) 24 | { 25 | if (0 == subPath.length) continue; 26 | 27 | result = [dict objectForKey:subPath]; 28 | 29 | if ([result isKindOfClass:[NSDictionary class]]) { 30 | dict = (NSDictionary *)result; 31 | continue; 32 | }else if([array lastObject] == subPath){ 33 | return result; 34 | }else { 35 | return nil; 36 | } 37 | } 38 | 39 | return [result isKindOfClass:[NSNull class]]?nil:result; 40 | } 41 | 42 | - (id)objectForKeyPath:(NSString *)keyPath otherwise:(id)other 43 | { 44 | NSObject *obj = [self objectForKeyPath:keyPath]; 45 | 46 | if ([obj isKindOfClass:[NSNull class]] || obj == nil) { 47 | return other; 48 | } 49 | 50 | return obj; 51 | } 52 | 53 | - (NSDictionary *)entriesForKeys:(NSArray *)keys 54 | { 55 | NSMutableDictionary *dic = [NSMutableDictionary dictionary]; 56 | for (id key in keys) { 57 | id value = self[key]; 58 | if (value) dic[key] = value; 59 | } 60 | return dic; 61 | } 62 | 63 | - (NSString *)keyValueString 64 | { 65 | if (!self.isNoEmpty) return nil; 66 | 67 | NSMutableString *string = [NSMutableString string]; 68 | [self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { 69 | [string appendFormat:@"%@=%@&",key,obj]; 70 | }]; 71 | 72 | NSRange range = [string rangeOfString:@"&" options:NSBackwardsSearch]; 73 | [string deleteCharactersInRange:range]; 74 | 75 | return string; 76 | } 77 | 78 | - (NSString *)jsonString 79 | { 80 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self options:0 error:nil]; 81 | return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; 82 | } 83 | 84 | - (NSInteger)integerValueForKeyPath:(NSString *)keyPath def:(NSInteger)def 85 | { 86 | id value = [self objectForKeyPath:keyPath]; 87 | 88 | if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]]) { 89 | return [value integerValue]; 90 | }else { 91 | return def; 92 | } 93 | } 94 | 95 | - (long)longLongValueForKey:(NSString *)keyPath def:(long)def 96 | { 97 | id value = [self objectForKeyPath:keyPath]; 98 | 99 | if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]]) { 100 | return [value longLongValue]; 101 | }else { 102 | return def; 103 | } 104 | } 105 | 106 | - (BOOL)boolValueForKeyPath:(NSString *)keyPath def:(BOOL)def 107 | { 108 | id value = [self objectForKeyPath:keyPath]; 109 | 110 | if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]]) { 111 | return [value boolValue]; 112 | }else { 113 | return def; 114 | } 115 | } 116 | 117 | - (double)doubleValueForKeyPath:(NSString *)keyPath def:(double)def 118 | { 119 | id value = [self objectForKeyPath:keyPath]; 120 | 121 | if ([value isKindOfClass:[NSNumber class]]) { 122 | return [value doubleValue]; 123 | }else { 124 | return def; 125 | } 126 | } 127 | 128 | - (float)floatValueForKey:(NSString *)keyPath def:(float)def 129 | { 130 | id value = [self objectForKeyPath:keyPath]; 131 | 132 | if ([value isKindOfClass:[NSNumber class]]) { 133 | return [value floatValue]; 134 | }else { 135 | return def; 136 | } 137 | } 138 | 139 | @end 140 | 141 | @implementation NSMutableDictionary (HZExtend) 142 | 143 | 144 | @end 145 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSObject+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+HZExtend.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/7/26. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | /** 13 | Provides extensions method for `NSObject`. 14 | */ 15 | @interface NSObject (HZExtend) 16 | 17 | /** 18 | Returns a BOOL value tells if the object is no empty. 19 | NSArray/NString/NSDictionary/NSData 20 | 21 | */ 22 | - (BOOL)isNoEmpty; 23 | 24 | /** 25 | Swap two instance method's implementation in one class. 26 | 27 | @param originalSel Selector 1. 28 | @param newSel Selector 2. 29 | @return YES if swizzling succeed, otherwise, NO. 30 | */ 31 | + (BOOL)swizzleInstanceMethod:(SEL)originalSel with:(SEL)newSel; 32 | 33 | 34 | /** 35 | Swap two class method's implementation in one class. 36 | 37 | @param originalSel Selector 1. 38 | @param newSel Selector 2. 39 | @return YES if swizzling succeed, otherwise, NO. 40 | */ 41 | + (BOOL)swizzleClassMethod:(SEL)originalSel with:(SEL)newSel; 42 | 43 | @end 44 | 45 | NS_ASSUME_NONNULL_END 46 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSObject+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+HZExtend.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/7/26. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "NSObject+HZExtend.h" 10 | #import 11 | #import 12 | 13 | @implementation NSObject (HZExtend) 14 | 15 | - (BOOL)isNoEmpty 16 | { 17 | if ([self isKindOfClass:[NSNull class]]) 18 | { 19 | return NO; 20 | } 21 | else if ([self isKindOfClass:[NSString class]]) 22 | { 23 | return [(NSString *)self length] > 0; 24 | } 25 | else if ([self isKindOfClass:[NSData class]]) 26 | { 27 | 28 | return [(NSData *)self length] > 0; 29 | } 30 | else if ([self isKindOfClass:[NSArray class]]) 31 | { 32 | 33 | return [(NSArray *)self count] > 0; 34 | } 35 | else if ([self isKindOfClass:[NSDictionary class]]) 36 | { 37 | 38 | return [(NSDictionary *)self count] > 0; 39 | } 40 | 41 | return YES; 42 | } 43 | 44 | + (BOOL)swizzleInstanceMethod:(SEL)originalSel with:(SEL)newSel 45 | { 46 | Method originalMethod = class_getInstanceMethod(self, originalSel); 47 | Method newMethod = class_getInstanceMethod(self, newSel); 48 | if (!originalMethod || !newMethod) return NO; 49 | 50 | class_addMethod(self, 51 | originalSel, 52 | class_getMethodImplementation(self, originalSel), 53 | method_getTypeEncoding(originalMethod)); 54 | class_addMethod(self, 55 | newSel, 56 | class_getMethodImplementation(self, newSel), 57 | method_getTypeEncoding(newMethod)); 58 | 59 | method_exchangeImplementations(class_getInstanceMethod(self, originalSel), 60 | class_getInstanceMethod(self, newSel)); 61 | return YES; 62 | } 63 | 64 | + (BOOL)swizzleClassMethod:(SEL)originalSel with:(SEL)newSel 65 | { 66 | Class class = object_getClass(self); 67 | Method originalMethod = class_getInstanceMethod(class, originalSel); 68 | Method newMethod = class_getInstanceMethod(class, newSel); 69 | if (!originalMethod || !newMethod) return NO; 70 | method_exchangeImplementations(originalMethod, newMethod); 71 | return YES; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSObject+HZKVO.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+HZKVO.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2017/8/9. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | typedef void(^HZKVOBlock)(id obj,id oldVal, id newVal); 13 | /** 14 | Observer with block (KVO). 15 | */ 16 | @interface NSObject (HZKVO) 17 | 18 | /** 19 | Registers a block to receive KVO notifications for the specified key-path 20 | relative to the receiver. 21 | 22 | @discussion The block and block captured objects are retained. Call 23 | `removeObserverBlocksForKeyPath:` or `removeObserverBlocks` to release. 24 | 25 | @param keyPath The key path, relative to the receiver, of the property to 26 | observe. This value must not be nil. 27 | @param options A combination of the NSKeyValueObservingOptions values that specifies what is included in observation notifications. For possible values, see NSKeyValueObservingOptions. 28 | @param block The block to register for KVO notifications. 29 | */ 30 | - (void)addObserverBlockForKeyPath:(NSString *)keyPath 31 | options:(NSKeyValueObservingOptions)options 32 | block:(HZKVOBlock)block; 33 | 34 | /** 35 | Stops all blocks (associated by `addObserverBlockForKeyPath:block:`) from 36 | receiving change notifications for the property specified by a given key-path 37 | relative to the receiver, and release these blocks. 38 | 39 | @param keyPath A key-path, relative to the receiver, for which blocks is 40 | registered to receive KVO change notifications. 41 | */ 42 | - (void)removeObserverBlocksForKeyPath:(NSString*)keyPath; 43 | 44 | /** 45 | Stops all blocks (associated by `addObserverBlockForKeyPath:block:`) from 46 | receiving change notifications, and release these blocks. 47 | */ 48 | - (void)removeObserverBlocks; 49 | 50 | 51 | @end 52 | 53 | NS_ASSUME_NONNULL_END 54 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSObject+HZKVO.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+HZKVO.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2017/8/9. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "NSObject+HZKVO.h" 10 | #import 11 | #import "NSObject+HZExtend.h" 12 | 13 | static const int block_key; 14 | 15 | @interface HZNSObjectKVOBlockTarget : NSObject 16 | 17 | @property (nonatomic, copy) HZKVOBlock block; 18 | 19 | - (id)initWithBlock:(HZKVOBlock)block; 20 | 21 | @end 22 | 23 | @implementation HZNSObjectKVOBlockTarget 24 | 25 | - (id)initWithBlock:(HZKVOBlock)block { 26 | self = [super init]; 27 | if (self) { 28 | self.block = block; 29 | } 30 | return self; 31 | } 32 | 33 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 34 | if (!self.block) return; 35 | 36 | NSKeyValueChange changeKind = [[change objectForKey:NSKeyValueChangeKindKey] integerValue]; 37 | if (changeKind != NSKeyValueChangeSetting) return; 38 | 39 | id oldVal = [change objectForKey:NSKeyValueChangeOldKey]; 40 | if (oldVal == [NSNull null]) oldVal = nil; 41 | 42 | id newVal = [change objectForKey:NSKeyValueChangeNewKey]; 43 | if (newVal == [NSNull null]) newVal = nil; 44 | 45 | self.block(object, oldVal, newVal); 46 | } 47 | 48 | @end 49 | 50 | 51 | @implementation NSObject (HZKVO) 52 | 53 | - (void)addObserverBlockForKeyPath:(NSString *)keyPath 54 | options:(NSKeyValueObservingOptions)options 55 | block:(nonnull HZKVOBlock)block 56 | { 57 | if (!keyPath.isNoEmpty || !block) return; 58 | 59 | HZNSObjectKVOBlockTarget *target = [[HZNSObjectKVOBlockTarget alloc] initWithBlock:block]; 60 | NSMutableDictionary *dic = [self allNSObjectObserverBlocks]; 61 | NSMutableArray *arr = dic[keyPath]; 62 | if (!arr) { 63 | arr = [NSMutableArray new]; 64 | dic[keyPath] = arr; 65 | } 66 | [arr addObject:target]; 67 | [self addObserver:target forKeyPath:keyPath options:options context:NULL]; 68 | } 69 | 70 | - (void)removeObserverBlocksForKeyPath:(NSString *)keyPath 71 | { 72 | if (!keyPath) return; 73 | NSMutableDictionary *dic = [self allNSObjectObserverBlocks]; 74 | NSMutableArray *arr = dic[keyPath]; 75 | [arr enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) { 76 | [self removeObserver:obj forKeyPath:keyPath]; 77 | }]; 78 | 79 | [dic removeObjectForKey:keyPath]; 80 | } 81 | 82 | - (void)removeObserverBlocks { 83 | NSMutableDictionary *dic = [self allNSObjectObserverBlocks]; 84 | [dic enumerateKeysAndObjectsUsingBlock: ^(NSString *key, NSArray *arr, BOOL *stop) { 85 | [arr enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) { 86 | [self removeObserver:obj forKeyPath:key]; 87 | }]; 88 | }]; 89 | 90 | [dic removeAllObjects]; 91 | } 92 | 93 | - (NSMutableDictionary *)allNSObjectObserverBlocks { 94 | NSMutableDictionary *targets = objc_getAssociatedObject(self, &block_key); 95 | if (!targets) { 96 | targets = [NSMutableDictionary new]; 97 | objc_setAssociatedObject(self, &block_key, targets, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 98 | } 99 | return targets; 100 | } 101 | 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSString+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+HZExtend.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/7/20. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSObject+HZExtend.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | /** 14 | Provides extensions method for `NSString`. 15 | */ 16 | @interface NSString (HZExtend) 17 | 18 | /** 19 | Trim blank characters (space and newline) in head and tail. 20 | 21 | @return the trimmed string. 22 | */ 23 | - (NSString *)stringByTrim; 24 | 25 | /** 26 | Returns a NSString for md5 hash. 27 | */ 28 | - (NSString *)md5String; 29 | 30 | /** 31 | Returns a new UUID NSString. e.g. "C3278C30-2B3D-4E1E-7AC2-B6FFB24A07C1" 32 | */ 33 | + (NSString *)UUIDString; 34 | 35 | /** 36 | URL encode a string in utf-8. 37 | 38 | @return the encode string. 39 | */ 40 | - (NSString *)urlEncode; 41 | 42 | /** 43 | URL decode a string in utf-8. 44 | 45 | @return the decoded string. 46 | */ 47 | - (NSString *)urlDecode; 48 | 49 | /** 50 | Returns a new string made by appending a given query keyValue string to the receiver. 51 | */ 52 | - (NSString *)urlAppendingKeyValue:(NSString *)keyValue; 53 | 54 | /** 55 | Converts json string to json object. return nil if an error occurs. 56 | NSArray/NSDictionary 57 | */ 58 | - (nullable id)jsonObject; 59 | 60 | /** 61 | Whether it can match the regular expression. 62 | 63 | @param regex The regular expression 64 | @param options The matching options to report. 65 | @return YES if can match the regex; otherwise, NO. 66 | */ 67 | - (BOOL)matchesRegx:(NSString *)regex options:(NSRegularExpressionOptions)options; 68 | 69 | /** 70 | Match the regular expression, and executes a given block using each object in the matches. 71 | 72 | @param regex The regular expression 73 | @param options The matching options to report. 74 | @param block The block to apply to elements in the array of matches. 75 | */ 76 | 77 | - (void)enumerateRegexMatches:(NSString *)regex 78 | options:(NSRegularExpressionOptions)options 79 | usingBlock:(void (^)(NSString *match, NSRange matchRange, BOOL *stop))block; 80 | 81 | /** 82 | Returns a new string containing matching regular expressions replaced with the template string. 83 | 84 | @param regex The regular expression 85 | @param options The matching options to report. 86 | @param replacement The substitution template used when replacing matching instances. 87 | 88 | @return A string with matching regular expressions replaced by the template string. 89 | */ 90 | - (NSString *)stringByReplacingRegex:(NSString *)regex 91 | options:(NSRegularExpressionOptions)options 92 | withString:(NSString *)replacement; 93 | 94 | /** 95 | Returns NSMakeRange(0, self.length). 96 | */ 97 | - (NSRange)rangeOfAll; 98 | 99 | 100 | @end 101 | 102 | NS_ASSUME_NONNULL_END 103 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSString+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+HZExtend.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/7/20. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | 10 | #import "NSString+HZExtend.h" 11 | #import "NSData+HZExtend.h" 12 | @implementation NSString (HZExtend) 13 | 14 | - (NSString *)stringByTrim 15 | { 16 | NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet]; 17 | return [self stringByTrimmingCharactersInSet:set]; 18 | } 19 | 20 | - (NSRange)rangeOfAll 21 | { 22 | return NSMakeRange(0, self.length); 23 | } 24 | 25 | #pragma mark - URL 26 | - (NSString *)urlEncode 27 | { 28 | return [self stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"-_.!*'();:@$,[]"]]; 29 | } 30 | 31 | - (NSString *)urlDecode 32 | { 33 | return [self stringByRemovingPercentEncoding]; 34 | } 35 | 36 | - (NSString *)urlAppendingKeyValue:(NSString *)keyValue 37 | { 38 | NSString *separator = [self rangeOfString:@"?"].length == 0?@"?":@"&"; 39 | return [self stringByAppendingFormat:@"%@%@",separator,keyValue]; 40 | } 41 | 42 | - (NSString *)md5String 43 | { 44 | NSData *value = [[NSData dataWithBytes:[self UTF8String] length:[self length]] md5Data]; 45 | 46 | char tmp[16]; 47 | unsigned char * hex = (unsigned char *)malloc( 2048 + 1 ); 48 | unsigned char * bytes = (unsigned char *)[value bytes]; 49 | unsigned long length = [value length]; 50 | 51 | hex[0] = '\0'; 52 | 53 | for ( unsigned long i = 0; i < length; ++i ) 54 | { 55 | sprintf( tmp, "%02X", bytes[i] ); 56 | strcat( (char *)hex, tmp ); 57 | } 58 | 59 | NSString * result = [NSString stringWithUTF8String:(const char *)hex]; 60 | free( hex ); 61 | return result; 62 | } 63 | 64 | - (id)jsonObject 65 | { 66 | return [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:nil]; 67 | } 68 | 69 | - (BOOL)matchesRegx:(NSString *)regex options:(NSRegularExpressionOptions)options 70 | { 71 | if (!regex.isNoEmpty) return NO; 72 | 73 | NSError *error; 74 | NSRegularExpression *rx = [NSRegularExpression regularExpressionWithPattern:regex options:options error:&error]; 75 | if (error) return NO; 76 | 77 | NSRange range = [rx rangeOfFirstMatchInString:self options:0 range:NSMakeRange(0, self.length)]; 78 | return range.length != 0; 79 | } 80 | 81 | - (void)enumerateRegexMatches:(NSString *)regex options:(NSRegularExpressionOptions)options usingBlock:(void (^)(NSString * _Nonnull, NSRange, BOOL * _Nonnull))block 82 | { 83 | NSRegularExpression *regExp = [NSRegularExpression regularExpressionWithPattern:regex options:options error:nil]; 84 | if (!regExp) return; 85 | [regExp enumerateMatchesInString:self options:kNilOptions range:NSMakeRange(0, self.length) usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) { 86 | block([self substringWithRange:result.range], result.range, stop); 87 | }]; 88 | } 89 | 90 | - (NSString *)stringByReplacingRegex:(NSString *)regex options:(NSRegularExpressionOptions)options withString:(NSString *)replacement 91 | { 92 | NSRegularExpression *pattern = [NSRegularExpression regularExpressionWithPattern:regex options:options error:nil]; 93 | if (!pattern) return self; 94 | return [pattern stringByReplacingMatchesInString:self options:0 range:NSMakeRange(0, [self length]) withTemplate:replacement]; 95 | } 96 | 97 | + (NSString *)UUIDString 98 | { 99 | CFUUIDRef uuid = CFUUIDCreate(NULL); 100 | CFStringRef string = CFUUIDCreateString(NULL, uuid); 101 | CFRelease(uuid); 102 | return (__bridge_transfer NSString *)string; 103 | } 104 | 105 | 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSTimer+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSTimer+HZExtend.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2017/8/4. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | /** 14 | Provides extensions for `NSTimer`. 15 | */ 16 | @interface NSTimer (HZExtend) 17 | 18 | /** 19 | Creates and returns a new NSTimer object and schedules it on the current run 20 | loop in the default mode. 21 | 22 | @discussion After seconds seconds have elapsed, the timer fires, 23 | sending the message aSelector to target. 24 | 25 | @param seconds The number of seconds between firings of the timer. If seconds 26 | is less than or equal to 0.0, this method chooses the 27 | nonnegative value of 0.1 milliseconds instead. 28 | 29 | @param block The block to invoke when the timer fires. The timer maintains 30 | a strong reference to the block until it (the timer) is invalidated. 31 | 32 | @param repeats If YES, the timer will repeatedly reschedule itself until 33 | invalidated. If NO, the timer will be invalidated after it fires. 34 | 35 | @return A new NSTimer object, configured according to the specified parameters. 36 | */ 37 | + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds block:(void (^)(NSTimer *timer))block repeats:(BOOL)repeats; 38 | 39 | /** 40 | Creates and returns a new NSTimer object initialized with the specified block. 41 | 42 | @discussion You must add the new timer to a run loop, using addTimer:forMode:. 43 | Then, after seconds have elapsed, the timer fires, invoking 44 | block. (If the timer is configured to repeat, there is no need 45 | to subsequently re-add the timer to the run loop.) 46 | 47 | @param seconds The number of seconds between firings of the timer. If seconds 48 | is less than or equal to 0.0, this method chooses the 49 | nonnegative value of 0.1 milliseconds instead. 50 | 51 | @param block The block to invoke when the timer fires. The timer instructs 52 | the block to maintain a strong reference to its arguments. 53 | 54 | @param repeats If YES, the timer will repeatedly reschedule itself until 55 | invalidated. If NO, the timer will be invalidated after it fires. 56 | 57 | @return A new NSTimer object, configured according to the specified parameters. 58 | */ 59 | + (NSTimer *)timerWithTimeInterval:(NSTimeInterval)seconds block:(void (^)(NSTimer *timer))block repeats:(BOOL)repeats; 60 | 61 | @end 62 | 63 | NS_ASSUME_NONNULL_END 64 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSTimer+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSTimer+HZExtend.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2017/8/4. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "NSTimer+HZExtend.h" 10 | 11 | @implementation NSTimer (HZExtend) 12 | 13 | + (void)fire:(NSTimer *)timer 14 | { 15 | if ([timer userInfo]) { 16 | void (^block)(NSTimer *timer) = (void (^)(NSTimer *timer))[timer userInfo]; 17 | block(timer); 18 | } 19 | } 20 | 21 | + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds block:(void (^)(NSTimer * _Nonnull))block repeats:(BOOL)repeats 22 | { 23 | return [NSTimer scheduledTimerWithTimeInterval:seconds target:self selector:@selector(fire:) userInfo:[block copy] repeats:repeats]; 24 | } 25 | 26 | + (NSTimer *)timerWithTimeInterval:(NSTimeInterval)seconds block:(void (^)(NSTimer *timer))block repeats:(BOOL)repeats 27 | { 28 | return [NSTimer timerWithTimeInterval:seconds target:self selector:@selector(fire:) userInfo:[block copy] repeats:repeats]; 29 | } 30 | 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSURL+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSURL+HZExtend.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/8/21. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | /** 12 | Provides extensions method for `NSURL`. 13 | */ 14 | @interface NSURL (HZExtend) 15 | 16 | /** Returns absoluteString but not contain the part of query. */ 17 | @property(nonatomic, readonly) NSString *allPath; 18 | 19 | /** 20 | Return a Dictionary which contains query params 21 | */ 22 | - (nullable NSDictionary *)queryDic; 23 | 24 | 25 | @end 26 | 27 | NS_ASSUME_NONNULL_END 28 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/NSURL+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSURL+HZExtend.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/8/21. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "NSURL+HZExtend.h" 10 | #import "NSString+HZExtend.h" 11 | 12 | @implementation NSURL (HZExtend) 13 | 14 | - (NSString *)allPath 15 | { 16 | NSString *absoluteStr = self.absoluteString; 17 | NSString *keyValues = self.query; 18 | if (keyValues.length > 0) return [absoluteStr stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"?%@",keyValues] withString:@""]; 19 | 20 | return absoluteStr; 21 | } 22 | 23 | - (NSDictionary *)queryDic 24 | { 25 | NSString *keyValues = self.query; 26 | if (!keyValues.isNoEmpty) return nil; 27 | 28 | return [self queryDicWithKeysValues:keyValues]; 29 | } 30 | 31 | 32 | #pragma mark - Private Method 33 | //从k=v中获取键值 34 | - (NSString *)valueFromKeyValue:(NSString *)keyValue atIndex:(NSUInteger)index 35 | { 36 | return [[keyValue componentsSeparatedByString:@"="] objectAtIndex:index]; 37 | } 38 | 39 | - (NSDictionary *)queryDicWithKeysValues:(NSString *)keyValues 40 | { 41 | if (!(keyValues.length > 0)) return @{}; 42 | 43 | NSArray *pairArray = [keyValues componentsSeparatedByString:@"&"]; //键值对字符串 44 | NSMutableDictionary *queryDic= [NSMutableDictionary dictionaryWithCapacity:pairArray.count]; 45 | NSString *key = nil; 46 | NSString *obj = nil; 47 | if (pairArray.count > 1) 48 | { 49 | for (NSString *pair in pairArray) 50 | { 51 | key = [self valueFromKeyValue:pair atIndex:0]; 52 | obj = [self valueFromKeyValue:pair atIndex:1]; 53 | [queryDic setObject:[obj stringByRemovingPercentEncoding] forKey:key]; 54 | } 55 | } 56 | else if (pairArray.count == 1) 57 | { 58 | key = [self valueFromKeyValue:keyValues atIndex:0]; 59 | obj = [self valueFromKeyValue:keyValues atIndex:1]; 60 | [queryDic setObject:[obj stringByRemovingPercentEncoding] forKey:key]; 61 | } 62 | 63 | return queryDic; 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIAlertController+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertController+HZExtend.h 3 | // Pods 4 | // 5 | // Created by xzh on 2017/8/11. 6 | // 7 | // 8 | 9 | #import 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface UIAlertController (HZExtend) 13 | 14 | + (void)showDestructiveActionSheetWithTitle:(NSString *)title 15 | destructiveTitle:(NSString *)destrucTitle 16 | cancleTitle:(NSString *)cancelTitle handler:(void (^ __nullable)(UIAlertAction *action))handler; 17 | 18 | + (void)showDestructiveAlertWithTitle:(NSString *)title 19 | message:(NSString *)message 20 | destructiveTitle:(NSString *)destrucTitle 21 | cancleTitle:(NSString *)cancelTitle handler:(void (^ __nullable)(UIAlertAction *action))handler; 22 | 23 | @end 24 | 25 | NS_ASSUME_NONNULL_END 26 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIAlertController+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertController+HZExtend.m 3 | // Pods 4 | // 5 | // Created by xzh on 2017/8/11. 6 | // 7 | // 8 | 9 | #import "UIAlertController+HZExtend.h" 10 | @implementation UIAlertController (HZExtend) 11 | 12 | #pragma mark - Public Method 13 | + (void)showDestructiveActionSheetWithTitle:(NSString *)title 14 | destructiveTitle:(NSString *)destrucTitle 15 | cancleTitle:(NSString *)cancelTitle 16 | handler:(void (^)(UIAlertAction *))handler 17 | { 18 | [self showAlertWithStyle:UIAlertControllerStyleActionSheet title:title message:@"" destructiveTitle:destrucTitle cancleTitle:cancelTitle handler:handler]; 19 | } 20 | 21 | + (void)showDestructiveAlertWithTitle:(NSString *)title 22 | message:(NSString *)message 23 | destructiveTitle:(NSString *)destrucTitle 24 | cancleTitle:(NSString *)cancelTitle 25 | handler:(void (^)(UIAlertAction * _Nonnull))handler 26 | { 27 | [self showAlertWithStyle:UIAlertControllerStyleAlert title:title message:message destructiveTitle:destrucTitle cancleTitle:cancelTitle handler:handler]; 28 | } 29 | 30 | #pragma mark - Private Method 31 | + (void)showAlertWithStyle:(UIAlertControllerStyle)style 32 | title:(NSString *)title 33 | message:(NSString *)message 34 | destructiveTitle:(NSString *)destrucTitle 35 | cancleTitle:(NSString *)cancelTitle 36 | handler:(void (^)(UIAlertAction *))handler 37 | { 38 | UIAlertController *alerController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:style]; 39 | UIAlertAction *destrucAction = [UIAlertAction actionWithTitle:destrucTitle style:UIAlertActionStyleDestructive handler:handler]; 40 | [alerController addAction:destrucAction]; 41 | 42 | UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:cancelTitle style:UIAlertActionStyleCancel handler:handler]; 43 | [alerController addAction:cancleAction]; 44 | [[self currentViewController] presentViewController:alerController animated:YES completion:nil]; 45 | } 46 | 47 | + (id)applicationDelegate 48 | { 49 | return [UIApplication sharedApplication].delegate; 50 | } 51 | 52 | + (UIViewController *)currentViewController 53 | { 54 | UIViewController* rootViewController = self.applicationDelegate.window.rootViewController; 55 | return [self currentViewControllerFrom:rootViewController]; 56 | } 57 | 58 | + (UIViewController*)currentViewControllerFrom:(UIViewController*)viewController 59 | { 60 | //传入的根节点控制器是导航控制器 61 | if ([viewController isKindOfClass:[UINavigationController class]]) 62 | { 63 | UINavigationController* navigationController = (UINavigationController *)viewController; 64 | return [self currentViewControllerFrom:navigationController.viewControllers.lastObject]; 65 | } 66 | else if([viewController isKindOfClass:[UITabBarController class]]) //传入的根节点控制器是UITabBarController 67 | { 68 | UITabBarController* tabBarController = (UITabBarController *)viewController; 69 | return [self currentViewControllerFrom:tabBarController.selectedViewController]; 70 | } 71 | else if(viewController.presentedViewController != nil) //传入的根节点控制器是被展现出来的控制器 72 | { 73 | return [self currentViewControllerFrom:viewController.presentedViewController]; 74 | } 75 | else 76 | { 77 | return viewController; 78 | } 79 | } 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIApplication+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIApplication+HZExtend.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2017/8/4. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | /** 13 | Provides extensions for `UIApplication`. 14 | */ 15 | @interface UIApplication (HZExtend) 16 | 17 | /** The Path of app's sandbox. */ 18 | @property (nonatomic, readonly) NSURL *rootURL; 19 | @property (nonatomic, readonly) NSString *rootPath; 20 | 21 | /** The Path of "Documents" folder in this app's sandbox. */ 22 | @property (nonatomic, readonly) NSURL *documentsURL; 23 | @property (nonatomic, readonly) NSString *documentsPath; 24 | 25 | /** The Path of "Caches" folder in this app's sandbox. */ 26 | @property (nonatomic, readonly) NSURL *cachesURL; 27 | @property (nonatomic, readonly) NSString *cachesPath; 28 | 29 | /** The Path of "Library" folder in this app's sandbox. */ 30 | @property (nonatomic, readonly) NSURL *libraryURL; 31 | @property (nonatomic, readonly) NSString *libraryPath; 32 | 33 | /** The Path of "tmp" folder in this app's sandbox. */ 34 | @property (nonatomic, readonly) NSURL *tmpURL; 35 | @property (nonatomic, readonly) NSString *tmpPath; 36 | 37 | /** Application's Bundle Name.*/ 38 | @property (nullable, nonatomic, readonly) NSString *appBundleName; 39 | 40 | /** Application's Bundle ID. */ 41 | @property (nullable, nonatomic, readonly) NSString *appBundleID; 42 | 43 | /** Application's Bundle Identifier. */ 44 | @property (nullable, nonatomic, readonly) NSString *appBundleIdentifier; 45 | 46 | /** Application's Version.*/ 47 | @property (nullable, nonatomic, readonly) NSString *appVersion; 48 | 49 | /** Application's Build number. */ 50 | @property (nullable, nonatomic, readonly) NSString *appBuildVersion; 51 | 52 | @end 53 | 54 | NS_ASSUME_NONNULL_END 55 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIApplication+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIApplication+HZExtend.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2017/8/4. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | #import "UIApplication+HZExtend.h" 9 | 10 | @implementation UIApplication (HZExtend) 11 | 12 | #pragma mark - Properties 13 | - (NSString *)rootPath 14 | { 15 | return NSHomeDirectory(); 16 | } 17 | 18 | - (NSURL *)rootURL 19 | { 20 | return [NSURL fileURLWithPath:[self rootPath]]; 21 | } 22 | 23 | - (NSURL *)documentsURL 24 | { 25 | return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; 26 | } 27 | 28 | - (NSString *)documentsPath 29 | { 30 | return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; 31 | } 32 | 33 | - (NSURL *)cachesURL { 34 | return [[[NSFileManager defaultManager] URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask] lastObject]; 35 | } 36 | 37 | - (NSString *)cachesPath 38 | { 39 | return [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]; 40 | } 41 | 42 | - (NSURL *)libraryURL 43 | { 44 | return [[[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject]; 45 | } 46 | 47 | - (NSString *)libraryPath 48 | { 49 | return [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject]; 50 | } 51 | 52 | - (NSURL *)tmpURL 53 | { 54 | return [NSURL fileURLWithPath:[self tmpPath]]; 55 | } 56 | 57 | - (NSString *)tmpPath 58 | { 59 | return NSTemporaryDirectory(); 60 | } 61 | 62 | - (NSString *)appBundleName 63 | { 64 | return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]; 65 | } 66 | 67 | - (NSString *)appBundleID 68 | { 69 | return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"]; 70 | } 71 | 72 | - (NSString *)appBundleIdentifier 73 | { 74 | return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]; 75 | } 76 | 77 | - (NSString *)appVersion 78 | { 79 | return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; 80 | } 81 | 82 | - (NSString *)appBuildVersion 83 | { 84 | return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]; 85 | } 86 | 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIColor+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HZExtend.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2015/7/20. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | /** 12 | Provides extensions method for `UIColor`. 13 | */ 14 | @interface UIColor (HZExtend) 15 | 16 | /** 17 | Creates and returns a color object using the specified RGB hex value. 18 | 19 | @param rgbHex The rgb value such as 0x66CCFF. 20 | 21 | @return The color object. The color information represented by this object is in the device RGB colorspace. 22 | */ 23 | + (UIColor *)colorForHex:(NSInteger)rgbHex; 24 | 25 | /** 26 | Creates and returns a color object using the specified opacity and RGB hex value. 27 | 28 | @param rgbHex The rgb value such as 0x66CCFF. 29 | @param alpha The opacity value of the color object,specified as a value from 0.0 to 1.0. 30 | 31 | @return The color object. The color information represented by this object is in the device RGB colorspace. 32 | */ 33 | + (UIColor *)colorForHex:(NSInteger)rgbHex alpha:(CGFloat)alpha; 34 | 35 | /** 36 | Creates and returns a color object from hex string. e.g @"#F0F", @"#66ccff 0.9" 37 | 38 | @param string The hex and alpha string value for the new color. 39 | @return An UIColor object from string, or nil if an error occurs. 40 | */ 41 | + (nullable UIColor *)colorForString:(NSString *)string; 42 | 43 | @end 44 | 45 | NS_ASSUME_NONNULL_END 46 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIColor+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HZExtend.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2015/7/20. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "UIColor+HZExtend.h" 10 | @implementation UIColor (HZExtend) 11 | #pragma mark - Public Method 12 | + (UIColor *)colorForHex:(NSInteger)colorHex 13 | { 14 | return [UIColor colorWithRed:((float)((colorHex & 0xFF0000) >> 16)) / 0xFF green:((float)((colorHex & 0xFF00) >> 8)) / 0xFF blue:((float)(colorHex & 0xFF)) / 0xFF alpha:1.0f]; 15 | } 16 | 17 | + (UIColor *)colorForHex:(NSInteger)colorHex alpha:(CGFloat)alpha 18 | { 19 | return [UIColor colorWithRed:((float)((colorHex & 0xFF0000) >> 16)) / 0xFF green:((float)((colorHex & 0xFF00) >> 8)) / 0xFF blue:((float)(colorHex & 0xFF)) / 0xFF alpha:alpha]; 20 | } 21 | 22 | + (UIColor *)colorForString:(NSString *)string 23 | { 24 | if ( nil == string || 0 == string.length ) 25 | return nil; 26 | 27 | string = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 28 | 29 | if ( [string hasPrefix:@"rgb("] && [string hasSuffix:@")"] ) 30 | { 31 | string = [string substringWithRange:NSMakeRange(4, string.length - 5)]; 32 | if ( string && string.length ) 33 | { 34 | NSArray * elems = [string componentsSeparatedByString:@","]; 35 | if ( elems && elems.count == 3 ) 36 | { 37 | NSInteger r = [[elems objectAtIndex:0] integerValue]; 38 | NSInteger g = [[elems objectAtIndex:1] integerValue]; 39 | NSInteger b = [[elems objectAtIndex:2] integerValue]; 40 | 41 | return [UIColor colorWithRed:(r * 1.0f / 255.0f) green:(g * 1.0f / 255.0f) blue:(b * 1.0f / 255.0f) alpha:1.0f]; 42 | } 43 | } 44 | } 45 | 46 | NSArray * array = [string componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; 47 | NSString * color = [array objectAtIndex:0]; 48 | CGFloat alpha = 1.0f; 49 | 50 | if ( array.count == 2 ) 51 | { 52 | alpha = [[array objectAtIndex:1] floatValue]; 53 | } 54 | 55 | if ( [color hasPrefix:@"#"] ) // #FFF 56 | { 57 | color = [color substringFromIndex:1]; 58 | 59 | if ( color.length == 3 ) 60 | { 61 | NSUInteger hexRGB = strtol(color.UTF8String , nil, 16); 62 | return [UIColor fromShortHexValue:hexRGB alpha:alpha]; 63 | } 64 | else if ( color.length == 6 ) 65 | { 66 | NSUInteger hexRGB = strtol(color.UTF8String , nil, 16); 67 | return [UIColor colorForHex:hexRGB alpha:alpha]; 68 | } 69 | } 70 | else if ( [color hasPrefix:@"0x"] || [color hasPrefix:@"0X"] ) // #FFF 71 | { 72 | color = [color substringFromIndex:2]; 73 | 74 | if ( color.length == 8 ) 75 | { 76 | NSUInteger hexRGB = strtol(color.UTF8String , nil, 16); 77 | return [UIColor colorForHex:hexRGB]; 78 | } 79 | else if ( color.length == 6 ) 80 | { 81 | NSUInteger hexRGB = strtol(color.UTF8String , nil, 16); 82 | return [UIColor colorForHex:hexRGB alpha:1.0f]; 83 | } 84 | } 85 | else 86 | { 87 | static NSMutableDictionary * __colors = nil; 88 | 89 | if ( nil == __colors ) 90 | { 91 | __colors = [[NSMutableDictionary alloc] init]; 92 | [__colors setObject:[UIColor clearColor] forKey:@"clear"]; 93 | [__colors setObject:[UIColor clearColor] forKey:@"transparent"]; 94 | [__colors setObject:[UIColor redColor] forKey:@"red"]; 95 | [__colors setObject:[UIColor blackColor] forKey:@"black"]; 96 | [__colors setObject:[UIColor darkGrayColor] forKey:@"darkgray"]; 97 | [__colors setObject:[UIColor lightGrayColor] forKey:@"lightgray"]; 98 | [__colors setObject:[UIColor whiteColor] forKey:@"white"]; 99 | [__colors setObject:[UIColor grayColor] forKey:@"gray"]; 100 | [__colors setObject:[UIColor greenColor] forKey:@"green"]; 101 | [__colors setObject:[UIColor blueColor] forKey:@"blue"]; 102 | [__colors setObject:[UIColor cyanColor] forKey:@"cyan"]; 103 | [__colors setObject:[UIColor yellowColor] forKey:@"yellow"]; 104 | [__colors setObject:[UIColor magentaColor] forKey:@"magenta"]; 105 | [__colors setObject:[UIColor orangeColor] forKey:@"orange"]; 106 | [__colors setObject:[UIColor purpleColor] forKey:@"purple"]; 107 | [__colors setObject:[UIColor brownColor] forKey:@"brown"]; 108 | } 109 | 110 | UIColor *setColor = [__colors objectForKey:color.lowercaseString]; 111 | if ( setColor ) 112 | { 113 | return [setColor colorWithAlphaComponent:alpha]; 114 | } 115 | } 116 | 117 | return nil; 118 | } 119 | 120 | #pragma mark - Private Method 121 | + (UIColor *)fromShortHexValue:(NSUInteger)hex alpha:(CGFloat)alpha 122 | { 123 | NSUInteger r = ((hex >> 8) & 0x0000000F); 124 | NSUInteger g = ((hex >> 4) & 0x0000000F); 125 | NSUInteger b = ((hex >> 0) & 0x0000000F); 126 | 127 | float fr = (r * 1.0f) / 15.0f; 128 | float fg = (g * 1.0f) / 15.0f; 129 | float fb = (b * 1.0f) / 15.0f; 130 | 131 | return [UIColor colorWithRed:fr green:fg blue:fb alpha:alpha]; 132 | } 133 | 134 | @end 135 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIDevice+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIApplication+HZExtend.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2017/8/4. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef NS_ENUM(NSInteger, HZDeviceSizeType) { 11 | HZDeviceSizeTypeUnKnow, // unknow size of device 12 | HZDeviceSizeType35Inch, // 3.5 inch 13 | HZDeviceSizeType4Inch, // 4 inch 14 | HZDeviceSizeType47Inch, // 4.7 inch 15 | HZDeviceSizeType55Inch, // 5.5 inch 16 | }; 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | /** 21 | Provides extensions for `UIDevice`. 22 | */ 23 | @interface UIDevice (HZExtend) 24 | 25 | /** The equipment size of the current device. */ 26 | @property(nonatomic, readonly) HZDeviceSizeType sizeType; 27 | 28 | /** The equipment model of the current device. e.g @"iPhone9,1",@"iPad6,7"... */ 29 | @property(nonatomic, readonly) NSString *platform; 30 | 31 | /** The UUID of the current device. */ 32 | @property(nonatomic, readonly) NSString *UUID; 33 | 34 | /** Whether the device is jailbroken. */ 35 | @property(nonatomic, readonly) BOOL isJailBroken; 36 | 37 | /** Whether the device is iPhone. */ 38 | @property(nonatomic, readonly) BOOL isPhone; 39 | 40 | /** Whether the device is iPad. */ 41 | @property(nonatomic, readonly) BOOL isPad; 42 | 43 | /** 44 | Returns a Boolean value that indicates whether the version of system is great than or eaqual to the version. 45 | 46 | @param version The version to compare to the system's version 47 | */ 48 | - (BOOL)systemVersionIsGreatThanOrEqualTo:(NSInteger)version; 49 | 50 | /** 51 | Returns a Boolean value that indicates whether the version of system is less than the version. 52 | 53 | @param version The version to compare to the system's version 54 | */ 55 | - (BOOL)systemVersionIsLessThan:(NSInteger)version; 56 | 57 | @end 58 | 59 | NS_ASSUME_NONNULL_END 60 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIDevice+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIApplication+HZExtend.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2017/8/4. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "UIDevice+HZExtend.h" 10 | #import "NSString+HZExtend.h" 11 | #include 12 | @implementation UIDevice (HZExtend) 13 | 14 | #pragma mark - Properties 15 | - (HZDeviceSizeType)sizeType 16 | { 17 | if (![UIScreen instancesRespondToSelector:@selector(currentMode)]) return HZDeviceSizeTypeUnKnow; 18 | 19 | CGSize deviceSize = [[UIScreen mainScreen] currentMode].size; 20 | if (CGSizeEqualToSize(CGSizeMake(640, 960), deviceSize)) return HZDeviceSizeType35Inch; 21 | if (CGSizeEqualToSize(CGSizeMake(640, 1136), deviceSize)) return HZDeviceSizeType4Inch; 22 | if (CGSizeEqualToSize(CGSizeMake(750, 1334), deviceSize)) return HZDeviceSizeType47Inch; 23 | if (CGSizeEqualToSize(CGSizeMake(1242, 2208), deviceSize)) return HZDeviceSizeType55Inch; 24 | 25 | return HZDeviceSizeTypeUnKnow; 26 | } 27 | 28 | - (NSString *)platform 29 | { 30 | size_t size; 31 | 32 | sysctlbyname("hw.machine", NULL, &size, NULL, 0); 33 | 34 | char *machine = malloc(size); 35 | 36 | sysctlbyname("hw.machine", machine, &size, NULL, 0); 37 | 38 | NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding]; 39 | 40 | free(machine); 41 | 42 | return platform; 43 | } 44 | 45 | - (NSString *)UUID 46 | { 47 | return [[self identifierForVendor] UUIDString]; 48 | } 49 | 50 | - (BOOL)isJailBroken 51 | { 52 | #if TARGET_IPHONE_SIMULATOR 53 | return NO; 54 | #else 55 | NSArray *paths = @[@"/Applications/Cydia.app", 56 | @"/private/var/lib/apt/", 57 | @"/private/var/lib/cydia", 58 | @"/private/var/stash"]; 59 | for (NSString *path in paths) { 60 | if ([[NSFileManager defaultManager] fileExistsAtPath:path]) return YES; 61 | } 62 | 63 | FILE *bash = fopen("/bin/bash", "r"); 64 | if (bash != NULL) { 65 | fclose(bash); 66 | return YES; 67 | } 68 | 69 | NSString *path = [NSString stringWithFormat:@"/private/%@", @"HZExtend"]; 70 | if ([@"HZExtend" writeToFile : path atomically : YES encoding : NSUTF8StringEncoding error : NULL]) { 71 | [[NSFileManager defaultManager] removeItemAtPath:path error:nil]; 72 | return YES; 73 | } 74 | 75 | return NO; 76 | #endif 77 | 78 | } 79 | 80 | - (BOOL)isPhone 81 | { 82 | NSString *model = [self model]; 83 | return [model rangeOfString:@"iPhone"].length != 0; 84 | } 85 | 86 | - (BOOL)isPad 87 | { 88 | NSString *model = [self model]; 89 | return [model rangeOfString:@"iPad"].length != 0; 90 | } 91 | 92 | #pragma mark - Method 93 | - (BOOL)systemVersionIsGreatThanOrEqualTo:(NSInteger)version 94 | { 95 | return ([[self systemVersion] floatValue] >= version); 96 | } 97 | 98 | - (BOOL)systemVersionIsLessThan:(NSInteger)version 99 | { 100 | return ([[self systemVersion] floatValue] < version); 101 | } 102 | @end 103 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIResponder+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIResponder+HZExtend.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 17/2/26. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | /** 15 | Provides extensions for `UIResponder` 16 | */ 17 | @interface UIResponder (HZExtend) 18 | 19 | /** 20 | Deliveries UI message. 21 | 22 | @param sel A selector identifying the message to send. 23 | @param block The block to be executed when message's responder is found. 24 | 25 | Sample Code: 26 | 27 | //ItemView.h 28 | @protocol ItemViewUIMessage 29 | - (void)messageDidClick:(ItemView *)item; 30 | @end 31 | 32 | //Deliveried the message about clicking. 33 | [self deliveryMessageWithSelector:@selector(itemDidClick:) usingBlock:^(UIResponder * _Nonnull responder) { 34 | [reponder messageDidClick:self]; 35 | }]; 36 | 37 | //responder.m 38 | - (void)messageDidClick:(ItemView *)item 39 | { 40 | //do something..... 41 | } 42 | */ 43 | - (void)deliveryMessageWithSelector:(SEL)sel usingBlock:(void (^)(UIResponder *responder))block; 44 | 45 | @end 46 | 47 | NS_ASSUME_NONNULL_END 48 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIResponder+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIResponder+HZExtend.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 17/2/26. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "UIResponder+HZExtend.h" 10 | 11 | @implementation UIResponder (HZAction) 12 | 13 | - (void)deliveryMessageWithSelector:(SEL)selector usingBlock:(void (^)(UIResponder * _Nonnull))block 14 | { 15 | UIResponder *next = [self nextResponder]; 16 | do { 17 | if ([next respondsToSelector:selector]) { 18 | if (block) { 19 | block(next); 20 | } 21 | } 22 | next = [next nextResponder]; 23 | } while (next != nil); 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIScrollView+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+HZExtend.h 3 | // HZNetworkDemo 4 | // 5 | // Created by xzh on 16/3/24. 6 | // Copyright © 2016年 xzh. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef NS_ENUM(NSInteger, HZScrollDirection) { 14 | HZScrollDirectionNone, 15 | HZScrollDirectionBack, 16 | HZScrollDirectionGo 17 | }; 18 | 19 | typedef NS_ENUM(NSInteger, HZScrollViewContentExpand) { 20 | HZScrollViewContentExpandVertical, 21 | HZScrollViewContentExpandHorizontal, 22 | }; 23 | 24 | @interface UIScrollView (HZExtend) 25 | 26 | @property(nonatomic, assign) CGFloat contentWidth; 27 | @property(nonatomic, assign) CGFloat contentHeight; 28 | 29 | @property(nonatomic, assign, readonly) CGFloat offsetY; 30 | @property(nonatomic, assign, readonly) CGFloat offsetX; 31 | 32 | @property(nonatomic, assign) CGFloat insetTop; 33 | @property(nonatomic, assign) CGFloat insetBottom; 34 | @property(nonatomic, assign) CGFloat insetLeft; 35 | @property(nonatomic, assign) CGFloat insetRight; 36 | @property(nonatomic, assign) UIEdgeInsets safeContentInset; 37 | 38 | @property(nonatomic, assign, readonly) HZScrollDirection direction; 39 | 40 | @property(nonatomic, assign) CGFloat lastContentOffset; 41 | 42 | - (UIImage *)imageRepresentation; 43 | 44 | - (void)calculateScrollDirectionWithExpand:(HZScrollViewContentExpand)expand; 45 | @end 46 | 47 | NS_ASSUME_NONNULL_END 48 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIScrollView+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+HZExtend.m 3 | // HZNetworkDemo 4 | // 5 | // Created by xzh on 16/3/24. 6 | // Copyright © 2016年 xzh. All rights reserved. 7 | // 8 | 9 | #import "UIScrollView+HZExtend.h" 10 | #import 11 | static const char kLastContentOffset = '\0'; 12 | static const char kDirection = '\0'; 13 | @implementation UIScrollView (HZExtend) 14 | 15 | #pragma mark - Data 16 | - (CGFloat)contentWidth 17 | { 18 | return self.contentSize.width; 19 | } 20 | 21 | - (void)setContentWidth:(CGFloat)contentWidth 22 | { 23 | CGSize contentSize = self.contentSize; 24 | contentSize.width = contentWidth; 25 | self.contentSize = contentSize; 26 | } 27 | 28 | - (CGFloat)contentHeight 29 | { 30 | return self.contentSize.height; 31 | } 32 | 33 | - (void)setContentHeight:(CGFloat)contentHeight 34 | { 35 | CGSize contentSize = self.contentSize; 36 | contentSize.height = contentHeight; 37 | self.contentSize = contentSize; 38 | } 39 | 40 | - (CGFloat)offsetX 41 | { 42 | return self.contentOffset.x; 43 | } 44 | 45 | - (CGFloat)offsetY 46 | { 47 | return self.contentOffset.y; 48 | } 49 | 50 | - (CGFloat)insetTop 51 | { 52 | return self.safeContentInset.top; 53 | } 54 | 55 | - (void)setInsetTop:(CGFloat)insetTop 56 | { 57 | UIEdgeInsets inset = self.contentInset; 58 | inset.top = insetTop; 59 | if (@available(iOS 11, *)) { 60 | inset.top -= (self.adjustedContentInset.top - self.contentInset.top); 61 | } 62 | self.contentInset = inset; 63 | } 64 | 65 | - (CGFloat)insetBottom 66 | { 67 | return self.safeContentInset.bottom; 68 | } 69 | 70 | - (void)setInsetBottom:(CGFloat)insetBottom 71 | { 72 | UIEdgeInsets insets = self.contentInset; 73 | insets.bottom = insetBottom; 74 | self.contentInset = insets; 75 | 76 | UIEdgeInsets inset = self.contentInset; 77 | inset.bottom = insetBottom; 78 | if (@available(iOS 11, *)) { 79 | inset.bottom -= (self.adjustedContentInset.bottom - self.contentInset.bottom); 80 | } 81 | self.contentInset = inset; 82 | } 83 | 84 | - (CGFloat)insetLeft 85 | { 86 | return self.safeContentInset.left; 87 | } 88 | 89 | - (void)setInsetLeft:(CGFloat)insetLeft 90 | { 91 | UIEdgeInsets inset = self.contentInset; 92 | inset.left = insetLeft; 93 | if (@available(iOS 11, *)) { 94 | inset.left -= (self.adjustedContentInset.left - self.contentInset.left); 95 | } 96 | self.contentInset = inset; 97 | } 98 | 99 | - (CGFloat)insetRight 100 | { 101 | return self.safeContentInset.right; 102 | } 103 | 104 | - (void)setInsetRight:(CGFloat)insetRight 105 | { 106 | UIEdgeInsets inset = self.contentInset; 107 | inset.right = insetRight; 108 | if (@available(iOS 11, *)) { 109 | inset.right -= (self.adjustedContentInset.right - self.contentInset.right); 110 | } 111 | self.contentInset = inset; 112 | } 113 | 114 | - (UIEdgeInsets)safeContentInset 115 | { 116 | if (@available(iOS 11, *)) { 117 | return self.adjustedContentInset; 118 | }else { 119 | return self.contentInset; 120 | } 121 | } 122 | 123 | - (UIImage *)imageRepresentation 124 | { 125 | CGFloat scale = [UIScreen mainScreen].scale; 126 | 127 | CGSize boundsSize = self.bounds.size; 128 | CGFloat boundsWidth = boundsSize.width; 129 | CGFloat boundsHeight = boundsSize.height; 130 | 131 | CGSize contentSize = self.contentSize; 132 | CGFloat contentHeight = contentSize.height; 133 | CGPoint offset = self.contentOffset; 134 | 135 | [self setContentOffset:CGPointMake(0, 0)]; 136 | NSMutableArray *images = [NSMutableArray array]; 137 | while (contentHeight > 0) { 138 | UIGraphicsBeginImageContextWithOptions(boundsSize, NO, 0.0); 139 | [self.layer renderInContext:UIGraphicsGetCurrentContext()]; 140 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 141 | UIGraphicsEndImageContext(); 142 | [images addObject:image]; 143 | 144 | CGFloat offsetY = self.contentOffset.y; 145 | [self setContentOffset:CGPointMake(0, offsetY + boundsHeight)]; 146 | 147 | contentHeight -= boundsHeight; 148 | } 149 | 150 | self.contentOffset = offset; 151 | 152 | CGSize imageSize = CGSizeMake(contentSize.width * scale, 153 | contentSize.height * scale); 154 | UIGraphicsBeginImageContext(imageSize); 155 | [images enumerateObjectsUsingBlock:^(UIImage *image, NSUInteger idx, BOOL *stop) { 156 | [image drawInRect:CGRectMake(0, 157 | scale * boundsHeight * idx, 158 | scale * boundsWidth, 159 | scale * boundsHeight)]; 160 | }]; 161 | 162 | UIImage *fullImage = UIGraphicsGetImageFromCurrentImageContext(); 163 | UIGraphicsEndImageContext(); 164 | return fullImage; 165 | 166 | } 167 | 168 | #pragma mark - Observer 169 | - (void)calculateScrollDirectionWithExpand:(HZScrollViewContentExpand)expand 170 | { 171 | CGFloat offsetDistance = expand == HZScrollViewContentExpandHorizontal?self.offsetX:self.offsetY; 172 | 173 | if (offsetDistance > self.lastContentOffset && self.direction != HZScrollDirectionGo) { //go 174 | self.direction = HZScrollDirectionGo; 175 | }else if (offsetDistance < self.lastContentOffset && self.direction != HZScrollDirectionBack) { //back 176 | self.direction = HZScrollDirectionBack; 177 | } 178 | 179 | self.lastContentOffset = offsetDistance; 180 | } 181 | 182 | #pragma mark - Properties 183 | - (CGFloat)lastContentOffset 184 | { 185 | NSNumber *value = objc_getAssociatedObject(self, &kLastContentOffset); 186 | return [value doubleValue]; 187 | } 188 | 189 | - (void)setLastContentOffset:(CGFloat)lastContentOffset 190 | { 191 | CGFloat value = [self lastContentOffset]; 192 | if (lastContentOffset != value) { 193 | [self willChangeValueForKey:@"lastContentOffsetDistance"]; 194 | objc_setAssociatedObject(self, &kLastContentOffset, @(lastContentOffset), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 195 | [self didChangeValueForKey:@"lastContentOffsetDistance"]; 196 | } 197 | } 198 | 199 | - (HZScrollDirection)direction 200 | { 201 | NSNumber *value = objc_getAssociatedObject(self, &kDirection); 202 | return [value doubleValue]; 203 | } 204 | 205 | - (void)setDirection:(HZScrollDirection)direction 206 | { 207 | NSInteger value = [self direction]; 208 | if (direction != value) { 209 | [self willChangeValueForKey:@"direction"]; 210 | objc_setAssociatedObject(self, &kDirection, @(direction), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 211 | [self didChangeValueForKey:@"direction"]; 212 | } 213 | } 214 | @end 215 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIView+HZExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+HZExtend.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 15/7/26. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | typedef void(^HZViewTapBlock)(UIView *view); 13 | 14 | /** 15 | Provides extensions for `UIView`. 16 | */ 17 | @interface UIView (HZExtend) 18 | 19 | /** Shortcut for frame.origin. */ 20 | @property(nonatomic, assign) CGPoint origin; 21 | 22 | /** Shortcut for frame.origin.y. */ 23 | @property(nonatomic, assign) CGFloat top; 24 | 25 | /** Shortcut for frame.origin.x. */ 26 | @property(nonatomic, assign) CGFloat left; 27 | 28 | /** Shortcut for frame.origin.y + frame.size.height. */ 29 | @property(nonatomic, assign) CGFloat bottom; 30 | 31 | /** Shortcut for frame.origin.x + frame.size.width. */ 32 | @property(nonatomic, assign) CGFloat right; 33 | 34 | /** Shortcut for center.y. */ 35 | @property(nonatomic, assign) CGFloat centerY; 36 | 37 | /** Shortcut for center.x. */ 38 | @property(nonatomic, assign) CGFloat centerX; 39 | 40 | /** Shortcut for frame.size.height. */ 41 | @property(nonatomic, assign) CGFloat height; 42 | 43 | /** Shortcut for frame.size.width. */ 44 | @property(nonatomic, assign) CGFloat width; 45 | 46 | /** Shortcut for frame.size. */ 47 | @property(nonatomic, assign) CGSize size; 48 | 49 | /** Returns the view's view controller. */ 50 | @property (nullable, nonatomic, readonly) UIViewController *viewController; 51 | 52 | /** 53 | Returns a snapshot image of the complete view hierarchy. 54 | 55 | @param afterUpdates A Boolean value that indicates whether the snapshot should be rendered after recent changes have been incorporated. 56 | Specify the value NO if you want to render a snapshot in the view hierarchy’s current state, which might not include recent changes. 57 | */ 58 | - (nullable UIImage *)snapshotImageAfterScreenUpdates:(BOOL)afterUpdates; 59 | 60 | 61 | /** 62 | Executes block when tap receiver. 63 | 64 | @param block the block to be executed when tap. 65 | */ 66 | - (void)tapPeformBlock:(HZViewTapBlock)block; 67 | 68 | @end 69 | 70 | @interface UIView (HZLayout) 71 | 72 | /** 73 | Sets frame.origin.x = superview.width - frame.size.width + rightOffset. 74 | 75 | @discussion If receiver don't have any superview, it will not work. 76 | */ 77 | - (void)alignRight:(CGFloat)rightOffset; 78 | 79 | /** 80 | Sets frame.origin.y = superview.height - frame.size.height + bottomOffset. 81 | 82 | @discussion If the receiver don't have any superview, this method has no effect. 83 | */ 84 | - (void)alignBottom:(CGFloat)bottomOffset; 85 | 86 | /** 87 | Sets center = (superview.width/2,superview.height/2). 88 | 89 | @discussion If the receiver don't have any superview, this method has no effect. 90 | */ 91 | - (void)alignCenter; 92 | 93 | /** 94 | Sets center.x = superview.width/2. 95 | 96 | @discussion If the receiver don't have any superview, this method has no effect. 97 | */ 98 | - (void)alignCenterX; 99 | 100 | /** 101 | Sets center.y = superview.height/2. 102 | 103 | @discussion If the receiver don't have any superview, this method has no effect. 104 | */ 105 | - (void)alignCenterY; 106 | 107 | /** 108 | Sets frame.origin.y = view.frame.origin.y + offset - frame.size.height. 109 | 110 | @discussion If the receiver don't have any superview, this method has no effect. 111 | */ 112 | - (void)bottomOverView:(UIView *)view offset:(CGFloat)offset; 113 | 114 | /** 115 | Sets frame.origin.y = CGRectGetMaxY(view) + offset. 116 | 117 | @discussion If the receiver don't have any superview, this method has no effect. 118 | */ 119 | - (void)topBehindView:(UIView *)view offset:(CGFloat)offset; 120 | 121 | /** 122 | Sets frame.origin.x = view.frame.origin.x + offset - frame.size.width. 123 | 124 | @discussion If the receiver don't have any superview, this method has no effect. 125 | */ 126 | - (void)rightOverView:(UIView *)view offset:(CGFloat)offset; 127 | 128 | /** 129 | Sets frame.origin.x = CGRectGetMaxX(view)+ offset. 130 | 131 | @discussion If the receiver don't have any superview, this method has no effect. 132 | */ 133 | - (void)leftBehindView:(UIView *)view offset:(CGFloat)offset; 134 | 135 | @end 136 | 137 | NS_ASSUME_NONNULL_END 138 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/Foundation/UIView+HZExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIApplication+HZExtend.m 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2017/8/4. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "UIView+HZExtend.h" 10 | #import 11 | static const char kBlock = '\0'; 12 | @implementation UIView (HZExtend) 13 | 14 | #pragma mark - Properties 15 | - (CGPoint)origin 16 | { 17 | return self.frame.origin; 18 | } 19 | 20 | - (void)setOrigin:(CGPoint)origin 21 | { 22 | CGRect newframe = self.frame; 23 | newframe.origin = origin; 24 | self.frame = newframe; 25 | } 26 | 27 | - (CGFloat)top 28 | { 29 | return self.frame.origin.y; 30 | } 31 | 32 | - (void)setTop:(CGFloat)top 33 | { 34 | CGRect newframe = self.frame; 35 | newframe.origin.y = top; 36 | self.frame = newframe; 37 | } 38 | 39 | - (CGFloat)left 40 | { 41 | return self.frame.origin.x; 42 | } 43 | 44 | - (void)setLeft:(CGFloat)left 45 | { 46 | CGRect newframe = self.frame; 47 | newframe.origin.x = left; 48 | self.frame = newframe; 49 | } 50 | 51 | - (CGFloat)bottom 52 | { 53 | return self.frame.origin.y + self.frame.size.height; 54 | } 55 | 56 | - (void)setBottom: (CGFloat)bottom 57 | { 58 | CGRect newframe = self.frame; 59 | newframe.origin.y = bottom - self.frame.size.height; 60 | self.frame = newframe; 61 | } 62 | 63 | - (CGFloat)right 64 | { 65 | return self.frame.origin.x + self.frame.size.width; 66 | } 67 | 68 | - (void)setRight:(CGFloat)right 69 | { 70 | CGRect newframe = self.frame; 71 | newframe.origin.x = right - self.frame.size.width; 72 | self.frame = newframe; 73 | } 74 | 75 | - (CGFloat)centerX 76 | { 77 | return self.center.x; 78 | } 79 | 80 | - (void)setCenterX:(CGFloat)centerX 81 | { 82 | CGPoint newCenter = self.center; 83 | newCenter.x = centerX; 84 | self.center = newCenter; 85 | } 86 | 87 | - (CGFloat)centerY 88 | { 89 | return self.center.y; 90 | } 91 | 92 | - (void)setCenterY:(CGFloat)centerY 93 | { 94 | CGPoint newCenter = self.center; 95 | newCenter.y = centerY; 96 | self.center = newCenter; 97 | } 98 | 99 | - (CGSize)size 100 | { 101 | return self.frame.size; 102 | } 103 | 104 | - (void)setSize:(CGSize)size 105 | { 106 | CGRect newframe = self.frame; 107 | newframe.size = size; 108 | self.frame = newframe; 109 | } 110 | 111 | - (CGFloat)height 112 | { 113 | return self.frame.size.height; 114 | } 115 | 116 | - (void)setHeight:(CGFloat)height 117 | { 118 | CGRect newframe = self.frame; 119 | newframe.size.height = height; 120 | self.frame = newframe; 121 | } 122 | 123 | - (CGFloat)width 124 | { 125 | return self.frame.size.width; 126 | } 127 | 128 | - (void)setWidth:(CGFloat)width 129 | { 130 | CGRect newframe = self.frame; 131 | newframe.size.width = width; 132 | self.frame = newframe; 133 | } 134 | 135 | - (UIViewController *)viewController 136 | { 137 | for (UIView *view = self; view; view = view.superview) { 138 | UIResponder *nextResponder = [view nextResponder]; 139 | if ([nextResponder isKindOfClass:[UIViewController class]]) { 140 | return (UIViewController *)nextResponder; 141 | } 142 | } 143 | return nil; 144 | } 145 | 146 | - (UIImage *)snapshotImageAfterScreenUpdates:(BOOL)afterUpdates 147 | { 148 | UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, 0); 149 | [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:afterUpdates]; 150 | UIImage *snap = UIGraphicsGetImageFromCurrentImageContext(); 151 | UIGraphicsEndImageContext(); 152 | return snap; 153 | } 154 | 155 | - (void)tapPeformBlock:(HZViewTapBlock)block 156 | { 157 | self.userInteractionEnabled = YES; 158 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)]; 159 | [self addGestureRecognizer:tap]; 160 | [self setBlock:block]; 161 | } 162 | 163 | - (void)tap:(UITapGestureRecognizer *)tap 164 | { 165 | HZViewTapBlock block = [self block]; 166 | if (block) { 167 | block(self); 168 | } 169 | } 170 | 171 | - (void)setBlock:(HZViewTapBlock)block 172 | { 173 | if (block) { 174 | objc_setAssociatedObject(self, &kBlock, block, OBJC_ASSOCIATION_COPY_NONATOMIC); 175 | } 176 | } 177 | 178 | - (HZViewTapBlock)block 179 | { 180 | return objc_getAssociatedObject(self, &kBlock); 181 | } 182 | 183 | 184 | @end 185 | 186 | @implementation UIView (HZLayout) 187 | 188 | - (void)alignRight:(CGFloat)rightOffset 189 | { 190 | [self checkSuperView]; 191 | 192 | UIView *supView = self.superview; 193 | self.right = supView.width + rightOffset; 194 | } 195 | 196 | - (void)alignBottom:(CGFloat)bottomOffset 197 | { 198 | [self checkSuperView]; 199 | 200 | UIView *supView = self.superview; 201 | self.bottom = supView.height + bottomOffset; 202 | } 203 | 204 | - (void)alignCenter 205 | { 206 | [self checkSuperView]; 207 | UIView *supView = self.superview; 208 | self.origin = CGPointMake((supView.width-self.width)/2, (supView.height-self.height)/2); 209 | } 210 | 211 | - (void)alignCenterX 212 | { 213 | [self checkSuperView]; 214 | UIView *supView = self.superview; 215 | self.left = (supView.width-self.width)/2; 216 | } 217 | 218 | - (void)alignCenterY 219 | { 220 | [self checkSuperView]; 221 | UIView *supView = self.superview; 222 | self.top = (supView.height-self.height)/2; 223 | } 224 | 225 | - (void)bottomOverView:(UIView *)view offset:(CGFloat)offset 226 | { 227 | [self checkHierarchySameWithContrastView:view]; 228 | self.bottom = view.top+offset; 229 | } 230 | 231 | - (void)topBehindView:(UIView *)view offset:(CGFloat)offset 232 | { 233 | [self checkHierarchySameWithContrastView:view]; 234 | self.top = view.bottom+offset; 235 | } 236 | 237 | - (void)rightOverView:(UIView *)view offset:(CGFloat)offset 238 | { 239 | [self checkHierarchySameWithContrastView:view]; 240 | self.right = view.left+offset; 241 | } 242 | 243 | - (void)leftBehindView:(UIView *)view offset:(CGFloat)offset 244 | { 245 | [self checkHierarchySameWithContrastView:view]; 246 | self.left = view.right+offset; 247 | } 248 | 249 | 250 | #pragma mark - Private Method 251 | - (void)checkSuperView 252 | { 253 | NSAssert(self.superview != nil, @"view did have superView"); 254 | } 255 | 256 | - (void)checkHierarchySameWithContrastView:(UIView *)contrastView 257 | { 258 | NSAssert((self.superview != nil && self.superview == contrastView.superview), @"views hierarchy not same"); 259 | } 260 | 261 | @end 262 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/HZFoundation/Classes/HZFoundation.h: -------------------------------------------------------------------------------- 1 | // 2 | // Extend.m 3 | // ZHFramework 4 | // 5 | // Created by xzh. on 15/7/20. 6 | // Copyright (c) 2015年 xzh. All rights reserved. 7 | // 8 | #ifndef _HZFOUNDATION_ 9 | #define _HZFOUNDATION_ 10 | 11 | #import "HZMacro.h" 12 | #import "HZSingleton.h" 13 | #import "NSString+HZExtend.h" 14 | #import "NSDictionary+HZExtend.h" 15 | #import "NSArray+HZExtend.h" 16 | #import "NSData+HZExtend.h" 17 | #import "NSDate+HZExtend.h" 18 | #import "NSURL+HZExtend.h" 19 | #import "NSObject+HZExtend.h" 20 | #import "NSDate+HZExtend.h" 21 | #import "UIApplication+HZExtend.h" 22 | #import "UIDevice+HZExtend.h" 23 | #import "UIView+HZExtend.h" 24 | #import "UIColor+HZExtend.h" 25 | #import "UIResponder+HZExtend.h" 26 | #import "NSObject+HZKVO.h" 27 | #import "HZConst.h" 28 | #import "UIAlertController+HZExtend.h" 29 | #import "UIScrollView+HZExtend.h" 30 | #import "NSTimer+HZExtend.h" 31 | 32 | #endif /* _HZFOUNDATION_ */ 33 | 34 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 天才哥 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Example/Pods/HZFoundation/README.md: -------------------------------------------------------------------------------- 1 | HZFoundation 2 | ============== 3 | 4 | [![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/GeniusBrother/HZFoundation/master/LICENSE)  5 | [![CocoaPods](https://img.shields.io/cocoapods/v/HZFoundation.svg?style=flat)](http://cocoapods.org/pods/HZFoundation)  6 | [![CocoaPods](http://img.shields.io/cocoapods/p/HZFoundation.svg?style=flat)](http://cocoadocs.org/docsets/HZFoundation)  7 | [![Support](https://img.shields.io/badge/support-iOS%208%2B%20-blue.svg?style=flat)](https://www.apple.com/nl/ios/)  8 | 9 | A set of useful categories for Foundation and UIKit.
10 | (It's a component of [HZExtend](https://github.com/GeniusBrother/HZExtend)) 11 | 12 | Contact 13 | ============== 14 | #### QQ Group:32272635 15 | #### Email:zuohong_xie@163.com 16 | 17 | Installation 18 | ============== 19 | ### CocoaPods 20 | 21 | 1. Add `pod 'HZFoundation` to your Podfile. 22 | 2. Run `pod install` or `pod update`. 23 | 3. Import \. 24 | 25 | Documentation 26 | ============== 27 | Full API documentation is available on [CocoaDocs](http://cocoadocs.org/docsets/HZFoundation/).
28 | 29 | Requirements 30 | ============== 31 | This library requires `iOS 8.0+` and `Xcode 8.0+`. 32 | 33 | License 34 | ============== 35 | HZORM is provided under the MIT license. See LICENSE file for details. 36 | -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/HZConst.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/HZConst.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/HZFoundation.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/HZFoundation.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/HZMacro.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/HZMacro.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/HZSingleton.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/HZSingleton.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/NSArray+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSArray+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/NSData+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSData+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/NSDate+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSDate+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/NSDictionary+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSDictionary+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/NSObject+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSObject+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/NSObject+HZKVO.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSObject+HZKVO.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/NSString+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSString+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/NSTimer+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSTimer+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/NSURL+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSURL+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/UIAlertController+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIAlertController+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/UIApplication+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIApplication+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/UIColor+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIColor+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/UIDevice+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIDevice+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/UIResponder+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIResponder+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/UIScrollView+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIScrollView+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZFoundation/UIView+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIView+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZURLManager/HZErrorViewController.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Controller/HZErrorViewController.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZURLManager/HZNavigationController.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Controller/HZNavigationController.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZURLManager/HZURLHandler.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/HZURLHandler.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZURLManager/HZURLManager.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/HZURLManager.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZURLManager/HZURLManagerConfig.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/HZURLManagerConfig.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZURLManager/HZURLNavigation.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/HZURLNavigation.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZURLManager/HZURLRewrite.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/HZURLRewrite.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZURLManager/NSObject+HZURLHandler.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/NSObject+HZURLHandler.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/HZURLManager/UIViewController+HZURLManager.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/UIViewController+HZURLManager.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/HZConst.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/HZConst.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/HZFoundation.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/HZFoundation.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/HZMacro.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/HZMacro.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/HZSingleton.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/HZSingleton.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/NSArray+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSArray+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/NSData+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSData+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/NSDate+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSDate+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/NSDictionary+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSDictionary+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/NSObject+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSObject+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/NSObject+HZKVO.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSObject+HZKVO.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/NSString+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSString+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/NSTimer+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSTimer+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/NSURL+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/NSURL+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/UIAlertController+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIAlertController+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/UIApplication+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIApplication+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/UIColor+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIColor+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/UIDevice+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIDevice+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/UIResponder+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIResponder+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/UIScrollView+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIScrollView+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZFoundation/UIView+HZExtend.h: -------------------------------------------------------------------------------- 1 | ../../../HZFoundation/HZFoundation/Classes/Foundation/UIView+HZExtend.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZURLManager/HZErrorViewController.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Controller/HZErrorViewController.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZURLManager/HZNavigationController.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Controller/HZNavigationController.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZURLManager/HZURLHandler.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/HZURLHandler.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZURLManager/HZURLManager.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/HZURLManager.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZURLManager/HZURLManagerConfig.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/HZURLManagerConfig.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZURLManager/HZURLNavigation.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/HZURLNavigation.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZURLManager/HZURLRewrite.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/HZURLRewrite.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZURLManager/NSObject+HZURLHandler.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/NSObject+HZURLHandler.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/HZURLManager/UIViewController+HZURLManager.h: -------------------------------------------------------------------------------- 1 | ../../../../../HZURLManager/Classes/Core/UIViewController+HZURLManager.h -------------------------------------------------------------------------------- /Example/Pods/Local Podspecs/HZFoundation.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "HZFoundation", 3 | "version": "0.1.3", 4 | "summary": "The Base Data Handle Library For IOS", 5 | "homepage": "https://github.com/GeniusBrother/HZFoundation.git", 6 | "license": "MIT", 7 | "authors": { 8 | "GeniusBrother": "zuohong_xie@163.com" 9 | }, 10 | "platforms": { 11 | "ios": "8.0" 12 | }, 13 | "requires_arc": true, 14 | "source": { 15 | "git": "https://github.com/GeniusBrother/HZFoundation.git", 16 | "tag": "0.1.3" 17 | }, 18 | "frameworks": "Foundation", 19 | "public_header_files": "HZFoundation/Classes/**/*.h", 20 | "source_files": "HZFoundation/Classes/**/*.{h,m}" 21 | } 22 | -------------------------------------------------------------------------------- /Example/Pods/Local Podspecs/HZURLManager.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "HZURLManager", 3 | "version": "0.1.1", 4 | "summary": "URL routing library for iOS,support URL rewrite", 5 | "homepage": "https://github.com/GeniusBrother/HZURLManager.git", 6 | "license": "MIT", 7 | "authors": { 8 | "GeniusBrother": "zuohong_xie@163.com" 9 | }, 10 | "platforms": { 11 | "ios": "8.0" 12 | }, 13 | "requires_arc": true, 14 | "source": { 15 | "git": "https://github.com/GeniusBrother/HZURLManager.git", 16 | "tag": "0.1.1" 17 | }, 18 | "frameworks": "Foundation", 19 | "public_header_files": "HZURLManager/Classes/**/*.h", 20 | "source_files": "HZURLManager/Classes/**/*.{h,m}" 21 | } 22 | -------------------------------------------------------------------------------- /Example/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - HZFoundation (0.1.3) 3 | - HZURLManager (0.1.1) 4 | 5 | DEPENDENCIES: 6 | - HZFoundation (from `https://github.com/GeniusBrother/HZFoundation`, branch `dev`) 7 | - HZURLManager (from `../`) 8 | 9 | EXTERNAL SOURCES: 10 | HZFoundation: 11 | :branch: dev 12 | :git: https://github.com/GeniusBrother/HZFoundation 13 | HZURLManager: 14 | :path: ../ 15 | 16 | CHECKOUT OPTIONS: 17 | HZFoundation: 18 | :commit: 5b541398a8ff97dae359f02b940086084c56cd34 19 | :git: https://github.com/GeniusBrother/HZFoundation 20 | 21 | SPEC CHECKSUMS: 22 | HZFoundation: 6dce609c11a0d9671020921207ea813a37da2b38 23 | HZURLManager: 87f2e040810d2c10da85692128e374cf198b942e 24 | 25 | PODFILE CHECKSUM: 3162d8dcc3682184cee62b23be9a1b9f9f49431a 26 | 27 | COCOAPODS: 1.3.1 28 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/HZFoundation/HZFoundation-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_HZFoundation : NSObject 3 | @end 4 | @implementation PodsDummy_HZFoundation 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/HZFoundation/HZFoundation-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/HZFoundation/HZFoundation.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/HZFoundation 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/HZFoundation" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/HZFoundation" "${PODS_ROOT}/Headers/Public/HZURLManager" 4 | OTHER_LDFLAGS = -framework "Foundation" 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}/HZFoundation 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/HZURLManager/HZURLManager-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_HZURLManager : NSObject 3 | @end 4 | @implementation PodsDummy_HZURLManager 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/HZURLManager/HZURLManager-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/HZURLManager/HZURLManager.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/HZURLManager 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/HZURLManager" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/HZFoundation" "${PODS_ROOT}/Headers/Public/HZURLManager" 4 | OTHER_LDFLAGS = -framework "Foundation" 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}/../.. 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-URLManager/Pods-URLManager-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## HZFoundation 5 | 6 | MIT License 7 | 8 | Copyright (c) 2017 天才哥 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | 29 | ## HZURLManager 30 | 31 | The MIT License (MIT) 32 | 33 | Copyright (c) 2016 GeniusBrother 34 | 35 | Permission is hereby granted, free of charge, to any person obtaining a copy 36 | of this software and associated documentation files (the "Software"), to deal 37 | in the Software without restriction, including without limitation the rights 38 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 39 | copies of the Software, and to permit persons to whom the Software is 40 | furnished to do so, subject to the following conditions: 41 | 42 | The above copyright notice and this permission notice shall be included in all 43 | copies or substantial portions of the Software. 44 | 45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 46 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 47 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 48 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 49 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 50 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 51 | SOFTWARE. 52 | 53 | Generated by CocoaPods - https://cocoapods.org 54 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-URLManager/Pods-URLManager-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 | MIT License 18 | 19 | Copyright (c) 2017 天才哥 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all 29 | copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 37 | SOFTWARE. 38 | 39 | License 40 | MIT 41 | Title 42 | HZFoundation 43 | Type 44 | PSGroupSpecifier 45 | 46 | 47 | FooterText 48 | The MIT License (MIT) 49 | 50 | Copyright (c) 2016 GeniusBrother 51 | 52 | Permission is hereby granted, free of charge, to any person obtaining a copy 53 | of this software and associated documentation files (the "Software"), to deal 54 | in the Software without restriction, including without limitation the rights 55 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 56 | copies of the Software, and to permit persons to whom the Software is 57 | furnished to do so, subject to the following conditions: 58 | 59 | The above copyright notice and this permission notice shall be included in all 60 | copies or substantial portions of the Software. 61 | 62 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 63 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 64 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 65 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 66 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 67 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 68 | SOFTWARE. 69 | 70 | License 71 | MIT 72 | Title 73 | HZURLManager 74 | Type 75 | PSGroupSpecifier 76 | 77 | 78 | FooterText 79 | Generated by CocoaPods - https://cocoapods.org 80 | Title 81 | 82 | Type 83 | PSGroupSpecifier 84 | 85 | 86 | StringsTable 87 | Acknowledgements 88 | Title 89 | Acknowledgements 90 | 91 | 92 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-URLManager/Pods-URLManager-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_URLManager : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_URLManager 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-URLManager/Pods-URLManager-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 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 10 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 11 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 12 | 13 | install_framework() 14 | { 15 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 16 | local source="${BUILT_PRODUCTS_DIR}/$1" 17 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 18 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 19 | elif [ -r "$1" ]; then 20 | local source="$1" 21 | fi 22 | 23 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 24 | 25 | if [ -L "${source}" ]; then 26 | echo "Symlinked..." 27 | source="$(readlink "${source}")" 28 | fi 29 | 30 | # Use filter instead of exclude so missing patterns don't throw errors. 31 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 32 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 33 | 34 | local basename 35 | basename="$(basename -s .framework "$1")" 36 | binary="${destination}/${basename}.framework/${basename}" 37 | if ! [ -r "$binary" ]; then 38 | binary="${destination}/${basename}" 39 | fi 40 | 41 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 42 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 43 | strip_invalid_archs "$binary" 44 | fi 45 | 46 | # Resign the code if required by the build settings to avoid unstable apps 47 | code_sign_if_enabled "${destination}/$(basename "$1")" 48 | 49 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 50 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 51 | local swift_runtime_libs 52 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 53 | for lib in $swift_runtime_libs; do 54 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 55 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 56 | code_sign_if_enabled "${destination}/${lib}" 57 | done 58 | fi 59 | } 60 | 61 | # Copies the dSYM of a vendored framework 62 | install_dsym() { 63 | local source="$1" 64 | if [ -r "$source" ]; then 65 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DWARF_DSYM_FOLDER_PATH}\"" 66 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DWARF_DSYM_FOLDER_PATH}" 67 | fi 68 | } 69 | 70 | # Signs a framework with the provided identity 71 | code_sign_if_enabled() { 72 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 73 | # Use the current code_sign_identitiy 74 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 75 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 76 | 77 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 78 | code_sign_cmd="$code_sign_cmd &" 79 | fi 80 | echo "$code_sign_cmd" 81 | eval "$code_sign_cmd" 82 | fi 83 | } 84 | 85 | # Strip invalid architectures 86 | strip_invalid_archs() { 87 | binary="$1" 88 | # Get architectures for current file 89 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 90 | stripped="" 91 | for arch in $archs; do 92 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then 93 | # Strip non-valid architectures in-place 94 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 95 | stripped="$stripped $arch" 96 | fi 97 | done 98 | if [[ "$stripped" ]]; then 99 | echo "Stripped $binary of architectures:$stripped" 100 | fi 101 | } 102 | 103 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 104 | wait 105 | fi 106 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-URLManager/Pods-URLManager-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 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-URLManager/Pods-URLManager.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/HZFoundation" "${PODS_ROOT}/Headers/Public/HZURLManager" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/HZFoundation" "$PODS_CONFIGURATION_BUILD_DIR/HZURLManager" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/HZFoundation" -isystem "${PODS_ROOT}/Headers/Public/HZURLManager" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"HZFoundation" -l"HZURLManager" -framework "Foundation" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-URLManager/Pods-URLManager.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/HZFoundation" "${PODS_ROOT}/Headers/Public/HZURLManager" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/HZFoundation" "$PODS_CONFIGURATION_BUILD_DIR/HZURLManager" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/HZFoundation" -isystem "${PODS_ROOT}/Headers/Public/HZURLManager" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"HZFoundation" -l"HZURLManager" -framework "Foundation" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Example/URLManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/URLManager.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/URLManager/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // URLManager 4 | // 5 | // Created by xzh on 16/2/29. 6 | // Copyright © 2016年 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /Example/URLManager/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // URLManager 4 | // 5 | // Created by xzh on 16/2/29. 6 | // Copyright © 2016年 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | #import 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | //Gets the controller corresponding to the URL. 21 | UIViewController *rootViewCtrl = [[ViewController alloc] init]; 22 | 23 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 24 | self.window.rootViewController = [[HZNavigationController alloc] initWithRootViewController:rootViewCtrl]; 25 | self.window.backgroundColor = [UIColor whiteColor]; 26 | [self.window makeKeyAndVisible]; 27 | 28 | NSURL *url = [NSURL URLWithString:@"wxren://page/share"]; 29 | 30 | NSLog(@"%@ %@",url.host, url.path); 31 | 32 | return YES; 33 | } 34 | 35 | - (void)applicationWillResignActive:(UIApplication *)application { 36 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 37 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 38 | } 39 | 40 | - (void)applicationDidEnterBackground:(UIApplication *)application { 41 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 42 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 43 | } 44 | 45 | - (void)applicationWillEnterForeground:(UIApplication *)application { 46 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 47 | } 48 | 49 | - (void)applicationDidBecomeActive:(UIApplication *)application { 50 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 51 | } 52 | 53 | - (void)applicationWillTerminate:(UIApplication *)application { 54 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /Example/URLManager/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Example/URLManager/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Example/URLManager/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Example/URLManager/ShowAlertURLHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // ShowAlertURLHandler.h 3 | // URLManager 4 | // 5 | // Created by xzh on 2017/8/11. 6 | // Copyright © 2017年 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ShowAlertURLHandler : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/URLManager/ShowAlertURLHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // ShowAlertURLHandler.m 3 | // URLManager 4 | // 5 | // Created by xzh on 2017/8/11. 6 | // Copyright © 2017年 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "ShowAlertURLHandler.h" 10 | #import 11 | #import 12 | @interface ShowAlertURLHandler () 13 | 14 | @end 15 | 16 | @implementation ShowAlertURLHandler 17 | 18 | /** 19 | hz://urlmanger.kit/doAlert 20 | 21 | @param title 22 | @param message 23 | */ 24 | - (id)handleURL:(NSURL *)url withParams:(id)params 25 | { 26 | NSDictionary *queryParam = url.queryDic; 27 | 28 | NSString *title = [queryParam objectForKey:@"title"]; 29 | NSString *message = [queryParam objectForKey:@"message"]; 30 | 31 | UIAlertController *alerController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; 32 | UIAlertAction *confirmAtion = [UIAlertAction actionWithTitle:@"Confirm" style:UIAlertActionStyleDefault handler:nil]; 33 | [alerController addAction:confirmAtion]; 34 | UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"Cancle" style:UIAlertActionStyleCancel handler:nil]; 35 | [alerController addAction:cancleAction]; 36 | [[HZURLNavigation currentViewController] presentViewController:alerController animated:YES completion:nil]; 37 | 38 | return nil; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Example/URLManager/URL-Controller-Config.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | hz 6 | 7 | page/web 8 | WebViewController 9 | page/itemA 10 | ViewController 11 | page/article 12 | URLItemViewController 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Example/URLManager/URL-Method-Config.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | hz://urlmanger.kit/doAlert 6 | ShowAlertURLHandler 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/URLManager/URLItemViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // URLItemViewController.h 3 | // URLManager 4 | // 5 | // Created by xzh on 16/2/29. 6 | // Copyright © 2016年 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface URLItemViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/URLManager/URLItemViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // URLItemViewController.m 3 | // URLManager 4 | // 5 | // Created by xzh on 16/2/29. 6 | // Copyright © 2016年 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "URLItemViewController.h" 10 | #import 11 | @interface URLItemViewController () 12 | 13 | @end 14 | 15 | @implementation URLItemViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | self.title = [self.params objectForKey:@"title"]; 21 | self.view.backgroundColor = [UIColor brownColor]; 22 | 23 | CGFloat viewWidth = self.view.frame.size.width; 24 | UIButton *pageBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 25 | pageBtn.frame = CGRectMake((viewWidth -150)/2, 100, 150, 30); 26 | [pageBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; 27 | [pageBtn setTitle:@"点击返回" forState:UIControlStateNormal]; 28 | [pageBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 29 | pageBtn.backgroundColor = [UIColor purpleColor]; 30 | [self.view addSubview:pageBtn]; 31 | 32 | if ([self.title isEqualToString:@"push"]) { 33 | UILabel *tipLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 34 | tipLabel.frame = CGRectMake((viewWidth -300)/2, 145, 300, 30); 35 | tipLabel.text = @"自定义导航控制器,可以全屏侧滑返回"; 36 | tipLabel.textColor = [UIColor blackColor]; 37 | tipLabel.textAlignment = NSTextAlignmentCenter; 38 | tipLabel.font = [UIFont systemFontOfSize:16]; 39 | tipLabel.backgroundColor = [UIColor whiteColor]; 40 | [self.view addSubview:tipLabel]; 41 | } 42 | 43 | UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 180, self.view.frame.size.width, 350)]; 44 | titleLabel.numberOfLines = 0; 45 | titleLabel.text = @"项目网址:https://github.com/GeniusBrother/HZURLManager\n\nHZExtend is a collection of iOS components.\nIt consists of the following several independent components:\n\n* HZFoundation — A set of useful categories for Foundation and UIKit.\n *HZURLManager — URL routing library for iOS, support URL rewrite.\n *HZNetwork — A useful networking framework based on AFNetworking for iOS, OS X, watchOS, and tvOS."; 46 | titleLabel.textColor = [UIColor blackColor]; 47 | titleLabel.font = [UIFont systemFontOfSize:13]; 48 | titleLabel.backgroundColor = [UIColor redColor]; 49 | [self.view addSubview:titleLabel]; 50 | 51 | } 52 | 53 | - (void)btnClick:(UIButton *)sender 54 | { 55 | [HZURLNavigation dismissCurrentAnimated:YES]; 56 | } 57 | 58 | 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Example/URLManager/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // URLManager 4 | // 5 | // Created by xzh on 16/2/29. 6 | // Copyright © 2016年 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Example/URLManager/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // URLManager 4 | // 5 | // Created by xzh on 16/2/29. 6 | // Copyright © 2016年 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "HZURLManager.h" 11 | #import "NSString+HZExtend.h" 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | self.view.backgroundColor = [UIColor whiteColor]; 22 | [self loadSubViews]; 23 | 24 | //I don't recommend load URLManager Config in View Controller, you should load it in AppDelegate. 25 | [self loadConfig]; 26 | } 27 | 28 | #pragma mark - Config 29 | - (void)loadConfig 30 | { 31 | //Loads URL-Controller & URL-Method Config. 32 | [[HZURLManagerConfig sharedConfig] loadURLCtrlConfig:[[NSBundle mainBundle] pathForResource:@"URL-Controller-Config" ofType:@"plist"] urlMethodConfig:[[NSBundle mainBundle] pathForResource:@"URL-Method-Config" ofType:@"plist"]]; 33 | 34 | //Adds URL Rewrite rule. You may be get the rule from remote. 35 | [[HZURLManagerConfig sharedConfig] addRewriteRules:@[@{@"match":@"(?:https://)?www.hz.com/articles/(\\d)\\?(.*)",@"target":@"hz://page/article?$query&id=$1"}]]; 36 | } 37 | 38 | #pragma mark - Action 39 | - (void)btnClick:(UIButton *)sender 40 | { 41 | NSInteger tag = sender.tag; 42 | 43 | if (0 == tag) { //URL-Present 44 | [HZURLManager redirectToURL:@"hz://page/article?title=present" animated:YES parmas:nil options:@{HZRedirectPresentMode:@(YES)} completion:nil]; 45 | }else if (1 == tag) { //URL-Push 46 | //The following URL will be converted to hz://page/article by rewriting. 47 | [HZURLManager pushToURL:@"https://www.hz.com/articles/3?title=push" animated:YES]; 48 | }else if (2 == tag) { 49 | NSString *targetUrl = @"https://github.com/GeniusBrother/HZExtend"; 50 | NSString *url = [NSString stringWithFormat:@"hz://page/web?url=%@",[targetUrl urlEncode]]; 51 | [HZURLManager pushToURL:url animated:YES]; 52 | }else if (3 == tag) { //URL-Action 53 | [HZURLManager handleURL:@"hz://urlmanger.kit/doAlert?title=alert&message=URL-showAlert" withParams:nil]; 54 | }else if (4 == tag) { //URL-NoRegister 55 | //跳转到没有注册过的控制器时在开发环境会提示错误 56 | [HZURLManager pushToURL:@"hz://urlItemC?title=push" animated:YES]; 57 | } 58 | } 59 | 60 | #pragma mark - UI 61 | - (void)loadSubViews 62 | { 63 | CGFloat viewWidth = self.view.frame.size.width; 64 | CGFloat btnWidth = 200; 65 | CGFloat btnHeight = 30; 66 | 67 | NSArray *titles = @[@"URL-Present",@"URL-Push",@"Default-Http(s)-URL",@"URL-Method",@"URL-NoRegister"]; 68 | for (NSInteger idx = 0; idx 10 | 11 | @interface WebViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/URLManager/WebViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewController.m 3 | // URLManager 4 | // 5 | // Created by xzh on 2017/8/11. 6 | // Copyright © 2017年 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "WebViewController.h" 10 | #import 11 | #import 12 | #import 13 | @interface WebViewController () 14 | 15 | @property(nonatomic, weak) WKWebView *webView; 16 | 17 | @end 18 | 19 | @implementation WebViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | 24 | NSString *urlstring = [[self.params objectForKey:@"url"] urlDecode]; 25 | NSURL *url = [NSURL URLWithString:urlstring]; 26 | WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.bounds]; 27 | webView.navigationDelegate = self; 28 | [self.view addSubview:webView]; 29 | self.webView = webView; 30 | 31 | [webView loadRequest:[NSURLRequest requestWithURL:url]]; 32 | 33 | } 34 | 35 | 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Example/URLManager/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // URLManager 4 | // 5 | // Created by xzh on 16/2/29. 6 | // Copyright © 2016年 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /HZURLManager.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "HZURLManager" 4 | s.version = "0.1.5" 5 | s.summary = "URL routing library for iOS,support URL rewrite" 6 | s.homepage = "https://github.com/GeniusBrother/HZURLManager.git" 7 | s.license = "MIT" 8 | s.author = { "GeniusBrother" => "zuohong_xie@163.com" } 9 | s.platform = :ios, "8.0" 10 | s.requires_arc = true 11 | s.source = { :git => "https://github.com/GeniusBrother/HZURLManager.git", :tag => s.version } 12 | s.frameworks = "Foundation" 13 | 14 | s.public_header_files = 'HZURLManager/Classes/**/*.h' 15 | s.source_files = 'HZURLManager/Classes/**/*.{h,m}' 16 | 17 | end 18 | -------------------------------------------------------------------------------- /HZURLManager/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeniusBrother/HZURLManager/bee4bc5d991bad2966a95c5cde6377b11966998f/HZURLManager/Assets/.gitkeep -------------------------------------------------------------------------------- /HZURLManager/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeniusBrother/HZURLManager/bee4bc5d991bad2966a95c5cde6377b11966998f/HZURLManager/Classes/.gitkeep -------------------------------------------------------------------------------- /HZURLManager/Classes/Controller/HZErrorViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZErrorViewController.h 3 | // URLManager 4 | // 5 | // Created by xzh on 16/3/26. 6 | // Copyright © 2016年 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HZErrorViewController : UIViewController 12 | 13 | @property(nonatomic, copy) NSString *errorInfo; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Controller/HZErrorViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HZErrorViewController.m 3 | // URLManager 4 | // 5 | // Created by xzh on 16/3/26. 6 | // Copyright © 2016年 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "HZErrorViewController.h" 10 | 11 | @interface HZErrorViewController () 12 | 13 | @property(nonatomic, weak) UILabel *errorLabel; 14 | 15 | @end 16 | 17 | @implementation HZErrorViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | self.view.backgroundColor = [UIColor whiteColor]; 22 | 23 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width; 24 | CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; 25 | UILabel *errorLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 26 | errorLabel.text = self.errorInfo; 27 | errorLabel.textColor = [UIColor blackColor]; 28 | errorLabel.numberOfLines = 0; 29 | errorLabel.font = [UIFont systemFontOfSize:18]; 30 | errorLabel.backgroundColor = [UIColor redColor]; 31 | CGSize size = [errorLabel sizeThatFits:CGSizeMake((screenWidth-2*15), 0)]; 32 | errorLabel.frame = CGRectMake(0, 0, size.width, size.height); 33 | errorLabel.center = CGPointMake(screenWidth/2, screenHeight/2); 34 | [self.view addSubview:errorLabel]; 35 | self.errorLabel = errorLabel; 36 | 37 | 38 | 39 | } 40 | 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Controller/HZNavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZNavigationController.h 3 | // ZHFramework 4 | // 5 | // Created by xzh. on 15/8/25. 6 | // Copyright (c) 2015年 xzh. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface HZNavigationController : UINavigationController 14 | 15 | /** Specify YES to turn on global slide pop. Default is YES */ 16 | @property(nonatomic, assign) BOOL swipeEnable; 17 | 18 | @property(nonatomic, assign) BOOL edgeRecognize; 19 | 20 | @end 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Controller/HZNavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HZNavigationController.m 3 | // ZHFramework 4 | // 5 | // Created by xzh. on 15/8/25. 6 | // Copyright (c) 2015年 xzh. All rights reserved. 7 | // 8 | 9 | #import "HZNavigationController.h" 10 | @interface HZNavigationController () 11 | 12 | @property(nonatomic, strong) UIPanGestureRecognizer *pan; 13 | 14 | @end 15 | 16 | @implementation HZNavigationController 17 | 18 | #pragma mark - Init 19 | - (void)setup 20 | { 21 | _swipeEnable = YES; 22 | self.delegate = self; 23 | [self configGestureRecognizer]; 24 | } 25 | 26 | /** 27 | * 在self.view检测到侧滑时调用系统的侧滑selector 28 | */ 29 | - (void)configGestureRecognizer 30 | { 31 | id target = self.interactivePopGestureRecognizer.delegate; 32 | UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)]; 33 | pan.delegate = self; 34 | [self.view addGestureRecognizer:pan]; 35 | self.pan = pan; 36 | 37 | //禁掉系统的侧滑手势 38 | self.interactivePopGestureRecognizer.enabled = NO; 39 | } 40 | 41 | - (void)viewDidLoad 42 | { 43 | [super viewDidLoad]; 44 | 45 | [self setup]; 46 | } 47 | - (void)handleNavigationTransition {} 48 | #pragma mark - Appearance 49 | - (UIStatusBarStyle)preferredStatusBarStyle 50 | { 51 | return self.topViewController.preferredStatusBarStyle; 52 | } 53 | 54 | #pragma mark - UIGestureRecognizerDelegate 55 | - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer 56 | { 57 | BOOL rs = (self.viewControllers.count > 1) && ![[self valueForKey:@"_isTransitioning"] boolValue] && self.swipeEnable; 58 | if (rs) { 59 | if (self.edgeRecognize) { 60 | CGPoint point = [gestureRecognizer locationInView:self.view]; 61 | return CGRectContainsPoint(CGRectMake(0, 0, 100,[UIScreen mainScreen].bounds.size.width) , point); 62 | } 63 | } 64 | return rs; 65 | } 66 | 67 | #pragma mark - UINavigationControllerDelegate 68 | - (void)navigationController:(UINavigationController *)navigationController 69 | didShowViewController:(UIViewController *)viewController 70 | animated:(BOOL)animate 71 | { 72 | if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) 73 | self.pan.enabled = YES;//push完毕开启手势 74 | 75 | } 76 | 77 | #pragma mark - Override 78 | - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated 79 | { 80 | if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) 81 | self.pan.enabled = NO; //push 时禁掉手势防止触发手势 82 | 83 | [super pushViewController:viewController animated:animated]; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Core/HZURLHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZURLHandler.h 3 | // HZURLManager 4 | // 5 | // Created by GeniusBrother on 2017/7/28. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @protocol HZURLHandler 14 | /** 15 | Handle URL. 16 | 17 | @discussion You can make different responses depending on the URL. 18 | 19 | @param URL The URL corresponding to the module method. 20 | @param params Additional parameters passed to URLHandler 21 | */ 22 | - (id)handleURL:(NSURL *)url withParams:(nullable id)params; 23 | 24 | @end 25 | 26 | NS_ASSUME_NONNULL_END 27 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Core/HZURLManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZURLManager.h 3 | // HZURLManager 4 | // 5 | // Created by GeniusBrother on 2015/8/21. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | #ifndef HZURLManager_h 11 | #define HZURLManager_h 12 | 13 | #import "HZURLHandler.h" 14 | #import "HZURLManagerConfig.h" 15 | #import "HZURLManager.h" 16 | #import "HZURLNavigation.h" 17 | #import "UIViewController+HZURLManager.h" 18 | #import "HZNavigationController.h" 19 | 20 | #endif /* HZURLManager_h */ 21 | @class HZViewController; 22 | #define URL_MANAGERN [HZURLManager sharedManager] 23 | 24 | NS_ASSUME_NONNULL_BEGIN 25 | extern NSString *const HZRedirectPresentMode; 26 | 27 | /** 28 | `HZURLManager` is an URL routing library for iOS,support URL rewrite. 29 | */ 30 | @interface HZURLManager : NSObject 31 | 32 | /** 33 | Calls module method specified by the given URL. 34 | 35 | @discussion Before use the method, you should registe the URL in {"scheme":{"host/path":"URLHandlerName"}} format in plist file, URLHandlerName is a name of class which implement HZURLHandler protocol. Then load it through HZURLManagerConfig. 36 | 37 | @param URL The URL corresponding to the module method. 38 | @param params Additional parameters passed to URLHandler. 39 | */ 40 | + (id)handleURL:(NSString *)URL withParams:(nullable id)params; 41 | 42 | /** 43 | Navigate to the controller corresponding to the URL. 44 | 45 | @discussion Before use the method, you should registe the URL in {"scheme":{"host/path":"ViewControllerName"}} format in plist file, ViewControllerName is a name of view controller. Then load it through HZURLManagerConfig. 46 | 47 | @param URL The URL corresponding to the Controller 48 | @param animated Specify YES to animate the transition or NO if you do not want the transition to be animated. 49 | @param parmas Additional parameters passed to Controller. You can get the parmas by `pramas` property see `UIViewController+HZURLManager.h` for more information. 50 | 51 | @param options Specify HZRedirectPresentMode equal YES to transition by present way or default is push way. 52 | @param completion The block to execute after the presentation finishes. 53 | */ 54 | + (void)redirectToURL:(NSString *)URL 55 | animated:(BOOL)animated 56 | parmas:(nullable NSDictionary *)parmas 57 | options:(nullable NSDictionary *)options 58 | completion:(nullable void(^)())completion; 59 | 60 | /** 61 | Navigate to the controller corresponding to the URL by push way. 62 | */ 63 | + (void)pushToURL:(NSString *)URL animated:(BOOL)animated params:(nullable NSDictionary *)params; 64 | + (void)pushToURL:(NSString *)URL animated:(BOOL)animated; 65 | 66 | 67 | + (void)pushViewController:(UIViewController *)ctrl animated:(BOOL)animated; 68 | + (void)presentViewController:(UIViewController *)ctrl animated:(BOOL)animated completion:(nullable void (^)(void))completion; 69 | + (void)dismissCurrentAnimated:(BOOL)animated; 70 | 71 | @end 72 | 73 | @interface HZURLManager (URLManagerDeprecated) 74 | 75 | + (void)pushViewControllerWithString:(NSString *)urlstring animated:(BOOL)animated __deprecated_msg("请使用- (void)redirectToURL:animated:"); 76 | + (void)pushViewControllerWithString:(NSString *)urlstring queryDic:(NSDictionary *)query animated:(BOOL)animated __deprecated_msg("- (void)redirectToURL:animated:params"); 77 | + (void)presentViewControllerWithString:(NSString *)urlstring animated:(BOOL)animated completion:(nullable void (^)(void))completion __deprecated_msg("请使用- (void)redirectToURL:animated:params:options:completion"); 78 | + (void)presentViewControllerWithString:( NSString *)urlstring queryDic:(NSDictionary *)query animated:(BOOL)animated completion:(nullable void (^)(void))completion __deprecated_msg("请使用- (void)redirectToURL:animated:params:options:completion"); 79 | @end 80 | 81 | 82 | NS_ASSUME_NONNULL_END 83 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Core/HZURLManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // HZURLManager.m 3 | // HZURLManager 4 | // 5 | // Created by GeniusBrother on 2015/8/21. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "HZURLManager.h" 10 | #import "NSObject+HZURLHandler.h" 11 | #import "HZURLRewrite.h" 12 | NSString *const HZRedirectPresentMode = @"HZRedirectPresentMode"; 13 | @interface HZURLManager () 14 | 15 | 16 | 17 | @end 18 | 19 | @implementation HZURLManager 20 | #pragma mark - Public Method 21 | + (id)handleURL:(NSString *)url withParams:(nullable id)parmas 22 | { 23 | if (!([url isKindOfClass:[NSString class]] && url.length > 0)) return nil; 24 | 25 | NSURL *formatedURL = [self formatedURL:url]; 26 | id handler = [NSObject urlHandlerForURL:formatedURL]; 27 | if ([handler respondsToSelector:@selector(handleURL:withParams:)]) { 28 | return [handler handleURL:formatedURL withParams:parmas]; 29 | } 30 | 31 | return nil; 32 | } 33 | 34 | + (void)redirectToURL:(NSString *)url 35 | animated:(BOOL)animated 36 | parmas:(nullable NSDictionary *)parmas 37 | options:(nullable NSDictionary *)options 38 | completion:(nullable void(^)())completion 39 | { 40 | NSURL *formatedURL = [self formatedURL:url]; 41 | NSURL *rewritedURL = [HZURLRewrite rewriteURLForURL:formatedURL]; 42 | UIViewController *viewController = [UIViewController viewControllerForURL:rewritedURL params:parmas]; 43 | if ([[options objectForKey:HZRedirectPresentMode] boolValue]) { 44 | [HZURLNavigation presentViewController:viewController animated:animated completion:completion]; 45 | }else { 46 | [HZURLNavigation pushViewController:viewController animated:animated]; 47 | } 48 | } 49 | 50 | + (void)pushToURL:(NSString *)url animated:(BOOL)animated 51 | { 52 | [self redirectToURL:url animated:animated parmas:nil options:nil completion:nil]; 53 | } 54 | 55 | + (void)pushToURL:(NSString *)url animated:(BOOL)animated params:(nullable NSDictionary *)params 56 | { 57 | [self redirectToURL:url animated:animated parmas:params options:nil completion:nil]; 58 | } 59 | 60 | + (void)pushViewController:(UIViewController *)ctrl animated:(BOOL)animated 61 | { 62 | [HZURLNavigation pushViewController:ctrl animated:animated]; 63 | } 64 | 65 | + (void)presentViewController:(UIViewController *)ctrl animated:(BOOL)animated completion:(void (^)(void))completion 66 | { 67 | [HZURLNavigation presentViewController:ctrl animated:animated completion:completion]; 68 | } 69 | 70 | + (void)dismissCurrentAnimated:(BOOL)animated 71 | { 72 | [HZURLNavigation dismissCurrentAnimated:animated]; 73 | } 74 | 75 | #pragma mark - Private Method 76 | //格式化URL 77 | + (NSURL *)formatedURL:(NSString *)url 78 | { 79 | if (!url) return nil; 80 | 81 | NSString *formatedURLString = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; 82 | return [NSURL URLWithString:formatedURLString]; 83 | } 84 | 85 | 86 | 87 | @end 88 | 89 | 90 | @implementation HZURLManager (URLManagerDeprecated) 91 | 92 | #pragma mark - push 93 | + (void)pushViewControllerWithString:(NSString *)urlstring animated:(BOOL)animated 94 | { 95 | if (!([urlstring isKindOfClass:[NSString class]] && urlstring.length > 0)) return; 96 | 97 | UIViewController *viewController = [UIViewController viewControllerForURL:[NSURL URLWithString:urlstring]]; 98 | if (viewController) 99 | [HZURLNavigation pushViewController:viewController animated:animated]; 100 | } 101 | 102 | + (void)pushViewControllerWithString:(NSString *)urlstring queryDic:(NSDictionary *)query animated:(BOOL)animated 103 | { 104 | if (!([urlstring isKindOfClass:[NSString class]] && urlstring.length > 0)) return; 105 | 106 | UIViewController *viewController = [UIViewController viewControllerForURL:[NSURL URLWithString:urlstring] params:query]; 107 | if (viewController) 108 | [HZURLNavigation pushViewController:viewController animated:animated]; 109 | } 110 | 111 | 112 | 113 | #pragma mark - Present 114 | + (void)presentViewControllerWithString:(NSString *)urlstring animated:(BOOL)animated completion:(void (^ _Nullable)(void))completion 115 | { 116 | if (!([urlstring isKindOfClass:[NSString class]] && urlstring.length > 0)) return; 117 | 118 | UIViewController *viewController = [UIViewController viewControllerForURL:[NSURL URLWithString:urlstring]]; 119 | if (viewController) 120 | [HZURLNavigation presentViewController:viewController animated:animated completion:completion]; 121 | } 122 | 123 | + (void)presentViewControllerWithString:(NSString *)urlstring queryDic:(NSDictionary *)query animated:(BOOL)animated completion:(void (^ _Nullable)(void))completion 124 | { 125 | if (!([urlstring isKindOfClass:[NSString class]] && urlstring.length > 0)) return; 126 | 127 | UIViewController *viewController = [UIViewController viewControllerForURL:[NSURL URLWithString:urlstring] params:query]; 128 | if (viewController) 129 | [HZURLNavigation presentViewController:viewController animated:animated completion:completion]; 130 | } 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Core/HZURLManagerConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZURLManageConfig.h 3 | // HZURLManager 4 | // 5 | // Created by GeniusBrother on 2016/2/27. 6 | // Copyright (c) 2016 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provides Configs for `HZURLManager` 13 | */ 14 | @interface HZURLManagerConfig : NSObject 15 | 16 | /** URL-Ctrl config */ 17 | @property(nonatomic, readonly) NSDictionary *urlControllerConfig; 18 | 19 | /** URL-Method config */ 20 | @property(nonatomic, readonly) NSDictionary *urlMethodConfig; 21 | 22 | /** URL rewrite rule */ 23 | @property(nonatomic, readonly) NSArray *rewriteRule; 24 | 25 | /** 26 | A Boolean value indicating whether the toolbar at the bottom of the screen is hidden when the view controller is pushed through URLManager on to a navigation controller. Default is YES. 27 | */ 28 | @property(nonatomic, assign) BOOL hideBottomWhenPushed; 29 | 30 | /** 31 | Returns global HZURLManagerConfig instance. 32 | 33 | @return HZURLManagerConfig shared instance 34 | */ 35 | + (instancetype)sharedConfig; 36 | 37 | /** 38 | Loads config of URL-Controller and URL-Method. 39 | 40 | @param ctrlPath the path of URL-Controller-Config.plist. 41 | @param methodPath the path of URL-Method-Config.plist. 42 | */ 43 | - (void)loadURLCtrlConfig:(NSString *)ctrlPath urlMethodConfig:(NSString *)methodPath; 44 | 45 | /** 46 | Adds URL rewrite rule. 47 | 48 | @discussion Each rewrite rule is represented by a dictionary, and the match key corresponds to the regular expression of the matching source URL The target key corresponds to the format of the new URL. 49 | 50 | The variable can be used in the target and starts with $, For example, $ 1 ... $ n represents the value of the corresponding tuple in the regular expression, $ query represents the query string part in the URL. 51 | 52 | For example, when the @{@"match":@"(?:https://)?www.hz.com/articles/(\\d)\\?(.*)",@"target":@"hz://page.hz/article?$query&id=$1"} rule is applied, the rewrite engine rewrites the source URL as hz://page.hz/article?title=cool&id=3 when we redirect to https://ww.hz.com/articles/3?title=cool , Finally we'll jump to hz://page.hz/article?title=cool&id=3. 53 | 54 | @param rule The Rule of URL rewrite. see discussion for more information. 55 | */ 56 | - (void)addRewriteRules:(NSArray *)rule; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Core/HZURLManagerConfig.m: -------------------------------------------------------------------------------- 1 | // 2 | // HZURLManageConfig.m 3 | // HZURLManager 4 | // 5 | // Created by GeniusBrother on 2016/2/27. 6 | // Copyright (c) 2016 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "HZURLManagerConfig.h" 10 | @interface HZURLManagerConfig () 11 | 12 | @property(nonatomic, copy) NSDictionary *urlControllerConfig; 13 | 14 | @property(nonatomic, copy) NSDictionary *urlMethodConfig; 15 | 16 | @property(nonatomic, strong) NSMutableArray *mutableRewriteRule; 17 | 18 | @end 19 | 20 | @implementation HZURLManagerConfig 21 | #pragma mark - Initialization 22 | static id _instance; 23 | + (id)allocWithZone:(struct _NSZone *)zone 24 | { 25 | static dispatch_once_t onceToken; 26 | dispatch_once(&onceToken, ^{ 27 | _instance = [super allocWithZone:zone]; 28 | }); 29 | return _instance; 30 | } 31 | 32 | + (id)copyWithZone:(struct _NSZone *)zone 33 | { 34 | return _instance; 35 | } 36 | 37 | + (instancetype)sharedConfig 38 | { 39 | static dispatch_once_t onceToken; 40 | dispatch_once(&onceToken, ^{ 41 | _instance = [[self alloc] init]; 42 | }); 43 | return _instance; 44 | } 45 | 46 | - (instancetype)init 47 | { 48 | self = [super init]; 49 | static dispatch_once_t onceToken; 50 | dispatch_once(&onceToken, ^{ 51 | _hideBottomWhenPushed = YES; 52 | _mutableRewriteRule = [NSMutableArray array]; 53 | }); 54 | return self; 55 | } 56 | 57 | #pragma mark - Public Method 58 | - (void)loadURLCtrlConfig:(NSString *)ctrlPath urlMethodConfig:(NSString *)methodPath 59 | { 60 | if ([ctrlPath isKindOfClass:[NSString class]] && ctrlPath.length > 0) { 61 | if ([[NSFileManager defaultManager] fileExistsAtPath:ctrlPath]) { 62 | self.urlControllerConfig = [NSDictionary dictionaryWithContentsOfFile:ctrlPath]; 63 | }else { 64 | NSAssert(NO, @"ctrlPath should be a file path"); 65 | } 66 | } 67 | 68 | if ([methodPath isKindOfClass:[NSString class]] && methodPath.length > 0) { 69 | if ([[NSFileManager defaultManager] fileExistsAtPath:methodPath]) { 70 | self.urlMethodConfig = [NSDictionary dictionaryWithContentsOfFile:methodPath]; 71 | }else { 72 | NSAssert(NO, @"methodPath should be a file path"); 73 | } 74 | } 75 | } 76 | 77 | - (void)addRewriteRules:(NSArray *)rule 78 | { 79 | if (rule) [self.mutableRewriteRule addObjectsFromArray:rule]; 80 | } 81 | 82 | #pragma mark - Getter 83 | - (NSArray *)rewriteRule 84 | { 85 | return [self.mutableRewriteRule copy]; 86 | } 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Core/HZURLNavigation.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZURLNavigation.h 3 | // HZFoundation 4 | // 5 | // Created by GeniusBrother on 2015/8/21. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface HZURLNavigation : NSObject 14 | /** 15 | Returns the current UIViewController. 16 | */ 17 | + (UIViewController *)currentViewController; 18 | 19 | /** 20 | Returns the current UINavigationController. 21 | */ 22 | + (nullable UINavigationController *)currentNavigationViewController; 23 | 24 | /** 25 | Pushes a view controller onto the current UINavigationController’s stack and updates the display. 26 | 27 | @param viewController The view controller to push onto the stack. This object cannot be a tab bar controller. If the view controller is already on the navigation stack, this method throws an exception. 28 | @param animated Specify YES to animate the transition or NO if you do not want the transition to be animated. You might specify NO if you are setting up the navigation controller at launch time. 29 | @param replace Specify YES to remove visibleViewController. 30 | */ 31 | + (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated; 32 | + (void)pushViewControllerArray:(NSArray *)viewControllers animated:(BOOL)animated; 33 | 34 | /** 35 | Presents a view controller modally. 36 | 37 | @param viewController The view controller to display over the current view controller’s content. 38 | @param animated Pass YES to animate the presentation; otherwise, pass NO. 39 | @param completion The block to execute after the presentation finishes. 40 | */ 41 | + (void)presentViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(void (^ __nullable)(void))completion; 42 | 43 | /** 44 | Dismisses current view controller. 45 | */ 46 | + (void)dismissCurrentAnimated:(BOOL)animated; 47 | 48 | @end 49 | 50 | NS_ASSUME_NONNULL_END 51 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Core/HZURLNavigation.m: -------------------------------------------------------------------------------- 1 | // 2 | // HZURLNavigation.m 3 | // HZURLManager 4 | // 5 | // Created by GeniusBrother on 2015/8/21. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "HZURLNavigation.h" 10 | @implementation HZURLNavigation 11 | 12 | #pragma mark - 获得控制器 13 | + (id)applicationDelegate 14 | { 15 | return [UIApplication sharedApplication].delegate; 16 | } 17 | 18 | + (UINavigationController*)currentNavigationViewController 19 | { 20 | UIViewController* currentViewController = [self currentViewController]; 21 | return currentViewController.navigationController; 22 | } 23 | 24 | + (UIViewController *)currentViewController 25 | { 26 | UIViewController* rootViewController = self.applicationDelegate.window.rootViewController; 27 | return [self currentViewControllerFrom:rootViewController]; 28 | } 29 | 30 | /** 31 | * 返回当前的控制器,以viewController为节点开始寻找 32 | */ 33 | + (UIViewController*)currentViewControllerFrom:(UIViewController*)viewController 34 | { 35 | //传入的根节点控制器是导航控制器 36 | if ([viewController isKindOfClass:[UINavigationController class]]) 37 | { 38 | UINavigationController* navigationController = (UINavigationController *)viewController; 39 | return [self currentViewControllerFrom:navigationController.viewControllers.lastObject]; 40 | } 41 | else if([viewController isKindOfClass:[UITabBarController class]]) //传入的根节点控制器是UITabBarController 42 | { 43 | UITabBarController* tabBarController = (UITabBarController *)viewController; 44 | return [self currentViewControllerFrom:tabBarController.selectedViewController]; 45 | } 46 | else if(viewController.presentedViewController != nil) //传入的根节点控制器是被展现出来的控制器 47 | { 48 | return [self currentViewControllerFrom:viewController.presentedViewController]; 49 | } 50 | else 51 | { 52 | return viewController; 53 | } 54 | } 55 | 56 | #pragma mark - Push 57 | + (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated 58 | { 59 | if (viewController) { 60 | [self pushViewControllerArray:@[viewController] animated:animated replace:NO]; 61 | } 62 | 63 | } 64 | 65 | + (void)pushViewControllerArray:(NSArray *)viewControllers animated:(BOOL)animated 66 | { 67 | [self pushViewControllerArray:viewControllers animated:animated replace:NO]; 68 | } 69 | 70 | + (void)pushViewControllerArray:(NSArray *)viewControllers animated:(BOOL)animated replace:(BOOL)replace 71 | { 72 | if (!viewControllers) return; 73 | 74 | UINavigationController *currentNav = [self currentNavigationViewController]; 75 | if (!currentNav) return; 76 | 77 | NSArray *oldViewCtrls = currentNav.childViewControllers; 78 | NSArray *newViewCtrls = nil; 79 | if (replace) { 80 | newViewCtrls = [[oldViewCtrls subarrayWithRange:NSMakeRange(0, oldViewCtrls.count-1)] arrayByAddingObjectsFromArray:viewControllers]; 81 | }else { 82 | newViewCtrls = [oldViewCtrls arrayByAddingObjectsFromArray:viewControllers]; 83 | } 84 | 85 | [currentNav setViewControllers:newViewCtrls animated:animated]; 86 | } 87 | 88 | #pragma mark - Present 89 | + (void)presentViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(void (^ __nullable)(void))completion 90 | { 91 | if (!viewController) return; 92 | 93 | UIViewController *currentCtrl = [self currentViewController]; 94 | if (!currentCtrl) return; 95 | 96 | [currentCtrl presentViewController:viewController animated:animated completion:completion]; 97 | } 98 | 99 | #pragma mark - Dismiss 100 | + (void)dismissCurrentAnimated:(BOOL)animated 101 | { 102 | UIViewController *currentViewController = [self currentViewController]; 103 | if(!currentViewController) return; 104 | 105 | if(currentViewController.navigationController) //如果当前视图有导航控制器 106 | { 107 | if(currentViewController.navigationController.viewControllers.count == 1) 108 | { 109 | if(currentViewController.presentingViewController) //modal出来一个导航控制器 110 | { 111 | [currentViewController dismissViewControllerAnimated:animated completion:nil]; 112 | } 113 | } 114 | else 115 | { 116 | [currentViewController.navigationController popViewControllerAnimated:animated]; 117 | } 118 | } 119 | else if(currentViewController.presentingViewController) //如果当前视图是modal 120 | { 121 | [currentViewController dismissViewControllerAnimated:animated completion:nil]; 122 | } 123 | 124 | } 125 | @end 126 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Core/HZURLRewrite.h: -------------------------------------------------------------------------------- 1 | // 2 | // HZURLRewrite.h 3 | // HZURLManager 4 | // 5 | // Created by GeniusBrother on 2017/7/28. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | /** 11 | Provides rewrite rules for `HZURLManager` 12 | */ 13 | @interface HZURLRewrite : NSObject 14 | 15 | + (NSURL *)rewriteURLForURL:(NSURL *)url; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Core/HZURLRewrite.m: -------------------------------------------------------------------------------- 1 | // 2 | // HZURLRewrite.m 3 | // HZURLManager 4 | // 5 | // Created by GeniusBrother on 2017/7/28. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "HZURLRewrite.h" 10 | #import "HZURLManagerConfig.h" 11 | @implementation HZURLRewrite 12 | 13 | + (NSURL *)rewriteURLForURL:(NSURL *)url 14 | { 15 | if (!url) return nil; 16 | 17 | NSArray *rules = [HZURLManagerConfig sharedConfig].rewriteRule; 18 | 19 | if ([rules isKindOfClass:[NSArray class]] && rules.count > 0) { 20 | NSString *targetURL = url.absoluteString; 21 | NSRegularExpression *replaceRx = [NSRegularExpression regularExpressionWithPattern:@"[$](\\d)+|[$]query" options:0 error:NULL]; 22 | for (NSDictionary *rule in rules) { 23 | NSString *matchRule = [rule objectForKey:@"match"]; 24 | if (!([matchRule isKindOfClass:[NSString class]] && matchRule.length > 0)) continue; 25 | 26 | NSRange searchRange = NSMakeRange(0, targetURL.length); 27 | NSRegularExpression *rx = [NSRegularExpression regularExpressionWithPattern:matchRule options:0 error:NULL]; 28 | NSRange range = [rx rangeOfFirstMatchInString:targetURL options:0 range:searchRange]; 29 | if (range.length != 0) { //url匹配 30 | //获取分组值 31 | NSMutableArray *groupValues = [NSMutableArray array]; 32 | NSTextCheckingResult *result = [rx firstMatchInString:targetURL options:0 range:searchRange]; 33 | for (NSInteger idx = 0; idx= 1 && index <= groupValues.count) { 50 | NSInteger loc = (index-1)?:0; 51 | [newTargetURL replaceOccurrencesOfString:value withString:groupValues[loc] options:0 range:NSMakeRange(0, newTargetURL.length)]; 52 | } 53 | }else { 54 | 55 | if ([value containsString:@"query"]) { 56 | [newTargetURL replaceOccurrencesOfString:value withString:url.query.length>0?url.query:@"" options:0 range:NSMakeRange(0, newTargetURL.length)]; 57 | } 58 | } 59 | }]; 60 | targetURL = newTargetURL; 61 | } 62 | } 63 | 64 | return [NSURL URLWithString:targetURL]; 65 | } 66 | 67 | return url; 68 | } 69 | 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Core/NSObject+HZURLHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+HZURLHandler.h 3 | // HZURLManager 4 | // 5 | // Created by GeniusBrother on 2017/7/28. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HZURLHandler.h" 11 | @interface NSObject (HZURLHandler) 12 | 13 | + (id )urlHandlerForURL:(NSURL *)url; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Core/NSObject+HZURLHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+HZURLHandler.m 3 | // HZURLManager 4 | // 5 | // Created by GeniusBrother on 2017/7/28. 6 | // Copyright (c) 2017 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "NSObject+HZURLHandler.h" 10 | #import "HZURLManagerConfig.h" 11 | @implementation NSObject (HZURLHandler) 12 | 13 | //获取URL对应的URLHandler 14 | + (id)urlHandlerForURL:(NSURL *)url 15 | { 16 | NSDictionary *config = [HZURLManagerConfig sharedConfig].urlMethodConfig; 17 | NSAssert(config, @"请先配置URL-Method-Config"); 18 | 19 | NSString *host = url.host; 20 | NSString *path = url.path; 21 | NSString *scheme = url.scheme; 22 | NSString *pathContainHost = [NSString stringWithFormat:@"%@%@%@",scheme?[NSString stringWithFormat:@"%@://",scheme]:@"",host?:@"",path?:@""]; 23 | NSString *className = [config objectForKey:pathContainHost]; 24 | if (className) { 25 | Class class = NSClassFromString(className); 26 | return class != NULL?[[class alloc] init]:nil; 27 | }else { 28 | return nil; 29 | } 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Core/UIViewController+HZURLManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+HZURLManager.h 3 | // HZURLManager 4 | // 5 | // Created by GeniusBrother on 15/8/21. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | #import 9 | NS_ASSUME_NONNULL_BEGIN 10 | /** 11 | Provides view controller for `HZURLManager`. 12 | */ 13 | @interface UIViewController (HZURLManager) 14 | 15 | /** 16 | The URL corresponding to the Controller 17 | */ 18 | @property(nonatomic, strong, readonly) NSString *originURL; 19 | 20 | /** 21 | Consists of a query string and additional parameters passed by user. 22 | */ 23 | @property(nonatomic, strong, readonly) NSDictionary *params; 24 | 25 | /** 26 | Returns the controller corresponding to the URL. 27 | 28 | @discussion Before use the method, you should registe the URL in {"scheme":{"host/path":"ViewControllerName"}} format in plist file, ViewControllerName is a name of view controller. Then load it through HZURLManagerConfig. 29 | 30 | @param parmas Additional parameters passed to Controller. 31 | */ 32 | + (UIViewController *)viewControllerForURL:(NSURL *)url; 33 | + (UIViewController *)viewControllerForURL:(NSURL *)url params:(nullable NSDictionary *)params; 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /HZURLManager/Classes/Core/UIViewController+HZURLManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+HZURLManager.m 3 | // HZURLManager 4 | // 5 | // Created by GeniusBrother on 15/8/21. 6 | // Copyright (c) 2015 GeniusBrother. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+HZURLManager.h" 10 | #import "HZURLManagerConfig.h" 11 | #import 12 | 13 | static const char kOriginURL = '\0'; 14 | static const char kParams = '\1'; 15 | @interface UIViewController () 16 | 17 | @property(nonatomic, strong) NSString *originURL; 18 | @property(nonatomic, strong) NSDictionary *queryDic; 19 | 20 | @end 21 | 22 | @implementation UIViewController (HZURLManager) 23 | #pragma mark - Public Method 24 | #pragma mark Core 25 | + (UIViewController *)viewControllerForURL:(NSURL *)url params:(NSDictionary *)params 26 | { 27 | NSDictionary *urlControllerConfig = [HZURLManagerConfig sharedConfig].urlControllerConfig; 28 | NSAssert(urlControllerConfig, @"请先配置URL-Ctrl-Config"); 29 | 30 | NSString *scheme = url.scheme; 31 | NSDictionary *config = [urlControllerConfig objectForKey:scheme]; 32 | NSAssert(config, @"scheme所对应的配置不存在"); 33 | 34 | /*******************根据scheme创建控制器********************/ 35 | UIViewController *viewCtrl = nil; 36 | NSString *strClass = [config objectForKey:[NSString stringWithFormat:@"%@%@",url.host?:@"",url.path]]; 37 | NSString *errorInfo = nil; 38 | 39 | 40 | if (strClass) { 41 | Class class = NSClassFromString(strClass); 42 | if(NULL != class) { 43 | viewCtrl = [[class alloc] init]; 44 | }else { //无该控制器 45 | errorInfo = [NSString stringWithFormat:@"404 :) ,%@ No Registrer",strClass]; 46 | } 47 | }else { 48 | errorInfo = [NSString stringWithFormat:@"404 :) ,%@ No Register", url.absoluteString]; 49 | } 50 | #ifdef DEBUG // 调试状态 51 | viewCtrl = viewCtrl?:[self errorViewConrtollerWithInfo:errorInfo]; 52 | 53 | #else // 发布状态 54 | #endif 55 | 56 | if (viewCtrl) { 57 | NSMutableDictionary *tmpDic = [NSMutableDictionary dictionary]; 58 | NSDictionary *urlQueryDic = [self queryDicWithURL:url]; 59 | if (urlQueryDic) [tmpDic addEntriesFromDictionary:urlQueryDic]; 60 | if (params) [tmpDic addEntriesFromDictionary:params]; 61 | viewCtrl.params = tmpDic; 62 | viewCtrl.originURL = url.absoluteString; 63 | viewCtrl.hidesBottomBarWhenPushed = [HZURLManagerConfig sharedConfig].hideBottomWhenPushed; 64 | return viewCtrl; 65 | } 66 | return nil; 67 | } 68 | 69 | 70 | + (UIViewController *)viewControllerForURL:(NSURL *)url 71 | { 72 | return [self viewControllerForURL:url params:nil]; 73 | } 74 | 75 | #pragma mark - Private Method 76 | /** 77 | * 创建错误控制器 78 | */ 79 | + (UIViewController *)errorViewConrtollerWithInfo:(NSString *)errorInfo 80 | { 81 | Class noCtrlClass = NSClassFromString(@"HZErrorViewController"); 82 | UIViewController *viewCtrl = [[noCtrlClass alloc] init]; 83 | [viewCtrl setValue:errorInfo forKey:@"errorInfo"]; 84 | return viewCtrl; 85 | } 86 | 87 | + (NSString *)valueFromKeyValue:(NSString *)keyValue atIndex:(NSUInteger)index 88 | { 89 | return [[keyValue componentsSeparatedByString:@"="] objectAtIndex:index]; 90 | } 91 | 92 | + (NSDictionary *)queryDicWithURL:(NSURL *)url 93 | { 94 | NSString *keyValues = url.query; 95 | if (!keyValues) return nil; 96 | 97 | return [self queryDicWithKeysValues:keyValues]; 98 | } 99 | 100 | 101 | + (NSDictionary *)queryDicWithKeysValues:(NSString *)keyValues 102 | { 103 | if (!(keyValues.length > 0)) return @{}; 104 | 105 | NSArray *pairArray = [keyValues componentsSeparatedByString:@"&"]; //键值对字符串 106 | NSMutableDictionary *queryDic= [NSMutableDictionary dictionaryWithCapacity:pairArray.count]; 107 | NSString *key = nil; 108 | NSString *obj = nil; 109 | if (pairArray.count > 1) 110 | { 111 | for (NSString *pair in pairArray) 112 | { 113 | key = [self valueFromKeyValue:pair atIndex:0]; 114 | obj = [self valueFromKeyValue:pair atIndex:1]; 115 | [queryDic setObject:[obj stringByRemovingPercentEncoding] forKey:key]; 116 | } 117 | } 118 | else if (pairArray.count == 1) 119 | { 120 | key = [self valueFromKeyValue:keyValues atIndex:0]; 121 | obj = [self valueFromKeyValue:keyValues atIndex:1]; 122 | [queryDic setObject:[obj stringByRemovingPercentEncoding] forKey:key]; 123 | } 124 | 125 | return queryDic; 126 | } 127 | 128 | #pragma mark - Property 129 | - (NSString *)originURL 130 | { 131 | return objc_getAssociatedObject(self, &kOriginURL); 132 | } 133 | 134 | - (void)setOriginURL:(NSString *)originURL 135 | { 136 | NSString *url = objc_getAssociatedObject(self, &kOriginURL); 137 | if (url != originURL) { 138 | [self willChangeValueForKey:@"originURL"]; 139 | objc_setAssociatedObject(self, &kOriginURL, originURL, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 140 | [self didChangeValueForKey:@"originURL"]; 141 | } 142 | } 143 | 144 | - (NSDictionary *)params 145 | { 146 | return objc_getAssociatedObject(self, &kParams); 147 | } 148 | 149 | - (void)setParams:(NSDictionary *)params 150 | { 151 | NSDictionary *dic = objc_getAssociatedObject(self, &kParams); 152 | if (dic != params) { 153 | [self willChangeValueForKey:@"params"]; 154 | objc_setAssociatedObject(self, &kParams, params, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 155 | [self didChangeValueForKey:@"params"]; 156 | } 157 | } 158 | 159 | 160 | @end 161 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 GeniusBrother 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | HZURLManager 2 | ============== 3 | 4 | [![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/GeniusBrother/HZURLManager/master/LICENSE)  5 | [![CocoaPods](https://img.shields.io/cocoapods/v/HZURLManager.svg?style=flat)](http://cocoapods.org/pods/HZURLManager)  6 | [![CocoaPods](http://img.shields.io/cocoapods/p/HZURLManager.svg?style=flat)](http://cocoadocs.org/docsets/HZURLManager)  7 | [![Support](https://img.shields.io/badge/support-iOS%208%2B%20-blue.svg?style=flat)](https://www.apple.com/nl/ios/)  8 | 9 | URL routing library for iOS, support URL rewrite.
10 | (It's a component of [HZExtend](https://github.com/GeniusBrother/HZExtend)) 11 | 12 | Contact 13 | ============== 14 | #### QQ Group:32272635 15 | #### Email:zuohong_xie@163.com 16 | 17 | Preview 18 | ============== 19 | ![preview](Screenshoot/screentshoot.gif) 20 | 21 | Installation 22 | ============== 23 | ### CocoaPods 24 | 25 | 1. Add `pod 'HZURLManager` to your Podfile. 26 | 2. Run `pod install` or `pod update`. 27 | 3. Import \. 28 | 29 | Documentation 30 | ============== 31 | Full API documentation is available on [CocoaDocs](http://cocoadocs.org/docsets/HZURLManager/).
32 | 33 | Requirements 34 | ============== 35 | This library requires `iOS 8.0+` and `Xcode 8.0+`. 36 | 37 | License 38 | ============== 39 | HZURLManager is provided under the MIT license. See LICENSE file for details. 40 | 41 | Usage 42 | ============== 43 | ### URL Config 44 | ```objective-c 45 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 46 | 47 | //Loads URL-Controller & URL-Method Config. 48 | [[HZURLManagerConfig sharedConfig] loadURLCtrlConfig:[[NSBundle mainBundle] pathForResource:@"URL-Controller-Config" ofType:@"plist"] urlMethodConfig:[[NSBundle mainBundle] pathForResource:@"URL-Method-Config" ofType:@"plist"]]; 49 | 50 | //Adds URL Rewrite rule. You may be get the rule from remote. 51 | /** 52 | The variable can be used in the target and starts with $, For example, $1 ... $n represents the value of the corresponding tuple in the regular expression, $query represents the query string part in the URL. 53 | 54 | For example, when the @{@"match":@"(?:https://)?www.hz.com/articles/(\\d)\\?(.*)",@"target":@"hz://page.hz/article?$query&id=$1"} rule is applied, the rewrite engine rewrites the source URL as hz://page.hz/article?title=cool&id=3 when we redirect to https://ww.hz.com/articles/3?title=cool , Finally we'll jump to hz://page.hz/article?title=cool&id=3. 55 | */ 56 | [[HZURLManagerConfig sharedConfig] addRewriteRules:@[@{@"match":@"(?:https://)?www.hz.com/articles/(\\d)\\?(.*)",@"target":@"hz://page.hz/article?$query&id=$1"}]]; 57 | 58 | //Configs the default name of controller for Http(s) URL. 59 | [HZURLManagerConfig sharedConfig].classOfWebViewCtrl = @"WebViewController"; 60 | } 61 | ``` 62 | ### Redirect 63 | ```objective-c 64 | //Present 65 | [URL_MANAGERN redirectToURL:@"hz://page.hz/article?title=present" animated:YES parmas:nil options:@{HZRedirectPresentMode:@(YES)} completion:nil]; 66 | 67 | //Push 68 | //The following URL will be converted to hz://page.hz/article by rewriting. 69 | [URL_MANAGERN redirectToURL:@"https://www.hz.com/articles/3?title=push" animated:YES]; 70 | 71 | ``` 72 | 73 | ### Executes Method 74 | ```objective-c 75 | @interface ShowAlertURLHandler () 76 | @end 77 | @implementation ShowAlertURLHandler 78 | /** 79 | hz://urlmanger.kit/doAlert 80 | 81 | @param title 82 | @param message 83 | */ 84 | - (id)handleURL:(NSURL *)url withParams:(id)params 85 | { 86 | NSDictionary *queryParam = url.queryDic; 87 | 88 | NSString *title = [queryParam objectForKey:@"title"]; 89 | NSString *message = [queryParam objectForKey:@"message"]; 90 | 91 | UIAlertController *alerController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; 92 | UIAlertAction *confirmAtion = [UIAlertAction actionWithTitle:@"Confirm" style:UIAlertActionStyleDefault handler:nil]; 93 | [alerController addAction:confirmAtion]; 94 | UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"Cancle" style:UIAlertActionStyleCancel handler:nil]; 95 | [alerController addAction:cancleAction]; 96 | [[HZURLNavigation currentViewController] presentViewController:alerController animated:YES completion:nil]; 97 | 98 | return nil; 99 | } 100 | 101 | @end 102 | 103 | //show the alert 104 | [URL_MANAGERN handleURL:@"hz://urlmanger.kit/doAlert?title=alert&message=URL-showAlert" withParams:nil]; 105 | ``` 106 | 107 | ### Navigation 108 | ```objective-c 109 | //Creates Controller 110 | UIViewController *controller = [UIViewController viewControllerForURL:[NSURL URLWithString:@"hz://page.hz/article"]]; 111 | 112 | //Gets current Controller 113 | UIViewController *currentViewCtrl = [HZURLNavigation currentViewController]; 114 | 115 | //Gets current Navigation Controller 116 | UIViewController *currentNavViewCtrl = [HZURLNavigation currentNavigationViewController]; 117 | 118 | //Dismiss(Pop or dissmiss) View Controller 119 | [HZURLNavigation dismissCurrentAnimated:YES]; 120 | 121 | ``` 122 | 123 | ### Param 124 | ```objective-c 125 | @interface UIViewController (HZURLManager) 126 | 127 | /** 128 | The URL corresponding to the Controller 129 | */ 130 | @property(nonatomic, strong, readonly) NSString *originURL; 131 | 132 | /** 133 | Consists of a query string and additional parameters passed by user. 134 | */ 135 | @property(nonatomic, strong, readonly) NSDictionary *params; 136 | 137 | @end 138 | ``` 139 | 140 | -------------------------------------------------------------------------------- /Screenshoot/screentshoot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeniusBrother/HZURLManager/bee4bc5d991bad2966a95c5cde6377b11966998f/Screenshoot/screentshoot.gif --------------------------------------------------------------------------------