Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Objective-C入門
Search
Yusuke Fujiki
October 23, 2013
Programming
0
180
Objective-C入門
プログラミング初心者向け
Yusuke Fujiki
October 23, 2013
Tweet
Share
More Decks by Yusuke Fujiki
See All by Yusuke Fujiki
Siri Shortcuts を試してみた! / Tried to Siri Shortcuts
fujikky
0
1.1k
13ヶ国語対応のアプリで やっていること
fujikky
3
780
Other Decks in Programming
See All in Programming
『自分のデータだけ見せたい!』を叶える──Laravel × Casbin で複雑権限をスッキリ解きほぐす 25 分
akitotsukahara
2
640
なぜ「共通化」を考え、失敗を繰り返すのか
rinchoku
1
650
AI時代のソフトウェア開発を考える(2025/07版) / Agentic Software Engineering Findy 2025-07 Edition
twada
PRO
87
29k
初学者でも今すぐできる、Claude Codeの生産性を10倍上げるTips
s4yuba
16
11k
Railsアプリケーションと パフォーマンスチューニング ー 秒間5万リクエストの モバイルオーダーシステムを支える事例 ー Rubyセミナー 大阪
falcon8823
5
1.1k
AIともっと楽するE2Eテスト
myohei
6
2.6k
5つのアンチパターンから学ぶLT設計
narihara
1
170
AI駆動のマルチエージェントによる業務フロー自動化の設計と実践
h_okkah
0
150
スタートアップの急成長を支えるプラットフォームエンジニアリングと組織戦略
sutochin26
1
5.8k
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
260
Node-RED を(HTTP で)つなげる MCP サーバーを作ってみた
highu
0
120
VS Code Update for GitHub Copilot
74th
2
650
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
95
6.1k
For a Future-Friendly Web
brad_frost
179
9.8k
Faster Mobile Websites
deanohume
307
31k
4 Signs Your Business is Dying
shpigford
184
22k
Designing for Performance
lara
610
69k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
20
1.3k
How GitHub (no longer) Works
holman
314
140k
Unsuck your backbone
ammeep
671
58k
Into the Great Unknown - MozCon
thekraken
40
1.9k
Rebuilding a faster, lazier Slack
samanthasiow
82
9.1k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Transcript
Objective-C入門 iOS勉強会
Objective-C
Objective + C
C言語にオブジェクト指向の機能を 追加したもの +
オブジェクト指向とは
オブジェクト指向とは 名前 性別 職業 「人」設計図 名前:Aさん 性別:男 職業:エンジニア 名前:Bさん 性別:女
職業:デザイナー 名前:Cさん 性別:男 職業:警備
オブジェクト指向とは 名前 性別 職業 「人」設計図 名前:Aさん 性別:男 職業:エンジニア 名前:Bさん 性別:女
職業:デザイナー 名前:Cさん 性別:男 職業:警備
オブジェクト指向とは 名前 性別 職業 「人」設計図 名前:Aさん 性別:男 職業:エンジニア 名前:Bさん 性別:女
職業:デザイナー 名前:Cさん 性別:男 職業:警備 クラス
オブジェクト指向とは 名前 性別 職業 「人」設計図 名前:Aさん 性別:男 職業:エンジニア 名前:Bさん 性別:女
職業:デザイナー 名前:Cさん 性別:男 職業:警備 インスタンス クラス
オブジェクト指向とは 同じ属性をもつオブジェクト の設計図をクラスという クラス(設計図)を元に作った ものをインスタンスという
Image From http:/ /forums.tigsource.com/index.php?topic=3630.0
オブジェクト指向とは あるクラスからその属性を 引き継いだ新しいクラスを作る ことができる これを継承という
Objective-Cでは ほぼすべてのオブジェクトは NSObjectを継承してい る
例えば UIImageView UILabel UISwitch UIView NSObject
interface(設計図) @interface Animal : NSObject @property (nonatomic) NSString *name; @property
(nonatomic) NSInteger legs; - (void)sayMyName; @end
interface(設計図) @interface Animal : NSObject @property (nonatomic) NSString *name; @property
(nonatomic) NSInteger legs; - (void)sayMyName; @end クラス名
interface(設計図) @interface Animal : NSObject @property (nonatomic) NSString *name; @property
(nonatomic) NSInteger legs; - (void)sayMyName; @end クラス名 継承元
interface(設計図) @interface Animal : NSObject @property (nonatomic) NSString *name; @property
(nonatomic) NSInteger legs; - (void)sayMyName; @end クラス名 継承元 属性
interface(設計図) @interface Animal : NSObject @property (nonatomic) NSString *name; @property
(nonatomic) NSInteger legs; - (void)sayMyName; @end クラス名 継承元 属性 メソッド
implementation(実装) @implementation Animal - (void)sayMyName { NSLog(@"%@", self.name); } @end
implementation(実装) @implementation Animal - (void)sayMyName { NSLog(@"%@", self.name); } @end
name属性を出力する
クラスの使い方 Animal *animal = [[Animal alloc] init]; animal.name = @"Stud";
[animal sayMyName];
クラスの使い方 Animal *animal = [[Animal alloc] init]; animal.name = @"Stud";
[animal sayMyName]; クラスからインスタンスを作る
クラスの使い方 Animal *animal = [[Animal alloc] init]; animal.name = @"Stud";
[animal sayMyName]; 属性を設定 クラスからインスタンスを作る
クラスの使い方 Animal *animal = [[Animal alloc] init]; animal.name = @"Stud";
[animal sayMyName]; 属性を設定 クラスからインスタンスを作る sayMyNameメソッドを 実行
継承する @interface Human : Animal - (void)sayHello; @end @implementation Human
- (void)sayHello { NSLog(@"%@ : Hello!", self.name); } @end
継承する @interface Human : Animal - (void)sayHello; @end @implementation Human
- (void)sayHello { NSLog(@"%@ : Hello!", self.name); } @end Animalクラスを 継承
継承する @interface Human : Animal - (void)sayHello; @end @implementation Human
- (void)sayHello { NSLog(@"%@ : Hello!", self.name); } @end Animalクラスを 継承 HumanクラスにはsayHelloメソッドをもたせる
継承する @interface Human : Animal - (void)sayHello; @end @implementation Human
- (void)sayHello { NSLog(@"%@ : Hello!", self.name); } @end Animalクラスを 継承 sayHelloメソッドの実装 HumanクラスにはsayHelloメソッドをもたせる
メソッドの定義 - (void)sayHello; - (NSString *)helloMessage; - (void)sayHelloToSomeone: (NSString *)someone;
- (NSString *)helloToSomeoneMessage: (NSString *)someone;
メソッドの定義 - (void)sayHello; - (NSString *)helloMessage; - (void)sayHelloToSomeone: (NSString *)someone;
- (NSString *)helloToSomeoneMessage: (NSString *)someone; 通常のメソッド
メソッドの定義 - (void)sayHello; - (NSString *)helloMessage; - (void)sayHelloToSomeone: (NSString *)someone;
- (NSString *)helloToSomeoneMessage: (NSString *)someone; 通常のメソッド 返り値ありのメソッド
メソッドの定義 - (void)sayHello; - (NSString *)helloMessage; - (void)sayHelloToSomeone: (NSString *)someone;
- (NSString *)helloToSomeoneMessage: (NSString *)someone; 通常のメソッド 返り値ありのメソッド 引数があるメソッド
メソッドの定義 - (void)sayHello; - (NSString *)helloMessage; - (void)sayHelloToSomeone: (NSString *)someone;
- (NSString *)helloToSomeoneMessage: (NSString *)someone; 通常のメソッド 返り値ありのメソッド 引数があるメソッド 返り値と引数があるメソッド
メソッドの実装 - (void)sayHello { NSLog(@"%@ : Hello!", self.name); } -
(NSString *)helloMessage { return [NSString stringWithFormat: @"%@ : Hello!", self.name]; }
メソッドの実装 - (void)sayHello { NSLog(@"%@ : Hello!", self.name); } -
(NSString *)helloMessage { return [NSString stringWithFormat: @"%@ : Hello!", self.name]; } 通常のメソッド
メソッドの実装 - (void)sayHello { NSLog(@"%@ : Hello!", self.name); } -
(NSString *)helloMessage { return [NSString stringWithFormat: @"%@ : Hello!", self.name]; } 通常のメソッド 返り値ありのメソッド
メソッドの実装 - (void)sayHelloToSomeone:(NSString *)someone { NSLog(@"%@ : Hello, %@!", self.name,
someone); } - (NSString *)helloToSomeoneMessage: (NSString *)someone { return [NSString stringWithFormat:@"%@ : Hello, %@!", self.name, someone]; }
メソッドの実装 - (void)sayHelloToSomeone:(NSString *)someone { NSLog(@"%@ : Hello, %@!", self.name,
someone); } - (NSString *)helloToSomeoneMessage: (NSString *)someone { return [NSString stringWithFormat:@"%@ : Hello, %@!", self.name, someone]; } 引数があるメソッド
メソッドの実装 - (void)sayHelloToSomeone:(NSString *)someone { NSLog(@"%@ : Hello, %@!", self.name,
someone); } - (NSString *)helloToSomeoneMessage: (NSString *)someone { return [NSString stringWithFormat:@"%@ : Hello, %@!", self.name, someone]; } 引数があるメソッド 返り値と引数があるメソッド
メソッドを実行 [animal sayMyName]; インスタンス名
メソッドを実行 [animal sayMyName]; インスタンス名 メソッドを実行
メソッドを実行 [animal sayHelloToSomeone:@"Levi"]; NSString *msg = [animal helloToSomeoneMessage:@"Levi"]; NSLog(@"msg =
%@", msg);
メソッドを実行 [animal sayHelloToSomeone:@"Levi"]; NSString *msg = [animal helloToSomeoneMessage:@"Levi"]; NSLog(@"msg =
%@", msg); 引数があるメソッド
メソッドを実行 [animal sayHelloToSomeone:@"Levi"]; NSString *msg = [animal helloToSomeoneMessage:@"Levi"]; NSLog(@"msg =
%@", msg); 引数があるメソッド 返り値と引数があるメソッド