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
16
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
190
DevOps in Switzerland from 2018 to 2022
akosma
3
260
APPUiO Cloud
akosma
2
660
Introduction to K8up
akosma
0
320
Creating Products through DevOps: The Story of VSHN
akosma
0
200
Everyday Life of an Open-Source Company: The Story of VSHN
akosma
0
250
Creating a Product through DevOps: The Story of APPUiO Cloud
akosma
0
580
Migrating the GitLab–Kubernetes Integration from Certificates to the Agent
akosma
0
440
APPUiO Cloud: Making of a Swiss PaaS
akosma
0
210
Other Decks in Technology
See All in Technology
エンジニアのためのドキュメント力基礎講座〜構造化思考から始めよう〜(2025/02/15jbug広島#15発表資料)
yasuoyasuo
15
5.5k
『衛星データ利用の方々にとって近いようで触れる機会のなさそうな小話 ~ 衛星搭載ソフトウェアと衛星運用ソフトウェア (実物) を動かしながらわいわいする編 ~』 @日本衛星データコミニティ勉強会
meltingrabbit
0
120
日経電子版 x AIエージェントの可能性とAgentic RAGによって提案書生成を行う技術
masahiro_nishimi
1
290
滅・サービスクラス🔥 / Destruction Service Class
sinsoku
6
1.5k
インフラをつくるとはどういうことなのか、 あるいはPlatform Engineeringについて
nwiizo
5
2.1k
All you need to know about InnoDB Primary Keys
lefred
0
120
ハッキングの世界に迫る~攻撃者の思考で考えるセキュリティ~
nomizone
12
4.5k
Larkご案内資料
customercloud
PRO
0
600
[2025-02-07]生成AIで変える問い合わせの未来 〜チームグローバル化の香りを添えて〜
tosite
1
290
個人開発から公式機能へ: PlaywrightとRailsをつなげた3年の軌跡
yusukeiwaki
10
2.7k
Developer Summit 2025 [14-D-1] Yuki Hattori
yuhattor
19
5.1k
転生CISOサバイバル・ガイド / CISO Career Transition Survival Guide
kanny
2
390
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2.1k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Building Applications with DynamoDB
mza
93
6.2k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
1k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
How to train your dragon (web standard)
notwaldorf
90
5.8k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
A Philosophy of Restraint
colly
203
16k
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?