SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
永島 次朗 / Jiro Nagashima

iOS Developer @ nana music, inc.




           @hedjirog
RestKit / Examples / RKTwitter
サンプルプロジェクト
• 動作手順
   • リポジトリを複製 (masterブランチ)
   • Examplesディレクトリ下のプロジェクトを開く
   • Build & Run
$ git clone -b master --recursive git://github.com/RestKit/RestKit.git

$ open RestKit/Examples/RKTwitter/RKTwitter.xcodeproj


              ※ 同時に複数のサンプルプロジェクトを開くと、
           (サブプロジェクトとして含まれるRestKitの参照に失敗して)
                 ビルドエラーになる場合があるので注意
サンプルプロジェクト(補足)
           Submoduleを含むリポジトリ複製



               recursiveオプションを付与
             (clone後のsubmodule更新)
$ git clone -b master --recursive git://github.com/RestKit/RestKit.git

$ open RestKit/Examples/RKTwitter/RKTwitter.xcodeproj
Agenda
• RestKitとは
 • 導入手順
 • 注意点
• 基本的な使い方
 • Networking, Object Mapping, Core Data
RestKitとは
RestKitとは



                           Networking
Object Mapping
                 RestKit
                             Core Data
RestKitとは
   Webサービスのクライアント実装を
          強力にサポート!!


                           Networking
Object Mapping
                 RestKit
                             Core Data
RestKitとは
           • RestKit
            • http://restkit.org/
           • Github project page
            • https://github.com/RestKit/
              RestKit
RestKit
導入手順
• CocoaPodsを利用(推奨)
 • https://github.com/RestKit/RestKit#via-
   cocoapods
 • http://cocoapods.org/?q=RestKit
注意点
• iOS 5.0 以上が必須
• ARC
• 最新バージョンに pre の表記 (2013.01.26現在)
 • https://github.com/RestKit/RestKit/tags
• Apache License 2.0
Agenda
  RestKitとは
    導入手順
    注意点

• 基本的な使い方
 • Networking, Object Mapping, Core Data
基本的な使い方
※ サンプルプロジェクト(RKTwitter, RKTwitterCoreData)から抜粋
Networking (1/6)
      • RKObjectManager
         • 通信処理の共通設定

NSURL *baseURL = [NSURL URLWithString:@"http://twitter.com"];

RKObjectManager *objectManager = [RKObjectManager managerWithBaseURL:baseURL];
Networking (2/6)
      • RKObjectManager
         • 共通設定からリクエストを作成

RKObjectManager *objectManager = [RKObjectManager sharedManager];

[objectManager getObjectsAtPath:@"/status/user_timeline/RestKit"
                     parameters:nil
                        success:^(RKObjectRequestOperation *operation,
                                  RKMappingResult *mappingResult) {
                            NSArray* statuses = [mappingResult array];
                            NSLog(@"Loaded statuses: %@", statuses);
                        }
                        failure:^(RKObjectRequestOperation *operation,
                                  NSError *error) {
                            NSLog(@"Hit error: %@", error);
                        }];
Object Mapping (3/6)
      • RKObjectMapping
         • マッピング対象のクラスを指定
         • レスポンスで受け取るJSONデータのキーと、
              クラスのプロパティをマッピング
RKObjectMapping *statusMapping;
statusMapping = [RKObjectMapping mappingForClass:[RKTweet class]];

[statusMapping addAttributeMappingsFromDictionary:@{
 @"id" : @"statusID",
 @"created_at" : @"createdAt",
 @"text" : @"text",
 @"url" : @"urlString",
 @"in_reply_to_screen_name" : @"inReplyToScreenName",
 @"favorited" : @"isFavorited",
 }];

                   ※ CoreData利用時のマッピングは後述(RKEntityMapping)
Object Mapping (4/6)
      • RKObjectMapping
         • マッピングを適用するレスポンスの状態を
              RKResponseDescriptorで設定
         • RKObjectManagerへ設定内容を引き渡し
RKResponseDescriptor *responseDescriptor;
responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:statusMapping
                                           pathPattern:@"/status/user_timeline/:username"
                                           keyPath:nil
                                           statusCodes:[NSIndexSet indexSetWithIndex:200]];

RKObjectManager *objectManager = [RKObjectManager sharedManager];
[objectManager addResponseDescriptor:responseDescriptor];
Core Data (5/6)
      • RKManagedObjectStore
         • Core Dataスタックの管理

