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
Objective-C For Web Developers
Search
Addam Hardy
August 24, 2012
Programming
6
670
Objective-C For Web Developers
Talk given at TechFest Northwest Arkansas 2012
Addam Hardy
August 24, 2012
Tweet
Share
More Decks by Addam Hardy
See All by Addam Hardy
Product Carousel Randomization & Optimization
addamh
0
22
A/B Testing
addamh
0
25
Kanban & Lean Manufacturing
addamh
0
80
What is caching? And why does it hate me?
addamh
0
22
Building Microservices on AWS with the Serverless Framework
addamh
0
110
Apache Spark & MLlib
addamh
0
110
Bayesian Sentiment Analysis with Ruby
addamh
0
150
Decision Trees, Data Science, and Machine Learning: Using Entropy to Discover Path to Purchase
addamh
1
210
Intro to Rails
addamh
0
120
Other Decks in Programming
See All in Programming
SwiftUIのObservationツールの挙動をテストしてみた
kenshih522
0
110
読もう! Android build ドキュメント
andpad
1
190
安全に倒し切るリリースをするために:15年来レガシーシステムのフルリプレイス挑戦記
sakuraikotone
5
2k
もう一人で悩まない! 個の知見をチームの知見にする3つの習慣と工夫 / Into team knowledge.
honyanya
3
500
PHPによる"非"構造化プログラミング入門 -本当に熱いスパゲティコードを求めて- #phperkaigi
o0h
PRO
0
760
eBPF Updates (March 2025)
kentatada
0
110
Scala 3 で GLSL のための c-like-for を実装してみた
exoego
1
160
複雑なフォームと複雑な状態管理にどう向き合うか / #newt_techtalk vol. 15
izumin5210
4
2.4k
신입 안드로이드 개발자의 AI 스타트업 생존기 (+ Native C++ Code를 Android에서 사용해보기)
dygames
0
470
Generative AI for Beginners .NETの紹介
tomokusaba
1
270
Go言語での実装を通して学ぶ、高速なベクトル検索を支えるクラスタリング技術/fukuokago-kmeans
monochromegane
1
130
PromptyによるAI開発入門
ymd65536
1
330
Featured
See All Featured
Being A Developer After 40
akosma
89
590k
Visualization
eitanlees
146
15k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
31
4.7k
Optimising Largest Contentful Paint
csswizardry
34
3.1k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
Raft: Consensus for Rubyists
vanstee
137
6.8k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
21k
RailsConf 2023
tenderlove
29
1k
It's Worth the Effort
3n
184
28k
Java REST API Framework Comparison - PWX 2021
mraible
29
8.5k
Transcript
For Objective-C Web Developers Addam Hardy
@addamh this guy Ruby on Rails Javascript Developer iOS
None
web developer? it’s time to evolve
tablet sales to surpass desktop sales by 2015
demand supply
demand supply profit
None
the run down
strict superset of C Objective-C
strict superset of C compiled language Objective-C
strict superset of C compiled language object-oriented Objective-C
strict superset of C compiled language object-oriented dynamic Objective-C
strict superset of C compiled language object-oriented dynamic strictly typed
Objective-C
strict superset of C compiled language object-oriented dynamic strictly typed
smalltalk style messaging Objective-C
strict superset of C compiled language object-oriented dynamic strictly typed
smalltalk style messaging very verbose Objective-C
difficulties for web developers
C bummers
C compiling! so much time! bummers
C compiling! so much time! the dynamic-ness. sort of. bummers
C compiling! so much time! the dynamic-ness. sort of. asynchronous/threading
bummers
C compiling! so much time! the dynamic-ness. sort of. asynchronous/threading
memory management bummers
C compiling! so much time! the dynamic-ness. sort of. asynchronous/threading
memory management bummers
C compiling! so much time! the dynamic-ness. sort of. asynchronous/threading
memory management static typing bummers
C compiling! so much time! the dynamic-ness. sort of. asynchronous/threading
memory management static typing errors bummers
xcode
xcode
xcode
xcode
xcode
xcode
xcode
xcode
typing
typing Ruby PHP Objective-C $var = 21; $variable = “This
is a string”; var = 21 variable = “This is a string” (int) var = 21; NSString *variable = @“This is a string”;
typing C Primitives Common Classes char short long unsigned char
unsigned int int float double bool NSString NSNumber NSArray NSDictionary NSMutableArray NSMutableDictionary UIView UIButton id and 20,000 others..
header files implementation files wat?
headers / implementation class.h The public API for the class
@interface Student { NSNumber *age; NSString *name; } @end
headers / implementation class.h class.m The public API for the
class The instructions for the class @interface Student { NSNumber *age; NSString *name; } @end @implementation Student - (NSString *) name { } @end
creating classes
classes Ruby PHP class HelloWorld { // instance variables go
here // methods go here public function sayHI() { print("Hello World!”); } } class HelloWorld // instance variables go here // methods go here def sayHI puts "Hello World!” end end
classes Objective-C @interface HelloWorld { NSString *statement = @”This is
a string” } -(void) sayHI; @end
classes Ruby PHP class cat extends animal { public function
be_cute() { print("I am teh cute”); } } class cat < animal def be_cute puts "I am teh cute” end end
classes Objective-C @interface Cat : Animal <CuteMultipler> { } -(void)
beCute; @end
properties
properties @property (nonatomic, retain) NSString *title; @property (nonatomic, assign) int
number;
properties @synthesize title; @synthesize number; [object setTitle:@”This is my title”];
NSLog(@”%@”, [object title]);
object instantiation
object instantiation Ruby PHP include_once('HelloWorld.class.php'); $hw = new HelloWorld; $hw->sayHI;
require ‘HelloWorld’ hw = HelloWorld.new hw.sayHI
Objective-C #import <Foundation/Foundation.h> @interface HelloWorld : NSObject { } -
(void)sayHI; @end object instantiation header
Objective-C #import “HelloWorld.h” @implementation HelloWorld - (void)sayHI { NSLog(@”Hi.”); }
@end object instantiation header
Objective-C #import <Foundation/Foundation.h> #import "HelloWorld.h" int main (int argc, const
char * argv[]) { HelloWorld *hw = [[HelloWorld alloc] init]; [hw printHelloDate]; return 0; } object instantiation main.m
methods /selectors
methods / selectors Ruby PHP function buyItem(item) { $cart =
new ShoppingCart; $cart->purchase(item); } def buyItem(item) cart = ShoppingCart.new cart.purchase(item) end
Objective-C - (void)buyItem:(ItemObject*)item { ShoppingCart *cart = [[ShoppingCart alloc] init];
[cart purchase:item]; } methods / selectors
def addObserver(key_path, options, context) end methods / selectors
def addObserver(key_path, options, context) end methods / selectors addObserver(key_path, options,
context)
-(void) addObserverForKeyPath:(NSIndexPath*)indexPath WithOptions:(NSDictionary*)options AndContext:(void*) { } methods / selectors
-(void) addObserverForKeyPath:(NSIndexPath*)indexPath WithOptions:(NSDictionary*)options AndContext:(void*) { } methods / selectors [object
addObserverForKeyPath:indexPath WithOptions:options AndContext:nil]
common pitfalls
common pitfalls NSString *this = @”kitty”; NSString *that = @”kitty”;
if(this == that){ NSLog(@”This will not happen”); } if([this isEqualToString:that]){ NSLog(@”This will happen!”); } NO YES
common pitfalls @synthesize this; @synthesize that; @synthesize those; @synthesize this,
that, those; NO YES
common pitfalls @interface MyNewClass @end @interface MyNewClass : NSObject @end
NO YES
common pitfalls start writing implementation right away always declare methods
in header first then implement NO YES
just do it!
thanks!