├── .DS_Store ├── .gitignore ├── .travis.yml ├── HHRouter.podspec ├── HHRouter ├── HHRouter.h └── HHRouter.m ├── HHRouterExample.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── HHRouterExample.xcscheme ├── HHRouterExample ├── .DS_Store ├── AppDelegate.h ├── AppDelegate.m ├── HHRouterExample-Info.plist ├── HHRouterExample-Prefix.pch ├── Images.xcassets │ ├── .DS_Store │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── StoryListViewController.h ├── StoryListViewController.m ├── StoryViewController.h ├── StoryViewController.m ├── UserViewController.h ├── UserViewController.m ├── en.lproj │ └── InfoPlist.strings └── main.m ├── HHRouterExampleTests ├── HHRouterExampleTests-Info.plist ├── HHRouterTests.m └── en.lproj │ └── InfoPlist.strings ├── LICENSE └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Huohua/HHRouter/b6a35dd0d7b248a666f5681379ef925e7465028a/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | profile 15 | *.moved-aside 16 | DerivedData 17 | *.hmap 18 | *.ipa 19 | 20 | # CocoaPods 21 | Pods 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | script: xctool -project HHRouterExample.xcodeproj -scheme 'HHRouterExample' -configuration Release -sdk iphonesimulator7.0 -arch i386 build-tests 3 | -------------------------------------------------------------------------------- /HHRouter.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | version = "0.1.9" 3 | s.name = "HHRouter" 4 | s.version = version 5 | s.summary = "Yet another URL Router for iOS." 6 | s.homepage = "https://github.com/Huohua/HHRouter/" 7 | s.license = { :type => 'MIT', :file => 'LICENSE' } 8 | s.author = { "Light" => "lightory@gmail.com" } 9 | s.platform = :ios, '5.0' 10 | s.source = { :git => "https://github.com/Huohua/HHRouter.git", :tag => version } 11 | s.source_files = 'HHRouter/*' 12 | s.requires_arc = true 13 | end 14 | -------------------------------------------------------------------------------- /HHRouter/HHRouter.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2014 LIGHT lightory@gmail.com 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the “Software”), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | ///--------------- 26 | /// @name HHRouter 27 | ///--------------- 28 | 29 | typedef NS_ENUM (NSInteger, HHRouteType) { 30 | HHRouteTypeNone = 0, 31 | HHRouteTypeViewController = 1, 32 | HHRouteTypeBlock = 2 33 | }; 34 | 35 | typedef id (^HHRouterBlock)(NSDictionary *params); 36 | 37 | @interface HHRouter : NSObject 38 | 39 | + (instancetype)shared; 40 | 41 | - (void)map:(NSString *)route toControllerClass:(Class)controllerClass; 42 | - (UIViewController *)match:(NSString *)route __attribute__((deprecated)); 43 | - (UIViewController *)matchController:(NSString *)route; 44 | 45 | - (void)map:(NSString *)route toBlock:(HHRouterBlock)block; 46 | - (HHRouterBlock)matchBlock:(NSString *)route; 47 | - (id)callBlock:(NSString *)route; 48 | 49 | - (HHRouteType)canRoute:(NSString *)route; 50 | 51 | @end 52 | 53 | ///-------------------------------- 54 | /// @name UIViewController Category 55 | ///-------------------------------- 56 | 57 | @interface UIViewController (HHRouter) 58 | 59 | @property (nonatomic, strong) NSDictionary *params; 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /HHRouter/HHRouter.m: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2014 LIGHT lightory@gmail.com 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the “Software”), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "HHRouter.h" 24 | #import 25 | 26 | @interface HHRouter () 27 | @property (strong, nonatomic) NSMutableDictionary *routes; 28 | @end 29 | 30 | @implementation HHRouter 31 | 32 | + (instancetype)shared 33 | { 34 | static HHRouter *router = nil; 35 | static dispatch_once_t onceToken; 36 | 37 | dispatch_once(&onceToken, ^{ 38 | if (!router) { 39 | router = [[self alloc] init]; 40 | } 41 | }); 42 | return router; 43 | } 44 | 45 | - (void)map:(NSString *)route toBlock:(HHRouterBlock)block 46 | { 47 | NSMutableDictionary *subRoutes = [self subRoutesToRoute:route]; 48 | 49 | subRoutes[@"_"] = [block copy]; 50 | } 51 | 52 | - (UIViewController *)matchController:(NSString *)route 53 | { 54 | NSDictionary *params = [self paramsInRoute:route]; 55 | Class controllerClass = params[@"controller_class"]; 56 | 57 | UIViewController *viewController = [[controllerClass alloc] init]; 58 | 59 | if ([viewController respondsToSelector:@selector(setParams:)]) { 60 | [viewController performSelector:@selector(setParams:) 61 | withObject:[params copy]]; 62 | } 63 | return viewController; 64 | } 65 | 66 | - (UIViewController *)match:(NSString *)route 67 | { 68 | return [self matchController:route]; 69 | } 70 | 71 | - (HHRouterBlock)matchBlock:(NSString *)route 72 | { 73 | NSDictionary *params = [self paramsInRoute:route]; 74 | 75 | if (!params){ 76 | return nil; 77 | } 78 | 79 | HHRouterBlock routerBlock = [params[@"block"] copy]; 80 | HHRouterBlock returnBlock = ^id(NSDictionary *aParams) { 81 | if (routerBlock) { 82 | NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:params]; 83 | [dic addEntriesFromDictionary:aParams]; 84 | return routerBlock([NSDictionary dictionaryWithDictionary:dic].copy); 85 | } 86 | return nil; 87 | }; 88 | 89 | return [returnBlock copy]; 90 | } 91 | 92 | - (id)callBlock:(NSString *)route 93 | { 94 | NSDictionary *params = [self paramsInRoute:route]; 95 | HHRouterBlock routerBlock = [params[@"block"] copy]; 96 | 97 | if (routerBlock) { 98 | return routerBlock([params copy]); 99 | } 100 | return nil; 101 | } 102 | 103 | // extract params in a route 104 | - (NSDictionary *)paramsInRoute:(NSString *)route 105 | { 106 | NSMutableDictionary *params = [NSMutableDictionary dictionary]; 107 | 108 | params[@"route"] = [self stringFromFilterAppUrlScheme:route]; 109 | 110 | NSMutableDictionary *subRoutes = self.routes; 111 | NSArray *pathComponents = [self pathComponentsFromRoute:params[@"route"]]; 112 | for (NSString *pathComponent in pathComponents) { 113 | BOOL found = NO; 114 | NSArray *subRoutesKeys = subRoutes.allKeys; 115 | for (NSString *key in subRoutesKeys) { 116 | if ([subRoutesKeys containsObject:pathComponent]) { 117 | found = YES; 118 | subRoutes = subRoutes[pathComponent]; 119 | break; 120 | } else if ([key hasPrefix:@":"]) { 121 | found = YES; 122 | subRoutes = subRoutes[key]; 123 | params[[key substringFromIndex:1]] = pathComponent; 124 | break; 125 | } 126 | } 127 | if (!found) { 128 | return nil; 129 | } 130 | } 131 | 132 | // Extract Params From Query. 133 | NSRange firstRange = [route rangeOfString:@"?"]; 134 | if (firstRange.location != NSNotFound && route.length > firstRange.location + firstRange.length) { 135 | NSString *paramsString = [route substringFromIndex:firstRange.location + firstRange.length]; 136 | NSArray *paramStringArr = [paramsString componentsSeparatedByString:@"&"]; 137 | for (NSString *paramString in paramStringArr) { 138 | NSArray *paramArr = [paramString componentsSeparatedByString:@"="]; 139 | if (paramArr.count > 1) { 140 | NSString *key = [paramArr objectAtIndex:0]; 141 | NSString *value = [paramArr objectAtIndex:1]; 142 | params[key] = value; 143 | } 144 | } 145 | } 146 | 147 | Class class = subRoutes[@"_"]; 148 | if (class_isMetaClass(object_getClass(class))) { 149 | if ([class isSubclassOfClass:[UIViewController class]]) { 150 | params[@"controller_class"] = subRoutes[@"_"]; 151 | } else { 152 | return nil; 153 | } 154 | } else { 155 | if (subRoutes[@"_"]) { 156 | params[@"block"] = [subRoutes[@"_"] copy]; 157 | } 158 | } 159 | 160 | return [NSDictionary dictionaryWithDictionary:params]; 161 | } 162 | 163 | #pragma mark - Private 164 | 165 | - (NSMutableDictionary *)routes 166 | { 167 | if (!_routes) { 168 | _routes = [[NSMutableDictionary alloc] init]; 169 | } 170 | 171 | return _routes; 172 | } 173 | 174 | - (NSArray *)pathComponentsFromRoute:(NSString *)route 175 | { 176 | NSMutableArray *pathComponents = [NSMutableArray array]; 177 | NSURL *url = [NSURL URLWithString:[route stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 178 | 179 | for (NSString *pathComponent in url.path.pathComponents) { 180 | if ([pathComponent isEqualToString:@"/"]) continue; 181 | if ([[pathComponent substringToIndex:1] isEqualToString:@"?"]) break; 182 | [pathComponents addObject:[pathComponent stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 183 | } 184 | 185 | return [pathComponents copy]; 186 | } 187 | 188 | - (NSString *)stringFromFilterAppUrlScheme:(NSString *)string 189 | { 190 | // filter out the app URL compontents. 191 | for (NSString *appUrlScheme in [self appUrlSchemes]) { 192 | if ([string hasPrefix:[NSString stringWithFormat:@"%@:", appUrlScheme]]) { 193 | return [string substringFromIndex:appUrlScheme.length + 2]; 194 | } 195 | } 196 | 197 | return string; 198 | } 199 | 200 | - (NSArray *)appUrlSchemes 201 | { 202 | NSMutableArray *appUrlSchemes = [NSMutableArray array]; 203 | 204 | NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; 205 | 206 | for (NSDictionary *dic in infoDictionary[@"CFBundleURLTypes"]) { 207 | NSString *appUrlScheme = dic[@"CFBundleURLSchemes"][0]; 208 | [appUrlSchemes addObject:appUrlScheme]; 209 | } 210 | 211 | return [appUrlSchemes copy]; 212 | } 213 | 214 | - (NSMutableDictionary *)subRoutesToRoute:(NSString *)route 215 | { 216 | NSArray *pathComponents = [self pathComponentsFromRoute:route]; 217 | 218 | NSInteger index = 0; 219 | NSMutableDictionary *subRoutes = self.routes; 220 | 221 | while (index < pathComponents.count) { 222 | NSString *pathComponent = pathComponents[index]; 223 | if (![subRoutes objectForKey:pathComponent]) { 224 | subRoutes[pathComponent] = [[NSMutableDictionary alloc] init]; 225 | } 226 | subRoutes = subRoutes[pathComponent]; 227 | index++; 228 | } 229 | 230 | return subRoutes; 231 | } 232 | 233 | - (void)map:(NSString *)route toControllerClass:(Class)controllerClass 234 | { 235 | NSMutableDictionary *subRoutes = [self subRoutesToRoute:route]; 236 | 237 | subRoutes[@"_"] = controllerClass; 238 | } 239 | 240 | - (HHRouteType)canRoute:(NSString *)route 241 | { 242 | NSDictionary *params = [self paramsInRoute:route]; 243 | 244 | if (params[@"controller_class"]) { 245 | return HHRouteTypeViewController; 246 | } 247 | 248 | if (params[@"block"]) { 249 | return HHRouteTypeBlock; 250 | } 251 | 252 | return HHRouteTypeNone; 253 | } 254 | 255 | @end 256 | 257 | #pragma mark - UIViewController Category 258 | 259 | @implementation UIViewController (HHRouter) 260 | 261 | static char kAssociatedParamsObjectKey; 262 | 263 | - (void)setParams:(NSDictionary *)paramsDictionary 264 | { 265 | objc_setAssociatedObject(self, &kAssociatedParamsObjectKey, paramsDictionary, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 266 | } 267 | 268 | - (NSDictionary *)params 269 | { 270 | return objc_getAssociatedObject(self, &kAssociatedParamsObjectKey); 271 | } 272 | 273 | @end 274 | -------------------------------------------------------------------------------- /HHRouterExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A02D396618D1B21F00291FE9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A02D396518D1B21F00291FE9 /* Foundation.framework */; }; 11 | A02D396A18D1B21F00291FE9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A02D396918D1B21F00291FE9 /* UIKit.framework */; }; 12 | A02D397018D1B21F00291FE9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A02D396E18D1B21F00291FE9 /* InfoPlist.strings */; }; 13 | A02D397218D1B21F00291FE9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A02D397118D1B21F00291FE9 /* main.m */; }; 14 | A02D397618D1B21F00291FE9 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A02D397518D1B21F00291FE9 /* AppDelegate.m */; }; 15 | A02D397818D1B21F00291FE9 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A02D397718D1B21F00291FE9 /* Images.xcassets */; }; 16 | A02D397F18D1B21F00291FE9 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A02D397E18D1B21F00291FE9 /* XCTest.framework */; }; 17 | A02D398018D1B21F00291FE9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A02D396518D1B21F00291FE9 /* Foundation.framework */; }; 18 | A02D398118D1B21F00291FE9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A02D396918D1B21F00291FE9 /* UIKit.framework */; }; 19 | A02D398918D1B21F00291FE9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A02D398718D1B21F00291FE9 /* InfoPlist.strings */; }; 20 | A02D399718D1B25500291FE9 /* HHRouter.m in Sources */ = {isa = PBXBuildFile; fileRef = A02D399618D1B25500291FE9 /* HHRouter.m */; }; 21 | A02D399818D1B25500291FE9 /* HHRouter.m in Sources */ = {isa = PBXBuildFile; fileRef = A02D399618D1B25500291FE9 /* HHRouter.m */; }; 22 | A02D399A18D1B34500291FE9 /* HHRouterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A02D399918D1B34500291FE9 /* HHRouterTests.m */; }; 23 | A02D399E18D2D9F100291FE9 /* UserViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A02D399D18D2D9F100291FE9 /* UserViewController.m */; }; 24 | A02D399F18D2D9F100291FE9 /* UserViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A02D399D18D2D9F100291FE9 /* UserViewController.m */; }; 25 | A02D39A218D2DA0200291FE9 /* StoryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A02D39A118D2DA0200291FE9 /* StoryViewController.m */; }; 26 | A02D39A318D2DA0200291FE9 /* StoryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A02D39A118D2DA0200291FE9 /* StoryViewController.m */; }; 27 | A02D39A618D2DA3F00291FE9 /* StoryListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A02D39A518D2DA3F00291FE9 /* StoryListViewController.m */; }; 28 | A02D39A718D2DA3F00291FE9 /* StoryListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A02D39A518D2DA3F00291FE9 /* StoryListViewController.m */; }; 29 | /* End PBXBuildFile section */ 30 | 31 | /* Begin PBXContainerItemProxy section */ 32 | A02D398218D1B21F00291FE9 /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = A02D395A18D1B21F00291FE9 /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = A02D396118D1B21F00291FE9; 37 | remoteInfo = HHRouterExample; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | A02D396218D1B21F00291FE9 /* HHRouterExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HHRouterExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | A02D396518D1B21F00291FE9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 44 | A02D396918D1B21F00291FE9 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 45 | A02D396D18D1B21F00291FE9 /* HHRouterExample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "HHRouterExample-Info.plist"; sourceTree = ""; }; 46 | A02D396F18D1B21F00291FE9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 47 | A02D397118D1B21F00291FE9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 48 | A02D397318D1B21F00291FE9 /* HHRouterExample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "HHRouterExample-Prefix.pch"; sourceTree = ""; }; 49 | A02D397418D1B21F00291FE9 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 50 | A02D397518D1B21F00291FE9 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 51 | A02D397718D1B21F00291FE9 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 52 | A02D397D18D1B21F00291FE9 /* HHRouterExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HHRouterExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | A02D397E18D1B21F00291FE9 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 54 | A02D398618D1B21F00291FE9 /* HHRouterExampleTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "HHRouterExampleTests-Info.plist"; sourceTree = ""; }; 55 | A02D398818D1B21F00291FE9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 56 | A02D399518D1B25500291FE9 /* HHRouter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HHRouter.h; sourceTree = ""; }; 57 | A02D399618D1B25500291FE9 /* HHRouter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HHRouter.m; sourceTree = ""; }; 58 | A02D399918D1B34500291FE9 /* HHRouterTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HHRouterTests.m; sourceTree = ""; }; 59 | A02D399C18D2D9F100291FE9 /* UserViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserViewController.h; sourceTree = ""; }; 60 | A02D399D18D2D9F100291FE9 /* UserViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserViewController.m; sourceTree = ""; }; 61 | A02D39A018D2DA0200291FE9 /* StoryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StoryViewController.h; sourceTree = ""; }; 62 | A02D39A118D2DA0200291FE9 /* StoryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StoryViewController.m; sourceTree = ""; }; 63 | A02D39A418D2DA3F00291FE9 /* StoryListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StoryListViewController.h; sourceTree = ""; }; 64 | A02D39A518D2DA3F00291FE9 /* StoryListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StoryListViewController.m; sourceTree = ""; }; 65 | /* End PBXFileReference section */ 66 | 67 | /* Begin PBXFrameworksBuildPhase section */ 68 | A02D395F18D1B21F00291FE9 /* Frameworks */ = { 69 | isa = PBXFrameworksBuildPhase; 70 | buildActionMask = 2147483647; 71 | files = ( 72 | A02D396A18D1B21F00291FE9 /* UIKit.framework in Frameworks */, 73 | A02D396618D1B21F00291FE9 /* Foundation.framework in Frameworks */, 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | A02D397A18D1B21F00291FE9 /* Frameworks */ = { 78 | isa = PBXFrameworksBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | A02D397F18D1B21F00291FE9 /* XCTest.framework in Frameworks */, 82 | A02D398118D1B21F00291FE9 /* UIKit.framework in Frameworks */, 83 | A02D398018D1B21F00291FE9 /* Foundation.framework in Frameworks */, 84 | ); 85 | runOnlyForDeploymentPostprocessing = 0; 86 | }; 87 | /* End PBXFrameworksBuildPhase section */ 88 | 89 | /* Begin PBXGroup section */ 90 | A02D395918D1B21F00291FE9 = { 91 | isa = PBXGroup; 92 | children = ( 93 | A02D399418D1B24300291FE9 /* HHRouter */, 94 | A02D396B18D1B21F00291FE9 /* HHRouterExample */, 95 | A02D398418D1B21F00291FE9 /* HHRouterExampleTests */, 96 | A02D396418D1B21F00291FE9 /* Frameworks */, 97 | A02D396318D1B21F00291FE9 /* Products */, 98 | ); 99 | sourceTree = ""; 100 | }; 101 | A02D396318D1B21F00291FE9 /* Products */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | A02D396218D1B21F00291FE9 /* HHRouterExample.app */, 105 | A02D397D18D1B21F00291FE9 /* HHRouterExampleTests.xctest */, 106 | ); 107 | name = Products; 108 | sourceTree = ""; 109 | }; 110 | A02D396418D1B21F00291FE9 /* Frameworks */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | A02D396518D1B21F00291FE9 /* Foundation.framework */, 114 | A02D396918D1B21F00291FE9 /* UIKit.framework */, 115 | A02D397E18D1B21F00291FE9 /* XCTest.framework */, 116 | ); 117 | name = Frameworks; 118 | sourceTree = ""; 119 | }; 120 | A02D396B18D1B21F00291FE9 /* HHRouterExample */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | A02D397418D1B21F00291FE9 /* AppDelegate.h */, 124 | A02D397518D1B21F00291FE9 /* AppDelegate.m */, 125 | A02D397718D1B21F00291FE9 /* Images.xcassets */, 126 | A02D396C18D1B21F00291FE9 /* Supporting Files */, 127 | A02D399C18D2D9F100291FE9 /* UserViewController.h */, 128 | A02D399D18D2D9F100291FE9 /* UserViewController.m */, 129 | A02D39A018D2DA0200291FE9 /* StoryViewController.h */, 130 | A02D39A118D2DA0200291FE9 /* StoryViewController.m */, 131 | A02D39A418D2DA3F00291FE9 /* StoryListViewController.h */, 132 | A02D39A518D2DA3F00291FE9 /* StoryListViewController.m */, 133 | ); 134 | path = HHRouterExample; 135 | sourceTree = ""; 136 | }; 137 | A02D396C18D1B21F00291FE9 /* Supporting Files */ = { 138 | isa = PBXGroup; 139 | children = ( 140 | A02D396D18D1B21F00291FE9 /* HHRouterExample-Info.plist */, 141 | A02D396E18D1B21F00291FE9 /* InfoPlist.strings */, 142 | A02D397118D1B21F00291FE9 /* main.m */, 143 | A02D397318D1B21F00291FE9 /* HHRouterExample-Prefix.pch */, 144 | ); 145 | name = "Supporting Files"; 146 | sourceTree = ""; 147 | }; 148 | A02D398418D1B21F00291FE9 /* HHRouterExampleTests */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | A02D399918D1B34500291FE9 /* HHRouterTests.m */, 152 | A02D398518D1B21F00291FE9 /* Supporting Files */, 153 | ); 154 | path = HHRouterExampleTests; 155 | sourceTree = ""; 156 | }; 157 | A02D398518D1B21F00291FE9 /* Supporting Files */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | A02D398618D1B21F00291FE9 /* HHRouterExampleTests-Info.plist */, 161 | A02D398718D1B21F00291FE9 /* InfoPlist.strings */, 162 | ); 163 | name = "Supporting Files"; 164 | sourceTree = ""; 165 | }; 166 | A02D399418D1B24300291FE9 /* HHRouter */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | A02D399518D1B25500291FE9 /* HHRouter.h */, 170 | A02D399618D1B25500291FE9 /* HHRouter.m */, 171 | ); 172 | path = HHRouter; 173 | sourceTree = ""; 174 | }; 175 | /* End PBXGroup section */ 176 | 177 | /* Begin PBXNativeTarget section */ 178 | A02D396118D1B21F00291FE9 /* HHRouterExample */ = { 179 | isa = PBXNativeTarget; 180 | buildConfigurationList = A02D398E18D1B22000291FE9 /* Build configuration list for PBXNativeTarget "HHRouterExample" */; 181 | buildPhases = ( 182 | A02D395E18D1B21F00291FE9 /* Sources */, 183 | A02D395F18D1B21F00291FE9 /* Frameworks */, 184 | A02D396018D1B21F00291FE9 /* Resources */, 185 | ); 186 | buildRules = ( 187 | ); 188 | dependencies = ( 189 | ); 190 | name = HHRouterExample; 191 | productName = HHRouterExample; 192 | productReference = A02D396218D1B21F00291FE9 /* HHRouterExample.app */; 193 | productType = "com.apple.product-type.application"; 194 | }; 195 | A02D397C18D1B21F00291FE9 /* HHRouterExampleTests */ = { 196 | isa = PBXNativeTarget; 197 | buildConfigurationList = A02D399118D1B22000291FE9 /* Build configuration list for PBXNativeTarget "HHRouterExampleTests" */; 198 | buildPhases = ( 199 | A02D397918D1B21F00291FE9 /* Sources */, 200 | A02D397A18D1B21F00291FE9 /* Frameworks */, 201 | A02D397B18D1B21F00291FE9 /* Resources */, 202 | ); 203 | buildRules = ( 204 | ); 205 | dependencies = ( 206 | A02D398318D1B21F00291FE9 /* PBXTargetDependency */, 207 | ); 208 | name = HHRouterExampleTests; 209 | productName = HHRouterExampleTests; 210 | productReference = A02D397D18D1B21F00291FE9 /* HHRouterExampleTests.xctest */; 211 | productType = "com.apple.product-type.bundle.unit-test"; 212 | }; 213 | /* End PBXNativeTarget section */ 214 | 215 | /* Begin PBXProject section */ 216 | A02D395A18D1B21F00291FE9 /* Project object */ = { 217 | isa = PBXProject; 218 | attributes = { 219 | LastUpgradeCheck = 0510; 220 | ORGANIZATIONNAME = Huohua; 221 | TargetAttributes = { 222 | A02D397C18D1B21F00291FE9 = { 223 | TestTargetID = A02D396118D1B21F00291FE9; 224 | }; 225 | }; 226 | }; 227 | buildConfigurationList = A02D395D18D1B21F00291FE9 /* Build configuration list for PBXProject "HHRouterExample" */; 228 | compatibilityVersion = "Xcode 3.2"; 229 | developmentRegion = English; 230 | hasScannedForEncodings = 0; 231 | knownRegions = ( 232 | en, 233 | ); 234 | mainGroup = A02D395918D1B21F00291FE9; 235 | productRefGroup = A02D396318D1B21F00291FE9 /* Products */; 236 | projectDirPath = ""; 237 | projectRoot = ""; 238 | targets = ( 239 | A02D396118D1B21F00291FE9 /* HHRouterExample */, 240 | A02D397C18D1B21F00291FE9 /* HHRouterExampleTests */, 241 | ); 242 | }; 243 | /* End PBXProject section */ 244 | 245 | /* Begin PBXResourcesBuildPhase section */ 246 | A02D396018D1B21F00291FE9 /* Resources */ = { 247 | isa = PBXResourcesBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | A02D397018D1B21F00291FE9 /* InfoPlist.strings in Resources */, 251 | A02D397818D1B21F00291FE9 /* Images.xcassets in Resources */, 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | A02D397B18D1B21F00291FE9 /* Resources */ = { 256 | isa = PBXResourcesBuildPhase; 257 | buildActionMask = 2147483647; 258 | files = ( 259 | A02D398918D1B21F00291FE9 /* InfoPlist.strings in Resources */, 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | /* End PBXResourcesBuildPhase section */ 264 | 265 | /* Begin PBXSourcesBuildPhase section */ 266 | A02D395E18D1B21F00291FE9 /* Sources */ = { 267 | isa = PBXSourcesBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | A02D397618D1B21F00291FE9 /* AppDelegate.m in Sources */, 271 | A02D399E18D2D9F100291FE9 /* UserViewController.m in Sources */, 272 | A02D39A618D2DA3F00291FE9 /* StoryListViewController.m in Sources */, 273 | A02D39A218D2DA0200291FE9 /* StoryViewController.m in Sources */, 274 | A02D397218D1B21F00291FE9 /* main.m in Sources */, 275 | A02D399718D1B25500291FE9 /* HHRouter.m in Sources */, 276 | ); 277 | runOnlyForDeploymentPostprocessing = 0; 278 | }; 279 | A02D397918D1B21F00291FE9 /* Sources */ = { 280 | isa = PBXSourcesBuildPhase; 281 | buildActionMask = 2147483647; 282 | files = ( 283 | A02D39A318D2DA0200291FE9 /* StoryViewController.m in Sources */, 284 | A02D399F18D2D9F100291FE9 /* UserViewController.m in Sources */, 285 | A02D39A718D2DA3F00291FE9 /* StoryListViewController.m in Sources */, 286 | A02D399818D1B25500291FE9 /* HHRouter.m in Sources */, 287 | A02D399A18D1B34500291FE9 /* HHRouterTests.m in Sources */, 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | }; 291 | /* End PBXSourcesBuildPhase section */ 292 | 293 | /* Begin PBXTargetDependency section */ 294 | A02D398318D1B21F00291FE9 /* PBXTargetDependency */ = { 295 | isa = PBXTargetDependency; 296 | target = A02D396118D1B21F00291FE9 /* HHRouterExample */; 297 | targetProxy = A02D398218D1B21F00291FE9 /* PBXContainerItemProxy */; 298 | }; 299 | /* End PBXTargetDependency section */ 300 | 301 | /* Begin PBXVariantGroup section */ 302 | A02D396E18D1B21F00291FE9 /* InfoPlist.strings */ = { 303 | isa = PBXVariantGroup; 304 | children = ( 305 | A02D396F18D1B21F00291FE9 /* en */, 306 | ); 307 | name = InfoPlist.strings; 308 | sourceTree = ""; 309 | }; 310 | A02D398718D1B21F00291FE9 /* InfoPlist.strings */ = { 311 | isa = PBXVariantGroup; 312 | children = ( 313 | A02D398818D1B21F00291FE9 /* en */, 314 | ); 315 | name = InfoPlist.strings; 316 | sourceTree = ""; 317 | }; 318 | /* End PBXVariantGroup section */ 319 | 320 | /* Begin XCBuildConfiguration section */ 321 | A02D398C18D1B22000291FE9 /* Debug */ = { 322 | isa = XCBuildConfiguration; 323 | buildSettings = { 324 | ALWAYS_SEARCH_USER_PATHS = NO; 325 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 326 | CLANG_CXX_LIBRARY = "libc++"; 327 | CLANG_ENABLE_MODULES = YES; 328 | CLANG_ENABLE_OBJC_ARC = YES; 329 | CLANG_WARN_BOOL_CONVERSION = YES; 330 | CLANG_WARN_CONSTANT_CONVERSION = YES; 331 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 332 | CLANG_WARN_EMPTY_BODY = YES; 333 | CLANG_WARN_ENUM_CONVERSION = YES; 334 | CLANG_WARN_INT_CONVERSION = YES; 335 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 336 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 337 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 338 | COPY_PHASE_STRIP = NO; 339 | GCC_C_LANGUAGE_STANDARD = gnu99; 340 | GCC_DYNAMIC_NO_PIC = NO; 341 | GCC_OPTIMIZATION_LEVEL = 0; 342 | GCC_PREPROCESSOR_DEFINITIONS = ( 343 | "DEBUG=1", 344 | "$(inherited)", 345 | ); 346 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 347 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 348 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 349 | GCC_WARN_UNDECLARED_SELECTOR = YES; 350 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 351 | GCC_WARN_UNUSED_FUNCTION = YES; 352 | GCC_WARN_UNUSED_VARIABLE = YES; 353 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 354 | ONLY_ACTIVE_ARCH = YES; 355 | SDKROOT = iphoneos; 356 | }; 357 | name = Debug; 358 | }; 359 | A02D398D18D1B22000291FE9 /* Release */ = { 360 | isa = XCBuildConfiguration; 361 | buildSettings = { 362 | ALWAYS_SEARCH_USER_PATHS = NO; 363 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 364 | CLANG_CXX_LIBRARY = "libc++"; 365 | CLANG_ENABLE_MODULES = YES; 366 | CLANG_ENABLE_OBJC_ARC = YES; 367 | CLANG_WARN_BOOL_CONVERSION = YES; 368 | CLANG_WARN_CONSTANT_CONVERSION = YES; 369 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 370 | CLANG_WARN_EMPTY_BODY = YES; 371 | CLANG_WARN_ENUM_CONVERSION = YES; 372 | CLANG_WARN_INT_CONVERSION = YES; 373 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 374 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 375 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 376 | COPY_PHASE_STRIP = YES; 377 | ENABLE_NS_ASSERTIONS = NO; 378 | GCC_C_LANGUAGE_STANDARD = gnu99; 379 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 380 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 381 | GCC_WARN_UNDECLARED_SELECTOR = YES; 382 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 383 | GCC_WARN_UNUSED_FUNCTION = YES; 384 | GCC_WARN_UNUSED_VARIABLE = YES; 385 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 386 | SDKROOT = iphoneos; 387 | VALIDATE_PRODUCT = YES; 388 | }; 389 | name = Release; 390 | }; 391 | A02D398F18D1B22000291FE9 /* Debug */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 395 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 396 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 397 | GCC_PREFIX_HEADER = "HHRouterExample/HHRouterExample-Prefix.pch"; 398 | GCC_WARN_UNDECLARED_SELECTOR = NO; 399 | INFOPLIST_FILE = "HHRouterExample/HHRouterExample-Info.plist"; 400 | PRODUCT_NAME = "$(TARGET_NAME)"; 401 | WRAPPER_EXTENSION = app; 402 | }; 403 | name = Debug; 404 | }; 405 | A02D399018D1B22000291FE9 /* Release */ = { 406 | isa = XCBuildConfiguration; 407 | buildSettings = { 408 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 409 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 410 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 411 | GCC_PREFIX_HEADER = "HHRouterExample/HHRouterExample-Prefix.pch"; 412 | GCC_WARN_UNDECLARED_SELECTOR = NO; 413 | INFOPLIST_FILE = "HHRouterExample/HHRouterExample-Info.plist"; 414 | PRODUCT_NAME = "$(TARGET_NAME)"; 415 | WRAPPER_EXTENSION = app; 416 | }; 417 | name = Release; 418 | }; 419 | A02D399218D1B22000291FE9 /* Debug */ = { 420 | isa = XCBuildConfiguration; 421 | buildSettings = { 422 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/HHRouterExample.app/HHRouterExample"; 423 | FRAMEWORK_SEARCH_PATHS = ( 424 | "$(SDKROOT)/Developer/Library/Frameworks", 425 | "$(inherited)", 426 | "$(DEVELOPER_FRAMEWORKS_DIR)", 427 | ); 428 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 429 | GCC_PREFIX_HEADER = "HHRouterExample/HHRouterExample-Prefix.pch"; 430 | GCC_PREPROCESSOR_DEFINITIONS = ( 431 | "DEBUG=1", 432 | "$(inherited)", 433 | ); 434 | GCC_WARN_UNDECLARED_SELECTOR = NO; 435 | INFOPLIST_FILE = "HHRouterExampleTests/HHRouterExampleTests-Info.plist"; 436 | PRODUCT_NAME = "$(TARGET_NAME)"; 437 | TEST_HOST = "$(BUNDLE_LOADER)"; 438 | WRAPPER_EXTENSION = xctest; 439 | }; 440 | name = Debug; 441 | }; 442 | A02D399318D1B22000291FE9 /* Release */ = { 443 | isa = XCBuildConfiguration; 444 | buildSettings = { 445 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/HHRouterExample.app/HHRouterExample"; 446 | FRAMEWORK_SEARCH_PATHS = ( 447 | "$(SDKROOT)/Developer/Library/Frameworks", 448 | "$(inherited)", 449 | "$(DEVELOPER_FRAMEWORKS_DIR)", 450 | ); 451 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 452 | GCC_PREFIX_HEADER = "HHRouterExample/HHRouterExample-Prefix.pch"; 453 | GCC_WARN_UNDECLARED_SELECTOR = NO; 454 | INFOPLIST_FILE = "HHRouterExampleTests/HHRouterExampleTests-Info.plist"; 455 | PRODUCT_NAME = "$(TARGET_NAME)"; 456 | TEST_HOST = "$(BUNDLE_LOADER)"; 457 | WRAPPER_EXTENSION = xctest; 458 | }; 459 | name = Release; 460 | }; 461 | /* End XCBuildConfiguration section */ 462 | 463 | /* Begin XCConfigurationList section */ 464 | A02D395D18D1B21F00291FE9 /* Build configuration list for PBXProject "HHRouterExample" */ = { 465 | isa = XCConfigurationList; 466 | buildConfigurations = ( 467 | A02D398C18D1B22000291FE9 /* Debug */, 468 | A02D398D18D1B22000291FE9 /* Release */, 469 | ); 470 | defaultConfigurationIsVisible = 0; 471 | defaultConfigurationName = Release; 472 | }; 473 | A02D398E18D1B22000291FE9 /* Build configuration list for PBXNativeTarget "HHRouterExample" */ = { 474 | isa = XCConfigurationList; 475 | buildConfigurations = ( 476 | A02D398F18D1B22000291FE9 /* Debug */, 477 | A02D399018D1B22000291FE9 /* Release */, 478 | ); 479 | defaultConfigurationIsVisible = 0; 480 | defaultConfigurationName = Release; 481 | }; 482 | A02D399118D1B22000291FE9 /* Build configuration list for PBXNativeTarget "HHRouterExampleTests" */ = { 483 | isa = XCConfigurationList; 484 | buildConfigurations = ( 485 | A02D399218D1B22000291FE9 /* Debug */, 486 | A02D399318D1B22000291FE9 /* Release */, 487 | ); 488 | defaultConfigurationIsVisible = 0; 489 | defaultConfigurationName = Release; 490 | }; 491 | /* End XCConfigurationList section */ 492 | }; 493 | rootObject = A02D395A18D1B21F00291FE9 /* Project object */; 494 | } 495 | -------------------------------------------------------------------------------- /HHRouterExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HHRouterExample.xcodeproj/xcshareddata/xcschemes/HHRouterExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /HHRouterExample/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Huohua/HHRouter/b6a35dd0d7b248a666f5681379ef925e7465028a/HHRouterExample/.DS_Store -------------------------------------------------------------------------------- /HHRouterExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // HHRouterExample 4 | // 5 | // Created by Light (lightory@gmail.com) on 2014-03-13. 6 | // Copyright (c) 2014 Huohua. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | @property (strong, nonatomic) UIWindow *window; 13 | @end -------------------------------------------------------------------------------- /HHRouterExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // HHRouterExample 4 | // 5 | // Created by Light (lightory@gmail.com) on 2014-03-13. 6 | // Copyright (c) 2014 Huohua. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "HHRouter.h" 11 | 12 | @implementation AppDelegate 13 | 14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 15 | { 16 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 17 | self.window.backgroundColor = [UIColor whiteColor]; 18 | self.window.rootViewController = [[UIViewController alloc] init]; 19 | [self.window makeKeyAndVisible]; 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application 24 | { 25 | // 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. 26 | // 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. 27 | } 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application 30 | { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | - (void)applicationWillEnterForeground:(UIApplication *)application 36 | { 37 | // 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. 38 | } 39 | 40 | - (void)applicationDidBecomeActive:(UIApplication *)application 41 | { 42 | // 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. 43 | } 44 | 45 | - (void)applicationWillTerminate:(UIApplication *)application 46 | { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /HHRouterExample/HHRouterExample-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | in.huohua.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleURLTypes 24 | 25 | 26 | CFBundleTypeRole 27 | Editor 28 | CFBundleURLName 29 | hhrouter 30 | CFBundleURLSchemes 31 | 32 | hhrouter 33 | 34 | 35 | 36 | CFBundleTypeRole 37 | Editor 38 | CFBundleURLName 39 | hhrouter2 40 | CFBundleURLSchemes 41 | 42 | hhrouter2 43 | 44 | 45 | 46 | CFBundleVersion 47 | 1.0 48 | LSRequiresIPhoneOS 49 | 50 | UIRequiredDeviceCapabilities 51 | 52 | armv7 53 | 54 | UISupportedInterfaceOrientations 55 | 56 | UIInterfaceOrientationPortrait 57 | UIInterfaceOrientationLandscapeLeft 58 | UIInterfaceOrientationLandscapeRight 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /HHRouterExample/HHRouterExample-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_3_0 10 | #warning "This project uses features only available in iOS SDK 3.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /HHRouterExample/Images.xcassets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Huohua/HHRouter/b6a35dd0d7b248a666f5681379ef925e7465028a/HHRouterExample/Images.xcassets/.DS_Store -------------------------------------------------------------------------------- /HHRouterExample/Images.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" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /HHRouterExample/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /HHRouterExample/StoryListViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // StoryListViewController.h 3 | // HHRouterExample 4 | // 5 | // Created by Light on 14-3-14. 6 | // Copyright (c) 2014年 Huohua. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface StoryListViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HHRouterExample/StoryListViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // StoryListViewController.m 3 | // HHRouterExample 4 | // 5 | // Created by Light on 14-3-14. 6 | // Copyright (c) 2014年 Huohua. All rights reserved. 7 | // 8 | 9 | #import "StoryListViewController.h" 10 | 11 | @interface StoryListViewController () 12 | 13 | @end 14 | 15 | @implementation StoryListViewController 16 | 17 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 18 | { 19 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 20 | if (self) { 21 | // Custom initialization 22 | } 23 | return self; 24 | } 25 | 26 | - (void)viewDidLoad 27 | { 28 | [super viewDidLoad]; 29 | // Do any additional setup after loading the view. 30 | } 31 | 32 | - (void)didReceiveMemoryWarning 33 | { 34 | [super didReceiveMemoryWarning]; 35 | // Dispose of any resources that can be recreated. 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /HHRouterExample/StoryViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // StoryViewController.h 3 | // HHRouterExample 4 | // 5 | // Created by Light on 14-3-14. 6 | // Copyright (c) 2014年 Huohua. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface StoryViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HHRouterExample/StoryViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // StoryViewController.m 3 | // HHRouterExample 4 | // 5 | // Created by Light on 14-3-14. 6 | // Copyright (c) 2014年 Huohua. All rights reserved. 7 | // 8 | 9 | #import "StoryViewController.h" 10 | 11 | @interface StoryViewController () 12 | 13 | @end 14 | 15 | @implementation StoryViewController 16 | 17 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 18 | { 19 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 20 | if (self) { 21 | // Custom initialization 22 | } 23 | return self; 24 | } 25 | 26 | - (void)viewDidLoad 27 | { 28 | [super viewDidLoad]; 29 | // Do any additional setup after loading the view. 30 | } 31 | 32 | - (void)didReceiveMemoryWarning 33 | { 34 | [super didReceiveMemoryWarning]; 35 | // Dispose of any resources that can be recreated. 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /HHRouterExample/UserViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // UserViewController.h 3 | // HHRouterExample 4 | // 5 | // Created by Light on 14-3-14. 6 | // Copyright (c) 2014年 Huohua. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UserViewController : UIViewController 12 | 13 | @end -------------------------------------------------------------------------------- /HHRouterExample/UserViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // UserViewController.m 3 | // HHRouterExample 4 | // 5 | // Created by Light on 14-3-14. 6 | // Copyright (c) 2014年 Huohua. All rights reserved. 7 | // 8 | 9 | #import "UserViewController.h" 10 | 11 | @interface UserViewController () 12 | 13 | @end 14 | 15 | @implementation UserViewController 16 | 17 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 18 | { 19 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 20 | if (self) { 21 | // Custom initialization 22 | } 23 | return self; 24 | } 25 | 26 | - (void)viewDidLoad 27 | { 28 | [super viewDidLoad]; 29 | // Do any additional setup after loading the view. 30 | } 31 | 32 | - (void)didReceiveMemoryWarning 33 | { 34 | [super didReceiveMemoryWarning]; 35 | // Dispose of any resources that can be recreated. 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /HHRouterExample/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /HHRouterExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HHRouterExample 4 | // 5 | // Created by Light on 14-3-13. 6 | // Copyright (c) 2014年 Huohua. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /HHRouterExampleTests/HHRouterExampleTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | in.huohua.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /HHRouterExampleTests/HHRouterTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // HHRouterTests.m 3 | // HHRouterExample 4 | // 5 | // Created by Light (lightory@gmail.com) on 2014-03-13. 6 | // Copyright (c) 2014 Huohua. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HHRouter.h" 11 | #import "UserViewController.h" 12 | #import "StoryViewController.h" 13 | #import "StoryListViewController.h" 14 | #define TIME_OUT 5 15 | 16 | @interface HHRouterTests : XCTestCase 17 | 18 | @end 19 | 20 | @implementation HHRouterTests 21 | 22 | - (void)setUp 23 | { 24 | [super setUp]; 25 | } 26 | 27 | - (void)tearDown 28 | { 29 | [super tearDown]; 30 | } 31 | 32 | - (void)testShared 33 | { 34 | XCTAssertTrue([[HHRouter shared] isKindOfClass:[HHRouter class]]); 35 | XCTAssertTrue([[HHRouter shared] isEqual:[HHRouter shared]]); 36 | } 37 | 38 | - (void)testRouteBlocks 39 | { 40 | dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); 41 | 42 | [[HHRouter shared] map:@"/user/add/" 43 | toBlock:^id(NSDictionary* params) { 44 | XCTAssertEqualObjects(params[@"a"], @"1"); 45 | XCTAssertEqualObjects(params[@"b"], @"2"); 46 | dispatch_semaphore_signal(semaphore); 47 | }]; 48 | 49 | HHRouterBlock block = [[HHRouter shared] matchBlock:@"/user/add/?a=1&b=2"]; 50 | XCTAssertNotNil(block); 51 | block(nil); 52 | while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW)) { 53 | [[NSRunLoop currentRunLoop] 54 | runMode:NSDefaultRunLoopMode 55 | beforeDate:[NSDate dateWithTimeIntervalSinceNow:TIME_OUT]]; 56 | } 57 | [[HHRouter shared] callBlock:@"/user/add/?a=1&b=2"]; 58 | } 59 | 60 | - (void)testRoute 61 | { 62 | [[HHRouter shared] map:@"/user/:userId/" 63 | toControllerClass:[UserViewController class]]; 64 | [[HHRouter shared] map:@"/story/:storyId/" 65 | toControllerClass:[StoryViewController class]]; 66 | [[HHRouter shared] map:@"/user/:userId/story/" 67 | toControllerClass:[StoryListViewController class]]; 68 | 69 | XCTAssertEqualObjects( 70 | [[[HHRouter shared] matchController:@"/story/2/"] class], 71 | [StoryViewController class]); 72 | XCTAssertEqualObjects( 73 | [[[HHRouter shared] matchController:@"/user/1/story/"] class], 74 | [StoryListViewController class]); 75 | 76 | // XCTAssertEqualObjects( 77 | // [[[HHRouter shared] matchController:@"hhrouter://user/1/"] class], 78 | // [UserViewController class]); 79 | 80 | UserViewController* userViewController = (UserViewController*) 81 | [[HHRouter shared] matchController:@"/user/1/?a=b&c=d"]; 82 | XCTAssertEqualObjects(userViewController.params[@"route"], 83 | @"/user/1/?a=b&c=d"); 84 | XCTAssertEqualObjects(userViewController.params[@"userId"], @"1"); 85 | XCTAssertEqualObjects(userViewController.params[@"a"], @"b"); 86 | XCTAssertEqualObjects(userViewController.params[@"c"], @"d"); 87 | 88 | 89 | 90 | [[HHRouter shared] map:@"/test/:someId/" 91 | toControllerClass:[StoryListViewController class]]; 92 | 93 | 94 | 95 | UserViewController* userViewController1 = (UserViewController*) 96 | [[HHRouter shared] matchController:@"/test/7777777?aa=11&bb=22"]; 97 | NSLog(@"%@", userViewController1.params); 98 | 99 | 100 | UserViewController* userViewController2 = (UserViewController*) 101 | [[HHRouter shared] matchController:@"/test/7777777"]; 102 | NSLog(@"%@", userViewController2.params); 103 | 104 | UserViewController* userViewController3 = (UserViewController*) 105 | [[HHRouter shared] matchController:@"/test/7777777/?aa=11&bb=22"]; 106 | NSLog(@"%@", userViewController3.params); 107 | 108 | 109 | } 110 | 111 | @end -------------------------------------------------------------------------------- /HHRouterExampleTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 LIGHT lightory@gmail.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | HHRouter 2 | ===== 3 | [![Build Status](https://travis-ci.org/Huohua/HHRouter.png)](https://travis-ci.org/Huohua/HHRouter) 4 | [![CocoaPods](https://cocoapod-badges.herokuapp.com/v/HHRouter/badge.png)](http://cocoapods.org/?q=HHRouter) 5 | 6 | Yet another URL Router for iOS. Clean, Fast & Flexible. Inspired by [ABRouter](https://github.com/aaronbrethorst/ABRouter) & [Routable iOS](https://github.com/usepropeller/routable-ios). 7 | 8 | ## Usage 9 | 10 | ### Warm Up 11 | 12 | Map URL patterns to viewController. Better in AppDelegate. 13 | 14 | ```objective-c 15 | [[HHRouter shared] map:@"/user/:userId/" toControllerClass:[UserViewController class]]; 16 | ``` 17 | 18 | ### Exciting Time 19 | Get viewController instance from URL. Params will be parsed automatically. 20 | 21 | ```objective-c 22 | UIViewController *viewController = [[HHRouter shared] matchController:@"/user/1/"]; 23 | ``` 24 | 25 | ```objective-c 26 | XCTAssertEqualObjects([viewController class], [UserViewController class]); 27 | XCTAssertEqualObjects(viewController.params[@"route"], @"/user/1/"); 28 | XCTAssertEqualObjects(viewController.params[@"userId"], @"1"); 29 | ``` 30 | 31 | ### URL Query Params 32 | 33 | URL Query Params is also supported, which will make things VERY flexible. 34 | 35 | ```objective-c 36 | UIViewController *viewController = [[HHRouter shared] matchController:@"/user/1/?tabIndex=3"]; 37 | ``` 38 | 39 | ```objective-c 40 | XCTAssertEqualObjects(viewController.params[@"tabIndex"], @"3"); 41 | ``` 42 | 43 | ### One More Thing 44 | 45 | If your app has defined some URL schemes, HHRouter will know. 46 | 47 | ```objective-c 48 | UIViewController *viewController = [[HHRouter shared] matchController:@"hhrouter://user/1/"]; 49 | ``` 50 | 51 | ```objective-c 52 | XCTAssertEqualObjects([viewController class], [UserViewController class]); 53 | ``` 54 | 55 | ## Installation 56 | ### [CocoaPods](http://cocoapods.org/) 57 | 58 | ```ruby 59 | pod 'HHRouter', '~> 0.1.8' 60 | ``` 61 | 62 | ```objective-c 63 | #import 64 | ``` 65 | 66 | If you're not able to use CocoaPods, please install HHRouter as a [git submodule](http://schacon.github.com/git/user-manual.html#submodules) and add the files to your Xcode project. 67 | 68 | ## We're Hiring! 69 | [http://pudding.cc/opportunity/](http://pudding.cc/opportunity/) 70 | 71 | ## Contact 72 | - [lightory@gmail.com](mailto:lightory@gmail.com) 73 | - [http://twitter.com/lightory/](http://twitter.com/lightory/) 74 | 75 | ## Who use HHRouter? 76 | If you're building your applications using HHRouter, please let me know! (add your application name & App Store link here and pull reuqest this README. 77 | 78 | - 布丁动画: [https://itunes.apple.com/cn/app/bu-ding-dong-hua-zui-liang/id869243194?l=zh&ls=1&mt=8](https://itunes.apple.com/cn/app/bu-ding-dong-hua-zui-liang/id869243194?l=zh&ls=1&mt=8) 79 | 80 | 81 | ## License 82 | HHRouter is available under the [MIT license](https://github.com/Huohua/HHRouter/blob/master/LICENSE). 83 | --------------------------------------------------------------------------------