NSManagedObjectModel *managedObjectModel;
managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];

RKManagedObjectStore *managedObjectStore;
managedObjectStore = [[RKManagedObjectStore alloc]
                       initWithManagedObjectModel:managedObjectModel];

RKObjectManager *objectManager = [RKObjectManager sharedManager];
objectManager.managedObjectStore = managedObjectStore;
Core Data (6/6)
      • RKEntityMapping
         • マッピング対象のエンティティと、
              RKManagedObjectSotreインスタンスを指定
         • 値が一意となる属性を指定(オブジェクト更新時
              に利用される)
RKEntityMapping *tweetMapping;
tweetMapping = [RKEntityMapping mappingForEntityForName:@"Tweet"
                                inManagedObjectStore:managedObjectStore];

tweetMapping.identificationAttributes = @[ @"statusID" ];
[tweetMapping addAttributeMappingsFromDictionary:@{
 @"id": @"statusID",
 @"created_at": @"createdAt",
 @"text": @"text",
 @"url": @"urlString",
 @"in_reply_to_screen_name": @"inReplyToScreenName",
 @"favorited": @"isFavorited",
 }];
Agenda
RestKitとは
 導入手順
 注意点

基本的な使い方
 Networking, Object Mapping, Core Data
関連
• API Reference
 • https://github.com/RestKit/RestKit#api-
   quickstart
 • http://restkit.org/api/latest/
• Wiki
 • https://github.com/RestKit/RestKit/wiki

Contenu connexe

Tendances

コア・コンテキスト管理 - FIWARE WednesdayWebinars
コア・コンテキスト管理 - FIWARE WednesdayWebinarsコア・コンテキスト管理 - FIWARE WednesdayWebinars
コア・コンテキスト管理 - FIWARE WednesdayWebinarsfisuda
 
コンテキストデータの永続化のための戦略
コンテキストデータの永続化のための戦略コンテキストデータの永続化のための戦略
コンテキストデータの永続化のための戦略fisuda
 
「書ける」から「できる」になれる! ~Javaメモリ節約ノウハウ話~
「書ける」から「できる」になれる! ~Javaメモリ節約ノウハウ話~「書ける」から「できる」になれる! ~Javaメモリ節約ノウハウ話~
「書ける」から「できる」になれる! ~Javaメモリ節約ノウハウ話~JustSystems Corporation
 
Firebaseで驚くほど簡単に作れるリアルタイムイベントドリブンアプリ
Firebaseで驚くほど簡単に作れるリアルタイムイベントドリブンアプリFirebaseで驚くほど簡単に作れるリアルタイムイベントドリブンアプリ
Firebaseで驚くほど簡単に作れるリアルタイムイベントドリブンアプリFumihiko Shiroyama
 
明日から使える Java SE 7
明日から使える Java SE 7明日から使える Java SE 7
明日から使える Java SE 7Yuichi Sakuraba
 
DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!kwatch
 
CRAN Task Views でパッケージ管理
CRAN Task Views でパッケージ管理CRAN Task Views でパッケージ管理
CRAN Task Views でパッケージ管理Kosei ABE
 
Pro aspnetmvc3framework chap19
Pro aspnetmvc3framework chap19Pro aspnetmvc3framework chap19
Pro aspnetmvc3framework chap19Hideki Hashizume
 
Migr8.rb チュートリアル
Migr8.rb チュートリアルMigr8.rb チュートリアル
Migr8.rb チュートリアルkwatch
 
Webサーバ勉強会03
Webサーバ勉強会03Webサーバ勉強会03
Webサーバ勉強会03oranie Narut
 
これからのコンピューティングの変化とJava-JJUG CCC 2015 Fall
これからのコンピューティングの変化とJava-JJUG CCC 2015 Fallこれからのコンピューティングの変化とJava-JJUG CCC 2015 Fall
これからのコンピューティングの変化とJava-JJUG CCC 2015 Fallなおき きしだ
 
実行時のために最適なデータ構造を作成しよう
実行時のために最適なデータ構造を作成しよう実行時のために最適なデータ構造を作成しよう
実行時のために最適なデータ構造を作成しようHiroki Omae
 
