Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
iOS for Web Developers
Search
Ben Howdle
August 22, 2014
Programming
320
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
iOS for Web Developers
Ben Howdle
August 22, 2014
Other Decks in Programming
See All in Programming
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
250
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
1
2.3k
Kubernetes祭り #2 OP/ED
bells17
0
110
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
160
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
34
16k
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
8
5.7k
contenteditable と日本語入力に向き合う
colorful12
0
190
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
150
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.2k
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
580
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
240
Featured
See All Featured
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
Art, The Web, and Tiny UX
lynnandtonic
304
22k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
The Cult of Friendly URLs
andyhume
79
7k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
[SF Ruby Conf 2025] Rails X
palkan
3
1.4k
Believing is Seeing
oripsolob
1
240
The Limits of Empathy - UXLibs8
cassininazir
2
710
New Earth Scene 8
popppiees
4
2.7k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
620
Game over? The fight for quality and originality in the time of robots
wayneb77
1
300
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Transcript
iOS for web developers site: http://benhowdle.im twitter: @benhowdle
Today’s menu • Why give this talk? • An Objective-C
crash course • The building blocks of an iOS app • New things • Warm & fuzzy familiar things • Greener pastures & pain-points
Why give this talk?
http://benhowdle.im/2014/04/24/ios-for-web-developers-building-permeate/
None
Objective-C .page > #menu li:nth-child(2n+1) ~ a:focus Not so fast
on the hatin’
Classes & Objects
JavaScript //definition ! function MyClass(name){ this.name = name; } !
myClass.prototype.sayName = function(){ console.log(this.name); } ! // usage ! var myClass = new MyClass("woz"); myClass.sayName(); // woz
Objective-C // definition ! // MyClass.h @interface MyClass : NSObject
! @property NSString *name; ! - (id)initWithName:(NSString *)name; - (void)sayName; ! @end // MyClass.m #import "MyClass.h" ! @implementation MyClass - (id)initWithName:(NSString *)name { if ((self = [super init])) { _name = name; } return self; } ! - (void)sayName { NSLog(@"%@", self.name); } @end ! // usage ! MyClass *myClass = [[MyClass alloc] initWithName:@"woz"]; [myClass sayName]; Interface (header) file Implementation file
Variables
JavaScript var myNum = 2; var myDictionary = { foo:
"bar" } var myArray = ["foo", "bar"];
Objective-C NSNumber *myNum = @2; NSDictionary *myDictionary = @{ @"foo":
@"bar" } NSArray *myArray = @[@"foo", @"bar"];
Methods (functions)
JavaScript function takeMyMoney(amount, inCurrency){ console.log(inCurrency + amount); } ! function
takeMyMoney(amount, inCurrency, withAReceipt){ console.log(withAReceipt); return inCurrency + amount; } ! takeMyMoney(42, "£"); // £42 takeMyMoney(42, "£", true); // £42
Objective-C - (void)takeMyMoney:(NSNumber *)amount inCurrency:(NSString *)currency { NSLog(@"%@%@", currency, amount);
} ! - (NSString *)takeMyMoney:(NSNumber *)amount inCurrency:(NSString *)currency withReceipt:(BOOL)receipt { NSLog(@"%@", receipt ? @"YES" : @"NO"); return [NSString stringWithFormat:@"%@%@", currency, amount]; } ! [self takeMyMoney:@42 inCurrency:@"£"]; // £42 NSString *monies = [self takeMyMoney:@42 inCurrency:@"£" withReceipt:YES]; // £42
Anatomy of an iOS app
View Controllers
Objective-C @interface FooViewController : UIViewController ! @end #import "FooViewController.h" !
@interface FooViewController () ! @end ! @implementation FooViewController ! - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; } ! @end
Objective-C - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ! self.window =
[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; UIViewController *vc = [[ViewController alloc] init]; self.window.rootViewController = vc; [self.window makeKeyAndVisible]; return YES; ! }
UIViewController UITableViewController UINavigationController
Views
JavaScript var button = document.createElement('div'); button.innerHTML = "Click me"; button.style.backgroundColor
= "#f7f7f7"; button.style.color = "#222"; button.style.borderRadius = "4px"; button.style.width = "100px"; button.style.height = "25px"; document.querySelector('#mySidebar').appendChild(button);
Objective-C UIButton *myButton = [[UIButton alloc] init]; myButton.frame = CGRectMake(0,
0, 100, 25); [myButton setTitle:@"Tap me" forState:UIControlStateNormal]; myButton.layer.cornerRadius = 4; myButton.backgroundColor = [UIColor blueColor]; myButton.titleLabel.textColor = [UIColor whiteColor]; [self.view addSubview:myButton];
New things to learn
Multithreading
Objective-C dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKG ROUND, 0), ^ { // intensive stuff, maybe
a network request, or resizing an image dispatch_async(dispatch_get_main_queue(), ^{ // back on the main thread to update the UI }); });
Dependency Management
Delegates
Objective-C - (void)viewDidLoad { [super viewDidLoad]; self.passwordTextField = [[UITextField alloc]
initWithFrame:CGRectMake(10, 316, 300, 44)]; self.passwordTextField.placeholder = @"Password"; self.passwordTextField.secureTextEntry = YES; self.passwordTextField.delegate = self; [self.view addSubview:self.passwordTextField]; } ! -(BOOL)textFieldShouldReturn:(UITextField *)textField { if(textField == self.passwordTextField){ [textField resignFirstResponder]; // do what we want now return NO; } return YES; }
No HTML
Typed language
Warm, fuzzy familiar things
Handling Events
JavaScript document.querySelector('#myButton').addEventListener('click', handleClick); ! function handleClick(){ console.log('I was clicked'); }
Objective-C UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)]; ! [self.myButton
addGestureRecognizer:singleFingerTap]; ! - (void)handleSingleTap:(UITapGestureRecognizer *)recognizer { NSLog(@"I was tapped"); }
Blocks
JavaScript function someTask(callback){ // do some stuff callback(); } !
someTask(function(){ // someTask has been completed }); ! function someTaskThatReturnsAName(callback){ callback("Neo"); } ! someTaskThatReturnsAName(function(name){ console.log(name); });
Objective-C - (void)someTask:(void (^)(void))callback { // do some stuff callback();
} ! [self someTask:^{ // someTask has been completed }]; ! - (void)someTaskThatReturnsAName:(void (^)(NSString *))callback { // do some stuff callback(@"Neo"); } ! [self someTaskThatReturnsAName:^(NSString *name){ NSLog(@"%@", name); }];
Package Management
Images
HTML <img src="/images/face.png" /> <img src="http://www.placecage.com/g/200/300" />
Objective-C // local UIImage *img = [UIImage imageNamed:@"bg.jpeg"]; ! //
remote UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL: [NSURL URLWithString:@"http://www.placecage.com/g/200/300"]]]; ! UIImageView *bg = [[UIImageView alloc] initWithImage:img]; [self.view addSubview:bg]; https://github.com/nicklockwood/AsyncImageView
AJAX & JSON
JavaScript var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://www.reddit.com/r/earthporn.json', true); !
xhr.onreadystatechange = function(){ if(xhr.readyState == 4){ console.log(JSON.parse(xhr.responseText).data.children); } } ! xhr.send();
Objective-C NSURL *url = [NSURL URLWithString:@"http://www.reddit.com/r/earthporn.json"]; ! NSURLSessionDataTask *dataTask =
[[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if(error == nil){ id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; NSArray *results = [json valueForKeyPath:@“data.children”]; NSLog(@"%@", results); } }]; ! [dataTask resume];
Greener pastures
Fewer screen sizes
Xcode
Documentation
Views (vs. HTML)
Pain points
Learning curve
Deployments & updating
Provisioning Portal
Thanks for listening…