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
15
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
170
DevOps in Switzerland from 2018 to 2022
akosma
3
240
APPUiO Cloud
akosma
2
640
Introduction to K8up
akosma
0
300
Creating Products through DevOps: The Story of VSHN
akosma
0
190
Everyday Life of an Open-Source Company: The Story of VSHN
akosma
0
240
Creating a Product through DevOps: The Story of APPUiO Cloud
akosma
0
550
Migrating the GitLab–Kubernetes Integration from Certificates to the Agent
akosma
0
420
APPUiO Cloud: Making of a Swiss PaaS
akosma
0
200
Other Decks in Technology
See All in Technology
20241218_今年はSLI/SLOの導入を頑張ってました!
zepprix
0
100
非機能品質を作り込むための実践アーキテクチャ
knih
5
1.6k
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
380
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
240
APIとはなにか
mikanichinose
0
110
レンジャーシステムズ | 会社紹介(採用ピッチ)
rssytems
0
280
LINEヤフーのフロントエンド組織・体制の紹介【24年12月】
lycorp_recruit_jp
0
550
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
830
なぜCodeceptJSを選んだか
goataka
0
180
.NET 9 のパフォーマンス改善
nenonaninu
0
1.3k
10個のフィルタをAXI4-Streamでつなげてみた
marsee101
0
180
Opcodeを読んでいたら何故かphp-srcを読んでいた話
murashotaro
0
320
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
33
3k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
How STYLIGHT went responsive
nonsquared
96
5.2k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Visualization
eitanlees
146
15k
We Have a Design System, Now What?
morganepeng
51
7.3k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Practical Orchestrator
shlominoach
186
10k
Six Lessons from altMBA
skipperchong
27
3.5k
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?