JavaでインメモリSQLエンジンを作ってみた
JavaでインメモリSQLエンジンを作ってみたJavaでインメモリSQLエンジンを作ってみた
JavaでインメモリSQLエンジンを作ってみたJustSystems Corporation
 
IoT Agents をデバッグする方法 - FIWARE WednesdayWebinars
IoT Agents をデバッグする方法 - FIWARE WednesdayWebinarsIoT Agents をデバッグする方法 - FIWARE WednesdayWebinars
IoT Agents をデバッグする方法 - FIWARE WednesdayWebinarsfisuda
 
プロジェクト2B 最終発表
プロジェクト2B 最終発表プロジェクト2B 最終発表
プロジェクト2B 最終発表Kodai Takao
 

Tendances (20)

コア・コンテキスト管理 - FIWARE WednesdayWebinars
コア・コンテキスト管理 - FIWARE WednesdayWebinarsコア・コンテキスト管理 - FIWARE WednesdayWebinars
コア・コンテキスト管理 - FIWARE WednesdayWebinars
 
コンテキストデータの永続化のための戦略
コンテキストデータの永続化のための戦略コンテキストデータの永続化のための戦略
コンテキストデータの永続化のための戦略
 
「書ける」から「できる」になれる! ~Javaメモリ節約ノウハウ話~
「書ける」から「できる」になれる! ~Javaメモリ節約ノウハウ話~「書ける」から「できる」になれる! ~Javaメモリ節約ノウハウ話~
「書ける」から「できる」になれる! ~Javaメモリ節約ノウハウ話~
 
Firebaseで驚くほど簡単に作れるリアルタイムイベントドリブンアプリ
Firebaseで驚くほど簡単に作れるリアルタイムイベントドリブンアプリFirebaseで驚くほど簡単に作れるリアルタイムイベントドリブンアプリ
Firebaseで驚くほど簡単に作れるリアルタイムイベントドリブンアプリ
 
明日から使える Java SE 7
明日から使える Java SE 7明日から使える Java SE 7
明日から使える Java SE 7
 
Babelfish Compatibility
Babelfish CompatibilityBabelfish Compatibility
Babelfish Compatibility
 
DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!DBスキーマもバージョン管理したい!
DBスキーマもバージョン管理したい!
 
OpenStack API
OpenStack APIOpenStack API
OpenStack API
 
CRAN Task Views でパッケージ管理
CRAN Task Views でパッケージ管理CRAN Task Views でパッケージ管理
CRAN Task Views でパッケージ管理
 
Slub alloc and free
Slub alloc and freeSlub alloc and free
Slub alloc and free
 
Pro aspnetmvc3framework chap19
Pro aspnetmvc3framework chap19Pro aspnetmvc3framework chap19
Pro aspnetmvc3framework chap19
 
Migr8.rb チュートリアル
Migr8.rb チュートリアルMigr8.rb チュートリアル
Migr8.rb チュートリアル
 
Webサーバ勉強会03
Webサーバ勉強会03Webサーバ勉強会03
Webサーバ勉強会03
 
これからのコンピューティングの変化とJava-JJUG CCC 2015 Fall
これからのコンピューティングの変化とJava-JJUG CCC 2015 Fallこれからのコンピューティングの変化とJava-JJUG CCC 2015 Fall
これからのコンピューティングの変化とJava-JJUG CCC 2015 Fall
 
実行時のために最適なデータ構造を作成しよう
実行時のために最適なデータ構造を作成しよう実行時のために最適なデータ構造を作成しよう
実行時のために最適なデータ構造を作成しよう
 
JavaでインメモリSQLエンジンを作ってみた
JavaでインメモリSQLエンジンを作ってみたJavaでインメモリSQLエンジンを作ってみた
JavaでインメモリSQLエンジンを作ってみた
 
IoT Agents をデバッグする方法 - FIWARE WednesdayWebinars
IoT Agents をデバッグする方法 - FIWARE WednesdayWebinarsIoT Agents をデバッグする方法 - FIWARE WednesdayWebinars
IoT Agents をデバッグする方法 - FIWARE WednesdayWebinars
 
プロジェクト2B 最終発表
プロジェクト2B 最終発表プロジェクト2B 最終発表
プロジェクト2B 最終発表
 
EDB Postgres Vision 2019
EDB Postgres Vision 2019 EDB Postgres Vision 2019
EDB Postgres Vision 2019
 
