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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yusuke Fujiki
October 23, 2013
Programming
0
190
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.2k
13ヶ国語対応のアプリで やっていること
fujikky
3
790
Other Decks in Programming
See All in Programming
朝日新聞のデジタル版を支えるGoバックエンド ー価値ある情報をいち早く確実にお届けするために
junkiishida
1
790
Fundamentals of Software Engineering In the Age of AI
therealdanvega
1
240
AI活用のコスパを最大化する方法
ochtum
0
130
CDIの誤解しがちな仕様とその対処TIPS
futokiyo
0
200
Claude Codeセッション現状確認 2026福岡 / fukuoka-aicoding-00-beacon
monochromegane
4
410
守る「だけ」の優しいEMを抜けて、 事業とチームを両方見る視点を身につけた話
maroon8021
3
650
Geminiの機能を調べ尽くしてみた
naruyoshimi
0
200
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
370
CSC307 Lecture 13
javiergs
PRO
0
320
技術検証結果の整理と解析をAIに任せよう!
keisukeikeda
0
110
nilとは何か 〜interfaceの構造とnil!=nilから理解する〜
kuro_kurorrr
3
1.9k
SourceGeneratorのマーカー属性問題について
htkym
0
180
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
89
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2.4k
Statistics for Hackers
jakevdp
799
230k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
120
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
sira's awesome portfolio website redesign presentation
elsirapls
0
190
How STYLIGHT went responsive
nonsquared
100
6k
Speed Design
sergeychernyshev
33
1.6k
Embracing the Ebb and Flow
colly
88
5k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
290
Prompt Engineering for Job Search
mfonobong
0
180
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); 引数があるメソッド 返り値と引数があるメソッド