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
200
0
Share
Objective-C入門
プログラミング初心者向け
Yusuke Fujiki
October 23, 2013
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
ローカルLLMでどこまでコードが書けるか / How much code can be written on a local LLM
kishida
2
270
PHPでバイナリをパースして理解するASN.1
muno92
PRO
0
400
How We Practice Exploratory Testing in Iterative Development( #scrumniigata ) / 反復開発の中で、探索的テストをどう実施しているか
teyamagu
PRO
3
650
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
320
属人化しないコード品質の作り方_2026.04.07.pdf
muraaano
0
300
「Linuxサーバー構築標準教科書」を読んでみた #ツナギメオフライン.7
akase244
0
1.4k
Back to the roots of date
jinroq
0
670
PHPでローカル環境用のSSL/TLS証明書を発行することはできるのか? #phpconkagawa
akase244
0
320
Surviving Black Friday: 329 billion requests with Falcon!
ioquatix
0
2.7k
Import assertionsが消えた日~ECMAScriptの仕様はどう決まり、なぜ覆るのか~
bicstone
2
170
From Formal Specification to Property Based Test
ohbarye
0
680
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
2.4k
Featured
See All Featured
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
320
Paper Plane
katiecoart
PRO
1
49k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
180
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
The SEO Collaboration Effect
kristinabergwall1
1
440
30 Presentation Tips
portentint
PRO
1
290
Google's AI Overviews - The New Search
badams
0
1k
KATA
mclloyd
PRO
35
15k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
280
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
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); 引数があるメソッド 返り値と引数があるメソッド