Slub data structure
Slub data structureSlub data structure
Slub data structure
 

Similaire à RestKitの紹介 - Webサービスのクライアント実装補助フレームワーク -

Web Operations and Perl kansai.pm#14
Web Operations and Perl kansai.pm#14Web Operations and Perl kansai.pm#14
Web Operations and Perl kansai.pm#14Masahiro Nagano
 
Apache Torqueについて
Apache TorqueについてApache Torqueについて
Apache Torqueについてtako pons
 
scala+liftで遊ぼう
scala+liftで遊ぼうscala+liftで遊ぼう
scala+liftで遊ぼうyouku
 
Spring Data in a Nutshell
Spring Data in a NutshellSpring Data in a Nutshell
Spring Data in a NutshellTsuyoshi Miyake
 
Develop Web Application with Node.js + Express
Develop Web Application with Node.js + ExpressDevelop Web Application with Node.js + Express
Develop Web Application with Node.js + ExpressAkinari Tsugo
 
基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~
基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~
基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~normalian
 
コンポーネント指向による、Reactのベストプラクティスとバッドプラクティス
コンポーネント指向による、Reactのベストプラクティスとバッドプラクティスコンポーネント指向による、Reactのベストプラクティスとバッドプラクティス
コンポーネント指向による、ReactのベストプラクティスとバッドプラクティスKohei Asai
 
Sansan様 登壇資料
Sansan様 登壇資料Sansan様 登壇資料
Sansan様 登壇資料Daisuke Nagata
 
Seasarプロジェクト徹底攻略
Seasarプロジェクト徹底攻略Seasarプロジェクト徹底攻略
Seasarプロジェクト徹底攻略takezoe
 
Hadoop基盤上のETL構築実践例 ~多様なデータをどう扱う?~
Hadoop基盤上のETL構築実践例 ~多様なデータをどう扱う?~Hadoop基盤上のETL構築実践例 ~多様なデータをどう扱う?~
Hadoop基盤上のETL構築実践例 ~多様なデータをどう扱う?~Sotaro Kimura
 
Selenium webdriver使ってみようず
Selenium webdriver使ってみようずSelenium webdriver使ってみようず
Selenium webdriver使ってみようずOda Shinsuke
 
Next2Dで始めるゲーム開発 - Game Development Starting with Next2D
Next2Dで始めるゲーム開発  - Game Development Starting with Next2DNext2Dで始めるゲーム開発  - Game Development Starting with Next2D
Next2Dで始めるゲーム開発 - Game Development Starting with Next2DToshiyuki Ienaga
 
「Windows 8 ストア アプリ開発 tips」 hokuriku.net vol.11 (2013年1月26日)
「Windows 8 ストア アプリ開発 tips」  hokuriku.net vol.11 (2013年1月26日)「Windows 8 ストア アプリ開発 tips」  hokuriku.net vol.11 (2013年1月26日)
「Windows 8 ストア アプリ開発 tips」 hokuriku.net vol.11 (2013年1月26日)Fujio Kojima
 
Dot netcore multiplatform 2
Dot netcore multiplatform 2Dot netcore multiplatform 2
Dot netcore multiplatform 2shozon
 
Springでdao 20070413
Springでdao 20070413Springでdao 20070413
Springでdao 20070413Funato Takashi
 
Let's build a simple app with .net 6 asp.net core web api, react, and elasti...
Let's build a simple app with  .net 6 asp.net core web api, react, and elasti...Let's build a simple app with  .net 6 asp.net core web api, react, and elasti...
Let's build a simple app with .net 6 asp.net core web api, react, and elasti...Shotaro Suzuki
 

Similaire à RestKitの紹介 - Webサービスのクライアント実装補助フレームワーク - (20)

Web Operations and Perl kansai.pm#14
Web Operations and Perl kansai.pm#14Web Operations and Perl kansai.pm#14
Web Operations and Perl kansai.pm#14
 
Apache Torqueについて
Apache TorqueについてApache Torqueについて
Apache Torqueについて
 
scala+liftで遊ぼう
scala+liftで遊ぼうscala+liftで遊ぼう
scala+liftで遊ぼう
 
Spring Data in a Nutshell
Spring Data in a NutshellSpring Data in a Nutshell
Spring Data in a Nutshell
 
