Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JLRoutesについて

ninjinkun
March 12, 2014

 JLRoutesについて

ninjinkun

March 12, 2014
Tweet

More Decks by ninjinkun

Other Decks in Technology

Transcript

  1. J04ΞϓϦͱ63-εΩʔϜ ࣮૷ྫ -(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { if ([url.path isEqualToString:@“/search"])

    { NSString *searchQuery; NSArray *queries = [url.query componentsSeparatedByString:@"&"]; for (NSString *query in queries) { NSArray *keyValue = [query componentsSeparatedByString:@"="]; if (keyValue.count == 2) { if ([keyValue[0] isEqualToString:@"q"]) { searchQuery = keyValue[1]; // Search query found!! } } } ! SearchResultViewController *viewController = [[SearchResultViewController alloc] initWithQuery:query]; [self showViewController:viewController]; return YES; } } OKLTFBSDI RQPUBUPUJQT
  2. J04ΞϓϦͱ63-εΩʔϜ w ϧʔςΟϯάͷϧʔϧهड़ͱॲཧ͕෼཭͞Ε͍ͯͳ͍ w "QQ%FMFHBUFʹ΂ͨॻ͖͕ͪ͠ w JGจ͕ͲΜͲΜ૿͍͑ͯ͘ w ΫΤϦΛखͰύʔε͍ͯ͠Δ w

    /463-ʹ͸ΫΤϦΛߏ଄ମͱͯ͠औΓग़͢࢓૊Έ͕ ͳ͍ w ΈΜͳΦϨΦϨΫΤϦύʔαʔΛ࣋ͭΑ͏ʹͳΔ Կ͕໰୊͔
  3. +-3PVUFT ࢖͍ํ JLRoutes *router = [JLRoutes routesForScheme:@“njk"]; ! [router addRoute:@"/search"

    handler:^BOOL(NSDictionary *parameters) { NSString *searchQuery = parameters[@“q"]; ! SearchResultViewController *viewController = [[SearchResultViewController alloc] initWithQuery:searchQuery]; [self showViewController:viewController]; return YES; }]; ! [router addRoute:@"/users/:user_id" handler:^BOOL(NSDictionary *parameters) { NSString *userId = parameters[@"user_id"]; ! UserViewController *viewController = [[UserViewController alloc] init]; viewController.userId = userId; [self showViewController:viewController]; return YES; }];
  4. ଞϥΠϒϥϦͱͷൺֱ w /JNCVT,JUTPDLJU w 4USJOH0CKFDU$PEJOHGPS0CKFDUJWF$ w จࣈྻͷύλʔϯ͔ΒΦϒδΣΫτͷੜ੒·Ͱ΍ͬͯ͘ΕΔ w SPVUBCMFJPT w

    63-6*7JFX$POUSPMMFS w ֎෦͔Β63-εΩʔϚΛىಈ͢Δ͜ͱ͸૝ఆ͍ͯ͠ͳͦ͞͏ w +-3PVUFT w 63-ͱCMPDLTͷσΟεύον͚ͩʹಛԽͯ͠γϯϓϧ
  5.  "3$@45"/%"3% ໰୊ w 9DPEF w "3$@45"/%"3%BSNWBSNWT w 9DPEF w

    "3$@45"/%"3%BSNWBSNWTBSN ! w CJUະରԠͷϥΠϒϥϦ͕͍ࠞͬͯ͟ΔͱϏϧυͰ ͖ͳ͍
  6.  "3$@45"/%"3% ໰୊ w खͰࢦఆ͢Δͱ$PDPB1PETͰ͚͜Δ ! ! ! ! w

    ෳ਺ͷ"3$)4ΛϋϯυϦϯάͰ͖ͳ͍όά ͕͋Δ $PDPB1PET
  7.  "3$@45"/%"3% ໰୊ w  45"/%"3%@"3$)@@#*5 Λ࢖͑͹ղܾ ! ! w

    ݁ہ͸CJUରԠ͕ਖ਼ಓ w ͓࢖͍ͷϥΠϒϥϦ͕CJUରԠ͢ΔΛ଴ͪ·͠ΐ͏ 4PMVUJPO