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
Cocoa & Objective-C: An Introduction
Search
Adrian Kosmaczewski
August 28, 2008
Technology
0
25
Cocoa & Objective-C: An Introduction
Introduction to Cocoa and Objective-C given to my colleagues of Electronlibre on August 28th, 2008.
Adrian Kosmaczewski
August 28, 2008
Tweet
Share
More Decks by Adrian Kosmaczewski
See All by Adrian Kosmaczewski
Managing Fleets of Kubernetes Clusters with GitOps
akosma
4
240
DevOps in Switzerland from 2018 to 2022
akosma
3
310
APPUiO Cloud
akosma
2
720
Introduction to K8up
akosma
0
380
Creating Products through DevOps: The Story of VSHN
akosma
0
250
Everyday Life of an Open-Source Company: The Story of VSHN
akosma
0
310
Creating a Product through DevOps: The Story of APPUiO Cloud
akosma
0
670
Migrating the GitLab–Kubernetes Integration from Certificates to the Agent
akosma
0
520
APPUiO Cloud: Making of a Swiss PaaS
akosma
0
250
Other Decks in Technology
See All in Technology
アジャイルテストで高品質のスプリントレビューを
takesection
0
120
[CV勉強会@関東 CVPR2025 読み会] MegaSaM: Accurate, Fast, and Robust Structure and Motion from Casual Dynamic Videos (Li+, CVPR2025)
abemii
0
200
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
8.6k
「守る」から「進化させる」セキュリティへ ~AWS re:Inforce 2025参加報告~ / AWS re:Inforce 2025 Participation Report
yuj1osm
1
140
LLMエージェント時代に適応した開発フロー
hiragram
1
420
どこで動かすか、誰が動かすか 〜 kintoneのインフラ基盤刷新と運用体制のシフト 〜
ueokande
0
190
「AI2027」を紐解く ― AGI・ASI・シンギュラリティ
masayamoriofficial
0
110
Yahoo!ニュースにおけるソフトウェア開発
lycorptech_jp
PRO
0
370
帳票Vibe Coding
terurou
0
140
R-SCoRe: Revisiting Scene Coordinate Regression for Robust Large-Scale Visual Localization
takmin
0
430
イオン店舗一覧ページのパフォーマンスチューニング事例 / Performance tuning example for AEON store list page
aeonpeople
2
300
mruby(PicoRuby)で ファミコン音楽を奏でる
kishima
1
280
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
4 Signs Your Business is Dying
shpigford
184
22k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
Building an army of robots
kneath
306
46k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
110
20k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
480
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Scaling GitHub
holman
462
140k
How to train your dragon (web standard)
notwaldorf
96
6.2k
How GitHub (no longer) Works
holman
315
140k
The Invisible Side of Design
smashingmag
301
51k
Navigating Team Friction
lara
189
15k
Transcript
Cocoa & Objective-C An introduction August 28th, 2008
Cocoa & Objective-C • Introduction • Objective-C • Cocoa Touch
• iPhone • “CurrencyConverter” Application • Books • References
Introduction
History • Objective-C • The “other” OO language based in
C • Created by Brad Cox (~1980) • Smalltalk syntax around C • NeXT • The “other” company created by Steve Jobs • NeXTstep: the father of Cocoa
None
None
Legacy
None
None
Objective-C
The Language • Thin layer around C • Message-dispatch runtime
• Static and dynamic (you choose) • The “real” father of Java: • http://cs.gmu.edu/~sean/stuff/java-objc.html
Comparison Objective-C Java @interface & @implementation class @protocol interface #import
// files! import // classes! categories n/a id n/a
Characteristics • Single inheritance + interfaces (“@protocols”) • @protocols can
have optional methods • Fields protected by default • Methods can be added to existing classes • Full introspection / reflection • Messages can be intercepted and forwarded • à la AOP!
Classes
Methods
Calling Methods • “Message Passing” ≠ “Method Call” [object method];
[object methodWithParam:parameter and:other]; • Interface and implementation are decoupled
The “id” type • Placeholder to any type: id name
= @”Adrian”; • Similar to NSString* name = @”Adrian”; • In the latter form, we get compiler checks
Creating Objects • No “new” operator; static and instance methods
used instead: MyClass *value = nil; value = [[MyClass alloc] init];
Creating Objects • Cannot create objects on the stack: •
All objects are created on the heap!
Creating Objects // C++ // Memory freed when out of
scope std::string name(“Adrian”); std::string *name = NULL; name = new std::string(“Adrian”); delete name;
Memory Management • Cocoa allows Garbage Collection only for desktop
apps. • iPhone applications DO NOT use Garbage collection, but manual memory management.
Memory Management • Objects created using “alloc” have a “retain
count” of “1”: // increments retain count [object retain]; // decrements retain count [object release];
Memory Management http://cocoadevcentral.com/d/learn_objectivec/
Memory Management • Only one rule: • “If you create
an object with alloc or copy, send it a release message at the end of the function. If you create an object any other way, do nothing”
Cocoa Touch
Cocoa Touch • Reduced version of the Cocoa framework found
in Mac OS X Leopard • Divided in two parts: • UIKit • Foundation
UIKit
iPhone OS
Address Book ABAddressBook ABMultiValue ABMutableMultiValue ABRecord ABGroup ABPerson
Accelerometer UIAccelerometer UIAccelerometerDelegate
Video MPMoviePlayerController
Location Services
Graphics & Animation CALayer NSGraphicsContext NSRect / NSMakeRect NSBezierPath NSColor
Camera & Photo Library UIImagePickerController UIImagePickerControllerDelegate UIImagePickerControllerSourceTypeCamera UIImagePickerControllerSourceTypePhotoLibrary
Code Security
More... • Audio • AudioToolbox • AudioUnit • CoreAudio •
CoreMIDI • OpenAL • XML • WebKit • SQLite • Networking • CFNetwork • Bonjour
CurrencyConverter
CurrencyConverter • Simple application for the iPhone • Shows basic
workflow • Use of • delegation • Interface Builder / Xcode integration • categories
Books
None
None
None
None
References
Objective-C http://cocoadevcentral.com/d/learn_objectivec/ http://www.faqs.org/faqs/computer-lang/Objective-C/faq/ http://cs.gmu.edu/~sean/stuff/java-objc.html http://www.mactech.com/articles/mactech/Vol.13/13.03/CandObjectiveCCompared/
C Tutorial for Cocoa http://cocoadevcentral.com/articles/000081.php
Naming Guidelines http://cocoadevcentral.com/articles/000082.php http://cocoadevcentral.com/articles/000083.php
Cocoa Tutorial http://cocoadevcentral.com/d/learn_cocoa/ http://cocoadevcentral.com/d/learn_cocoa_two/
Thanks!
Questions?