Sc2009autumn s2robot
Sc2009autumn s2robotSc2009autumn s2robot
Sc2009autumn s2robot
 
Develop Web Application with Node.js + Express
Develop Web Application with Node.js + ExpressDevelop Web Application with Node.js + Express
Develop Web Application with Node.js + Express
 
基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~
基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~
基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~
 
コンポーネント指向による、Reactのベストプラクティスとバッドプラクティス
コンポーネント指向による、Reactのベストプラクティスとバッドプラクティスコンポーネント指向による、Reactのベストプラクティスとバッドプラクティス
コンポーネント指向による、Reactのベストプラクティスとバッドプラクティス
 
Sansan様 登壇資料
Sansan様 登壇資料Sansan様 登壇資料
Sansan様 登壇資料
 
PostgreSQL 12の話
PostgreSQL 12の話PostgreSQL 12の話
PostgreSQL 12の話
 
Seasarプロジェクト徹底攻略
Seasarプロジェクト徹底攻略Seasarプロジェクト徹底攻略
Seasarプロジェクト徹底攻略
 
Hadoop基盤上のETL構築実践例 ~多様なデータをどう扱う?~
Hadoop基盤上のETL構築実践例 ~多様なデータをどう扱う?~Hadoop基盤上のETL構築実践例 ~多様なデータをどう扱う?~
Hadoop基盤上のETL構築実践例 ~多様なデータをどう扱う?~
 
Ssaw08 1028
Ssaw08 1028Ssaw08 1028
Ssaw08 1028
 
Selenium webdriver使ってみようず
Selenium webdriver使ってみようずSelenium webdriver使ってみようず
Selenium webdriver使ってみようず
 
Next2Dで始めるゲーム開発 - Game Development Starting with Next2D
Next2Dで始めるゲーム開発  - Game Development Starting with Next2DNext2Dで始めるゲーム開発  - Game Development Starting with Next2D
Next2Dで始めるゲーム開発 - Game Development Starting with Next2D
 
「Windows 8 ストア アプリ開発 tips」 hokuriku.net vol.11 (2013年1月26日)
「Windows 8 ストア アプリ開発 tips」  hokuriku.net vol.11 (2013年1月26日)「Windows 8 ストア アプリ開発 tips」  hokuriku.net vol.11 (2013年1月26日)
「Windows 8 ストア アプリ開発 tips」 hokuriku.net vol.11 (2013年1月26日)
 
Dot netcore multiplatform 2
Dot netcore multiplatform 2Dot netcore multiplatform 2
Dot netcore multiplatform 2
 
Springでdao 20070413
Springでdao 20070413Springでdao 20070413
Springでdao 20070413
 
Grails 2.0.0.M1の話
Grails 2.0.0.M1の話 Grails 2.0.0.M1の話
Grails 2.0.0.M1の話
 
Let's build a simple app with .net 6 asp.net core web api, react, and elasti...
Let's build a simple app with  .net 6 asp.net core web api, react, and elasti...Let's build a simple app with  .net 6 asp.net core web api, react, and elasti...
Let's build a simple app with .net 6 asp.net core web api, react, and elasti...
 

Dernier

LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルCRI Japan, Inc.
 
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptxsn679259
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...Toru Tamaki
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video UnderstandingToru Tamaki
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイスCRI Japan, Inc.
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Gamesatsushi061452
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsWSO2
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 

Dernier (10)

LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native Integrations
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 

