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
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
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
110
プロダクトオーナーから見たSOC2 _SOC2ゆるミートアップ#2
kekekenta
0
210
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
110
CSC307 Lecture 06
javiergs
PRO
0
680
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
200
Data-Centric Kaggle
isax1015
2
770
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
270
Architectural Extensions
denyspoltorak
0
280
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
1k
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
CSC307 Lecture 03
javiergs
PRO
1
490
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
230
Featured
See All Featured
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
200
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
430
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.6k
Side Projects
sachag
455
43k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.3k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
710
Docker and Python
trallard
47
3.7k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.5k
Scaling GitHub
holman
464
140k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
110
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); 引数があるメソッド 返り値と引数があるメソッド