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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Adrian Kosmaczewski
August 28, 2008
Technology
0
26
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
What's in your Container? Securing the Software Supply Chain without Slowing Down
akosma
0
18
Managing Fleets of Kubernetes Clusters with GitOps
akosma
4
280
DevOps in Switzerland from 2018 to 2022
akosma
4
360
APPUiO Cloud
akosma
2
780
Introduction to K8up
akosma
0
420
Creating Products through DevOps: The Story of VSHN
akosma
0
290
Everyday Life of an Open-Source Company: The Story of VSHN
akosma
0
370
Creating a Product through DevOps: The Story of APPUiO Cloud
akosma
0
760
Migrating the GitLab–Kubernetes Integration from Certificates to the Agent
akosma
0
610
Other Decks in Technology
See All in Technology
Serverless Agent Architecture on Azure / serverless-agent-on-azure
miyake
1
130
マイグレーションガイドに書いてないRiverpod 3移行話
taiju59
0
340
Data Hubグループ 紹介資料
sansan33
PRO
0
2.8k
Windows ネットワークを再確認する
murachiakira
PRO
0
240
DX Improvement at Scale
ntk1000
2
170
AI が Approve する開発フロー / How AI Reviewers Accelerate Our Development
zaimy
1
260
【PyCon mini Shizuoka 2026】生成AI時代に画像処理やオーディオ処理のノードエディターを作る理由
kazuhitotakahashi
0
260
技術的負債の泥沼から組織を救う3つの転換点
nwiizo
4
870
primeNumber DATA MANAGEMENT CAMP #2:
masatoshi0205
1
670
Devinを導入したら予想外の人たちに好評だった
tomuro
0
820
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
15
95k
LINE Messengerの次世代ストレージ選定
lycorptech_jp
PRO
17
7.1k
Featured
See All Featured
Become a Pro
speakerdeck
PRO
31
5.8k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
200
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
850
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
280
Git: the NoSQL Database
bkeepers
PRO
432
66k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
The Cost Of JavaScript in 2023
addyosmani
55
9.7k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
180
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?