RestKitの紹介 - Webサービスのクライアント実装補助フレームワーク -

  • 1.
  • 2. 永島 次朗 / Jiro Nagashima iOS Developer @ nana music, inc. @hedjirog
  • 3. RestKit / Examples / RKTwitter
  • 4. サンプルプロジェクト • 動作手順 • リポジトリを複製 (masterブランチ) • Examplesディレクトリ下のプロジェクトを開く • Build & Run $ git clone -b master --recursive git://github.com/RestKit/RestKit.git $ open RestKit/Examples/RKTwitter/RKTwitter.xcodeproj ※ 同時に複数のサンプルプロジェクトを開くと、 (サブプロジェクトとして含まれるRestKitの参照に失敗して) ビルドエラーになる場合があるので注意
  • 5. サンプルプロジェクト(補足) Submoduleを含むリポジトリ複製 recursiveオプションを付与 (clone後のsubmodule更新) $ git clone -b master --recursive git://github.com/RestKit/RestKit.git $ open RestKit/Examples/RKTwitter/RKTwitter.xcodeproj
  • 6. Agenda • RestKitとは • 導入手順 • 注意点 • 基本的な使い方 • Networking, Object Mapping, Core Data
  • 8. RestKitとは Networking Object Mapping RestKit Core Data
  • 9. RestKitとは Webサービスのクライアント実装を 強力にサポート!! Networking Object Mapping RestKit Core Data
  • 10. RestKitとは • RestKit • http://restkit.org/ • Github project page • https://github.com/RestKit/ RestKit RestKit
  • 11. 導入手順 • CocoaPodsを利用(推奨) • https://github.com/RestKit/RestKit#via- cocoapods • http://cocoapods.org/?q=RestKit
  • 12. 注意点 • iOS 5.0 以上が必須 • ARC • 最新バージョンに pre の表記 (2013.01.26現在) • https://github.com/RestKit/RestKit/tags • Apache License 2.0
  • 13. Agenda RestKitとは 導入手順 注意点 • 基本的な使い方 • Networking, Object Mapping, Core Data
  • 15. Networking (1/6) • RKObjectManager • 通信処理の共通設定 NSURL *baseURL = [NSURL URLWithString:@"http://twitter.com"]; RKObjectManager *objectManager = [RKObjectManager managerWithBaseURL:baseURL];
  • 16. Networking (2/6) • RKObjectManager • 共通設定からリクエストを作成 RKObjectManager *objectManager = [RKObjectManager sharedManager]; [objectManager getObjectsAtPath:@"/status/user_timeline/RestKit" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { NSArray* statuses = [mappingResult array]; NSLog(@"Loaded statuses: %@", statuses); } failure:^(RKObjectRequestOperation *operation, NSError *error) { NSLog(@"Hit error: %@", error); }];
  • 17. Object Mapping (3/6) • RKObjectMapping • マッピング対象のクラスを指定 • レスポンスで受け取るJSONデータのキーと、 クラスのプロパティをマッピング RKObjectMapping *statusMapping; statusMapping = [RKObjectMapping mappingForClass:[RKTweet class]]; [statusMapping addAttributeMappingsFromDictionary:@{ @"id" : @"statusID", @"created_at" : @"createdAt", @"text" : @"text", @"url" : @"urlString", @"in_reply_to_screen_name" : @"inReplyToScreenName", @"favorited" : @"isFavorited", }]; ※ CoreData利用時のマッピングは後述(RKEntityMapping)
  • 18. Object Mapping (4/6) • RKObjectMapping • マッピングを適用するレスポンスの状態を RKResponseDescriptorで設定 • RKObjectManagerへ設定内容を引き渡し RKResponseDescriptor *responseDescriptor; responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:statusMapping pathPattern:@"/status/user_timeline/:username" keyPath:nil statusCodes:[NSIndexSet indexSetWithIndex:200]]; RKObjectManager *objectManager = [RKObjectManager sharedManager]; [objectManager addResponseDescriptor:responseDescriptor];
  • 19. Core Data (5/6) • RKManagedObjectStore • Core Dataスタックの管理 NSManagedObjectModel *managedObjectModel; managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil]; RKManagedObjectStore *managedObjectStore; managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel]; RKObjectManager *objectManager = [RKObjectManager sharedManager]; objectManager.managedObjectStore = managedObjectStore;
  • 20. Core Data (6/6) • RKEntityMapping • マッピング対象のエンティティと、 RKManagedObjectSotreインスタンスを指定 • 値が一意となる属性を指定(オブジェクト更新時 に利用される) RKEntityMapping *tweetMapping; tweetMapping = [RKEntityMapping mappingForEntityForName:@"Tweet" inManagedObjectStore:managedObjectStore]; tweetMapping.identificationAttributes = @[ @"statusID" ]; [tweetMapping addAttributeMappingsFromDictionary:@{ @"id": @"statusID", @"created_at": @"createdAt", @"text": @"text", @"url": @"urlString", @"in_reply_to_screen_name": @"inReplyToScreenName", @"favorited": @"isFavorited", }];
  • 22. 関連 • API Reference • https://github.com/RestKit/RestKit#api- quickstart • http://restkit.org/api/latest/ • Wiki • https://github.com/RestKit/RestKit/wiki