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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
Managing Fleets of Kubernetes Clusters with GitOps
akosma
4
270
DevOps in Switzerland from 2018 to 2022
akosma
4
350
APPUiO Cloud
akosma
2
770
Introduction to K8up
akosma
0
420
Creating Products through DevOps: The Story of VSHN
akosma
0
280
Everyday Life of an Open-Source Company: The Story of VSHN
akosma
0
360
Creating a Product through DevOps: The Story of APPUiO Cloud
akosma
0
740
Migrating the GitLab–Kubernetes Integration from Certificates to the Agent
akosma
0
580
APPUiO Cloud: Making of a Swiss PaaS
akosma
0
280
Other Decks in Technology
See All in Technology
Oracle AI Database移行・アップグレード勉強会 - RAT活用編
oracle4engineer
PRO
0
100
Webhook best practices for rock solid and resilient deployments
glaforge
2
300
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1k
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
1.4k
学生・新卒・ジュニアから目指すSRE
hiroyaonoe
2
650
10Xにおける品質保証活動の全体像と改善 #no_more_wait_for_test
nihonbuson
PRO
2
320
Why Organizations Fail: ノーベル経済学賞「国家はなぜ衰退するのか」から考えるアジャイル組織論
kawaguti
PRO
1
100
Bill One急成長の舞台裏 開発組織が直面した失敗と教訓
sansantech
PRO
2
380
ランサムウェア対策としてのpnpm導入のススメ
ishikawa_satoru
0
180
Embedded SREの終わりを設計する 「なんとなく」から計画的な自立支援へ
sansantech
PRO
3
2.5k
CDK対応したAWS DevOps Agentを試そう_20260201
masakiokuda
1
350
【Ubie】AIを活用した広告アセット「爆速」生成事例 | AI_Ops_Community_Vol.2
yoshiki_0316
1
110
Featured
See All Featured
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
120
Thoughts on Productivity
jonyablonski
74
5k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.2k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.6k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
210
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.8k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
62
50k
エンジニアに許された特別な時間の終わり
watany
106
230k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
290
For a Future-Friendly Web
brad_frost
182
10k
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?