SlideShare una empresa de Scribd logo
1 de 80
Descargar para leer sin conexión
iOS Development
                        Lecture 1 - The basics



Petr Dvořák
Partner & iOS Development Lead
@joshis_tweets
Outline
Outline
• iOS app development ecosystem
  • Required hardware
  • iOS Developer Account & App Store
  • iOS Overview
  • XCode and Instruments
  • The cool stuff you can do
Outline
• Objective-C and iOS SDK
  • Basic language syntax
  • Classes, protocols, categories
  • Memory management
Outline
• UI Elements on iOS
  • Overview of the UI building blocks
  • Storyboard / Interface Builder
Outline
• Network aware applications
  • Connecting to on-line resources
  • Processing XML and JSON
iOS Ecosystem
Required hardware

• Any computer/laptop with Mac OS X
• Mac Mini - from 13 990 CZK
• MacBook Pro 13” - from 27 990 CZK
iOS Developer Account
• Bound to Apple ID
  • Registration is free
  • XCode/SDK download is free
   •   but it offers development for iOS simulator
       only
iOS Developer Account
• iOS Developer Program - $99 / year
  • Installation on devices
  • App Store publishing
  • Support
Member Center
• A dashboard website, a quick pointer
  • Dev Centers
  • Provisioning Portal
  • iTunes Connect
  • Resource Center, Developer
   Support, Forums
Developer Center
• Separate dev centers for iOS, Mac OS
   and Web development
 • A place to find
   • Resources, videos, tutorials, docs, ...
   • Early access downloads
Provisioning portal
• Register your development devices
  • max. 100 iOS devices / year
  • one-time removal
• Manage certificates
• Register AppID
• Create a provisioning profile
Provisioning profile
• Development / Distribution profiles
• A composite entity that contains
  • Certificates
  • AppID
  • Devices
Provisioning Process
iTunes Connect
• Manage applications
• Manage legal contracts
• Sales statistics
• Financial Reports, User Management,
  Contact
Member Center
• A dashboard that points to
  • Dev Centers          ~ Learn & Do
  • Provisioning Portal ~ Test
  • iTunes Connect       ~ Distribute
  • Resource Center, Developer
   Support, Forums
App Store
iOS Overview
iOS Overview
• Unix based, high performance
• Strict memory management
• Multi-tasking since iOS 4
• Apps are sandboxed
• Specific features accessed via public
  iOS SDK APIs
Memory management
• Application receives memory
  warnings from the OS
• Must react on it quickly
  • ... free up as much memory as
    possible as quickly as possible
• ... otherwise, it’s killed
Multi-tasking
• Application transitions among states
  • Not Running
  • Inactive
  • Active
  • Background
  • Suspended
User’s perspective
• Multitasking is
  transparent
• “List of last used apps”
• “List of running apps”
• Default.png should
  resemble the first app
  screen
Multi-tasking
• Apps may remain alive
  • audio
  • voip
  • location
  • newsstand
  • external / bluetooth accessory
Application sandbox
• Every application has a home folder
  • Documents folder - is backed up
  • Cache folder - isn’t backed up
  • tmp folder
Development Tools
XCode
• IDE used for Mac / iOS development
• Tight git VCS integration
• LLVM / GCC compiler
• App Store submit, ad-hoc archives
• Distributed builds
XCode - Project/Target
XCode - Storyboarding
XCode - Source Code
Instruments
• Set of visual debugging tools
  • Memory leaks / Zombie objects
  • CPU / Activity monitoring
  • Quartz performance
  • OpenGL ES performance
iPhone/iPad Simulator
• Almost like a real device
• Intel instruction set
• Inherits computer CPU and memory
• Limited set of device specific features
 •   no push, no App Store, no phone calls, no
     accelerometer, ...
Advanced demos
Advanced demos
• Augmented reality
  • Qualcom AR SDK for iOS
 •   https://developer.qualcomm.com/develop/
     mobile-technologies/augmented-reality

• Face recognition
  • OpenCV library built for iOS
 •   http://opencv.willowgarage.com
Augmented reality
Face Recognition
Objective-C & iOS SDK
Objective-C
• Object oriented language
• Derived from C
• It’s not a C++, it’s not even similar
• More similar to SmallTalk
• Dynamic, improved in a rapid pace
Confusing parts
• Methods are called selectors
• YES/NO instead of TRUE/FALSE
• nil instead of null
• self instead of this
• *.m files are implementation files
Confusing parts
• Map is called NSDictionary
• NSString constant is written as @”aa”
• NS stands for NextStep
• “hello” is a C/C++ string
Calling a selector
• Java
  int a = inst.method(12.0);

  MyClass.staticMethod(a, b);




• Objective-C
  int a = [inst methodWithParam:12.0];

  [MyClass staticMethodWithParam1:a
                           param2:b];
Selector
 • Yes, it is split in multiple parts
   •   Named parameters improve readability

   self.label.textColor = [UIColor colorWithRed:1.0
                                          green:0.0
                                           blue:0.0
                                          alpha:1.0];

   NSString *imageName = [NSString
                stringWithFormat:@”image_%d.png”, i];

   [[UIImage imageNamed:imgName]
                stretchableImageWithLeftCapWidth:27
                topCapHeight:9];

   string = [basePath stringByAppendingPathComponent:
                @"/some/file.txt"];
Declaring a selector
• Java
  public int method(double number);

  private static void staticMethod(int a, bool b);



• Objective-C
  - (int) methodWithParam:(double)number;

  + (void) staticMethodWithParam1:(int)a
                           param2:(BOOL)b;

  // note: avoid “and”, “with”, ... in selector name
  // WRONG=> initWithName:andSurname:
  //    OK=> initWithName:surname:
Declaring a class
 // Employee.h

 #import <Foundation/Foundation.h>

 @interface Employee: NSObject <EmployeeProtocol> {
     NSString _name; // often not necessary
 }

 @property (nonatomic, strong) NSString *name;
 @property (nonatomic, strong) NSString *surname;

 - (id) initWithName:(NSString*)name
             surname:(NSString*)surname;

 @end
Defining a class
 // Employee.m

 #import “Employee.h”

 @implementation Employee
 @synthesize name = _name, surname;

 - (id) initWithName:(NSString*)_name
             surname:(NSString*)_surname {
     self = [super init];
     if (self != nil) {
         self.name = _name;
         self.surname = _surname;
     }
     return self;
 }

 ...
Defining a class
 ...

 - (void) greet {
     NSLog(@”Hello, %@ %@!”, self.name, self.surname);
 }

 @end
Declaring a protocol
• Protocol ~ Interface
     // EmployeeProtocol.h

     #import <Foundation/Foundation.h>

     @protocol EmployeeProtocol <NSObject>

     - (void) greet;

     @optional

     - (void) greetPolitely;

     @end
Using a protocol
                                           Protocol
 // Employee.h

 #import <Foundation/Foundation.h>

 @interface Employee: NSObject <EmployeeProtocol> {
     int someInstanceVariable;
 }

 @property (nonatomic, strong) NSString *name;
 @property (nonatomic, strong) NSString *surname;

 - (id) initWithName:(NSString*)name
             surname:(NSString*)surname;
Declaring a category
• Category = Extending class without
  subclassing

     // NSString+Crypto.h

     #import <Foundation/Foundation.h>

     @interface NSString (Crypto)

     - (NSString*) cryptedString;

     @end
Declaring a category
• Category = Extending class without
  subclassing

     // NSString+Crypto.m

     #import "NSString+Crypto.h"

     @implementation NSString (Crypto)

     - (NSString*) cryptedString { ... }

     @end
Class Extension
• “Category” with nothing in the
  brackets
• Usually implemented in the class
  implementation file
• Used to implement private
  properties or to mask read-only
  modifier on a property
Blocks


^    • Block = piece of code
     • Used throughough the SDK
     • ~ Lambda, ~ anonymous
     • Blocks are clojures
       • __block type specifier
Blocks - UI Animations
 imageView.alpha = 0.0;
 [UIView animateWithDuration:1.0 animations:^{
     imageView.alpha = 1.0;
 } completion:^(BOOL finished) {
     if (finished) {
         // ...
     } else {
         // ...
     }
 }];
Blocks - Set filtering
 NSSet *iSet = [NSSet set];
 // ... add objects to the set


 [set objectsPassingTest:^(id obj, BOOL *stop) {
     return [self testValue:id]; // custom comparison
 }];
Memory Management
Memory management
• Every NSObject keeps a reference count
• Object is created => references = 1
  • note: created ~ init, new, copy
• Object is retained => references++
• Object is released => references--
• (references == 0) => dealloc
Memory management
• Before iOS 5: manual memory
  management was needed
 • retain / release / autorelease
 • mechanical, tedious, boring
   MyClass inst = [[MyClass alloc] init];
   // ... do something
   [inst release];
Since iOS 5 - ARC
• Automatic Reference Counting is
  available
 • Occurs during compilation
 • Still some libraries without ARC
   MyClass inst = [[MyClass alloc] init];
   // ... do something
   // object will get released in due course
Autorelease pools
• Every thread has a stack of
   autorelease pools
  • Object can register in the pool
  • In due course, the pool sends
    release to the object
  • When drained, the pool sends
    release to the object
  • Useful when creating many objects
Autorelease pools
 // HeavyMasacreComputator.m

 - (void) doSomething {
     for (int i = 0; i <   TRILLION_TRILLIONS; i++) {
         for (int j = 0;   j < TRILLION; j++) {
             MyClass c =   [[MyClass alloc] init];
             // do stuff   with my class
         }
     }
 }
Autorelease pools
 // HeavyMasacreComputator.m

 - (void) doSomething {
     for (int i = 0; i < TRILLION_TRILLIONS; i++) {
         @autoreleasepool {
             for (int j = 0; j < TRILLION; j++) {
                 MyClass c = [[MyClass alloc] init];
                 // do stuff with my class
             }
         }
     }
 }
Autorelease pools
 // HeavyMasacreComputator.m - pre iOS 5

 - (void) doSomething {
     for (int i = 0; i < TRILLION_TRILLIONS; i++) {
         NSAutoreleasePool *pool = [[NSAutoreleasePool
                                     alloc] init];
         for (int j = 0; j < TRILLION; j++) {
             MyClass c = [[[MyClass alloc] init]
                                    autorelease];
             // do stuff with my class
         }
         [pool drain];
     }
 }
Ownership Qualifiers
• How objects are assigned
  • __strong            - retained


  • __unsafe_unretained - not retained


  • __weak              - dtto, set to nil on dealloc


  • __autoreleasing     - retained, autoreleased
Properties
• Getter / Setter for the instance
  variables
• “Dot notation” for access
• Flags in the header file
• Synthesized in the implementation
  file
• Read-only / read-write properties
Properties
• Property vs. iVar
  • self.name ~ getter / setter used
    • [self name];
    • [self setName:@”Petr”];
  • name          ~ direct access to iVar
    • name = @”hello”;
Properties
• Implied ownership qualifiers for iVar
  • strong, retain, copy
      => __strong
 • weak
      => __weak
 • assign, unsafe_unretained
       => __unsafe_unretained
UI Elements
UIKit - The Gist
• Framework for iOS UI
• UI Components, gesture recognizers
• MVC approach
  • UIViewController manages UIView
  • UIViewController references model
UIKit - MVC diagram
               Model
UI Consistency
• Controls and views are customizable
• iOS is a very consistent platform, less
  is often more
• Follow iOS Human Interface
  Guidelines
iOS UI - Tools
• Storyboard / Interface Builder
• Hints in code for actions/outlets
  • IBAction
  • IBOutlet
• “Segue” since iOS 5
  • View transitions for free
Network Aware Apps
Networking
• Three classes to make it work
 •   [NSURL URLWithString:@”http://google.com”];

 •   [NSURLRequest requestWithUrl:url];

 •   [NSURLConnection connectionWithRequest:request
                                   delegate:self]




                              ???
Delegate
• Similar to observer pattern
  • “Only one instance of observer”
• An object that receives callbacks
• Uses protocol to define the callbacks
• Musn’t be retained to avoid retain
  cycles => “weak”
DataSource
• Structure is the same as for the
  delegate
 • not retained
 • bound by a protocol
• Callbacks are used to feed data to
  a view
Connection callbacks
// NSURLConnectionDataDelegate formal protocol since iOS 5

// HTTP response
- (void) connection:(NSURLConnection *)connection
 didReceiveResponse:(NSURLResponse *)response;


// Data chunk received
- (void) connection:(NSURLConnection *)connection
     didReceiveData:(NSData *)data;


// All done
- (void) connectionDidFinishLoading:(NSURLConnection *)conn;


// Problem with connection
- (void) connection:(NSURLConnection *)connection
   didFailWithError:(NSError *)error;
Processing JSON
• JSON-Framework
  • New BSD Licence
  • JSON parser and generator
  • http://stig.github.com/json-
    framework/
Processing XML
• TouchXML
  • Modified BSD Licence
  • DOM parser + XPath, XML
   Namespaces
 • https://github.com/TouchCode/
   TouchXML
Resources
•   Stack Overflow

•   iOS Dev Center

•   iOS Human Interface Guidelines

•   View Controller Catalog for iOS

•   clang: a C language family frontend for LLVM

•   Augmented Reality (Vuforia™)

•   OpenCV Wiki

•   JSON Framework on GitHub

•   TouchXML on GitHub
Thank you
                   http://www.inmite.eu/talks



Petr Dvořák
Partner & iOS Development Lead
@joshis_tweets

Más contenido relacionado

La actualidad más candente

Running YUI 3 on Node.js - JSConf 2010
Running YUI 3 on Node.js - JSConf 2010Running YUI 3 on Node.js - JSConf 2010
Running YUI 3 on Node.js - JSConf 2010Adam Moore
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQueryAlek Davis
 
Getting started with jQuery
Getting started with jQueryGetting started with jQuery
Getting started with jQueryGill Cleeren
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCAWhymca
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jqueryKostas Mavridis
 
How to make Ajax Libraries work for you
How to make Ajax Libraries work for youHow to make Ajax Libraries work for you
How to make Ajax Libraries work for youSimon Willison
 
iOS Memory Management Basics
iOS Memory Management BasicsiOS Memory Management Basics
iOS Memory Management BasicsBilue
 
Hibernate
Hibernate Hibernate
Hibernate Sunil OS
 
Can puppet help you run docker on a T2.Micro?
Can puppet help you run docker on a T2.Micro?Can puppet help you run docker on a T2.Micro?
Can puppet help you run docker on a T2.Micro?Neil Millard
 
From YUI3 to K2
From YUI3 to K2From YUI3 to K2
From YUI3 to K2kaven yan
 
Jquery dojo slides
Jquery dojo slidesJquery dojo slides
Jquery dojo slideshelenmga
 
Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)iloveigloo
 

La actualidad más candente (17)

iOS5 NewStuff
iOS5 NewStuffiOS5 NewStuff
iOS5 NewStuff
 
Running YUI 3 on Node.js - JSConf 2010
Running YUI 3 on Node.js - JSConf 2010Running YUI 3 on Node.js - JSConf 2010
Running YUI 3 on Node.js - JSConf 2010
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Getting started with jQuery
Getting started with jQueryGetting started with jQuery
Getting started with jQuery
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
 
jQuery-1-Ajax
jQuery-1-AjaxjQuery-1-Ajax
jQuery-1-Ajax
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jquery
 
How to make Ajax Libraries work for you
How to make Ajax Libraries work for youHow to make Ajax Libraries work for you
How to make Ajax Libraries work for you
 
iOS Memory Management Basics
iOS Memory Management BasicsiOS Memory Management Basics
iOS Memory Management Basics
 
Hibernate
Hibernate Hibernate
Hibernate
 
Can puppet help you run docker on a T2.Micro?
Can puppet help you run docker on a T2.Micro?Can puppet help you run docker on a T2.Micro?
Can puppet help you run docker on a T2.Micro?
 
From YUI3 to K2
From YUI3 to K2From YUI3 to K2
From YUI3 to K2
 
Jquery dojo slides
Jquery dojo slidesJquery dojo slides
Jquery dojo slides
 
Web2.0 with jQuery in English
Web2.0 with jQuery in EnglishWeb2.0 with jQuery in English
Web2.0 with jQuery in English
 
Django at Scale
Django at ScaleDjango at Scale
Django at Scale
 
Django Heresies
Django HeresiesDjango Heresies
Django Heresies
 
Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)
 

Similar a iOS Development Lecture 1 - The Basics

Beginning to iPhone development
Beginning to iPhone developmentBeginning to iPhone development
Beginning to iPhone developmentVonbo
 
iOS 2 - The practical Stuff
iOS 2 - The practical StuffiOS 2 - The practical Stuff
iOS 2 - The practical StuffPetr Dvorak
 
iOS,From Development to Distribution
iOS,From Development to DistributioniOS,From Development to Distribution
iOS,From Development to DistributionTunvir Rahman Tusher
 
Getting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumGetting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumTechday7
 
Getting started with titanium
Getting started with titaniumGetting started with titanium
Getting started with titaniumNaga Harish M
 
Developing iOS REST Applications
Developing iOS REST ApplicationsDeveloping iOS REST Applications
Developing iOS REST Applicationslmrei
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developerscacois
 
Objective-C Is Not Java
Objective-C Is Not JavaObjective-C Is Not Java
Objective-C Is Not JavaChris Adamson
 
iOS App with Parse.com as RESTful Backend
iOS App with Parse.com as RESTful BackendiOS App with Parse.com as RESTful Backend
iOS App with Parse.com as RESTful BackendStefano Zanetti
 
MFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsMFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsPetr Dvorak
 
Cross platform mobile development
Cross platform mobile development Cross platform mobile development
Cross platform mobile development Alberto De Bortoli
 
Adventures in cross platform ConnectJS / TiConnect 2014
Adventures in cross platform ConnectJS / TiConnect 2014Adventures in cross platform ConnectJS / TiConnect 2014
Adventures in cross platform ConnectJS / TiConnect 2014Jason Kneen
 
Connect.Tech- Swift Memory Management
Connect.Tech- Swift Memory ManagementConnect.Tech- Swift Memory Management
Connect.Tech- Swift Memory Managementstable|kernel
 
iOS & Drupal
iOS & DrupaliOS & Drupal
iOS & DrupalFoti Dim
 
Introducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsIntroducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsRichard Rodger
 

Similar a iOS Development Lecture 1 - The Basics (20)

Beginning to iPhone development
Beginning to iPhone developmentBeginning to iPhone development
Beginning to iPhone development
 
iOS 2 - The practical Stuff
iOS 2 - The practical StuffiOS 2 - The practical Stuff
iOS 2 - The practical Stuff
 
iOS,From Development to Distribution
iOS,From Development to DistributioniOS,From Development to Distribution
iOS,From Development to Distribution
 
Getting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumGetting started with Appcelerator Titanium
Getting started with Appcelerator Titanium
 
Getting started with titanium
Getting started with titaniumGetting started with titanium
Getting started with titanium
 
Intro to appcelerator
Intro to appceleratorIntro to appcelerator
Intro to appcelerator
 
Developing iOS REST Applications
Developing iOS REST ApplicationsDeveloping iOS REST Applications
Developing iOS REST Applications
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
 
Ios development
Ios developmentIos development
Ios development
 
Objective-C Is Not Java
Objective-C Is Not JavaObjective-C Is Not Java
Objective-C Is Not Java
 
Calabash for iPhone apps
Calabash for iPhone appsCalabash for iPhone apps
Calabash for iPhone apps
 
iOS App with Parse.com as RESTful Backend
iOS App with Parse.com as RESTful BackendiOS App with Parse.com as RESTful Backend
iOS App with Parse.com as RESTful Backend
 
MFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsMFF UK - Advanced iOS Topics
MFF UK - Advanced iOS Topics
 
Cross platform mobile development
Cross platform mobile development Cross platform mobile development
Cross platform mobile development
 
Adventures in cross platform ConnectJS / TiConnect 2014
Adventures in cross platform ConnectJS / TiConnect 2014Adventures in cross platform ConnectJS / TiConnect 2014
Adventures in cross platform ConnectJS / TiConnect 2014
 
Connect.Tech- Swift Memory Management
Connect.Tech- Swift Memory ManagementConnect.Tech- Swift Memory Management
Connect.Tech- Swift Memory Management
 
iOS & Drupal
iOS & DrupaliOS & Drupal
iOS & Drupal
 
DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
 
Introducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsIntroducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.js
 
20120816 nodejsdublin
20120816 nodejsdublin20120816 nodejsdublin
20120816 nodejsdublin
 

Más de Petr Dvorak

Czech Banks are Under Attack, Clients Lose Money.
Czech Banks are Under Attack, Clients Lose Money.Czech Banks are Under Attack, Clients Lose Money.
Czech Banks are Under Attack, Clients Lose Money.Petr Dvorak
 
Innovations on Banking - Digital Banking Security in the Age of Open Banking
Innovations on Banking - Digital Banking Security in the Age of Open BankingInnovations on Banking - Digital Banking Security in the Age of Open Banking
Innovations on Banking - Digital Banking Security in the Age of Open BankingPetr Dvorak
 
mDevCamp 2016 - Zingly, or how to design multi-banking app
mDevCamp 2016 - Zingly, or how to design multi-banking appmDevCamp 2016 - Zingly, or how to design multi-banking app
mDevCamp 2016 - Zingly, or how to design multi-banking appPetr Dvorak
 
Jak vypadá ideální bankovní API?
Jak vypadá ideální bankovní API? Jak vypadá ideální bankovní API?
Jak vypadá ideální bankovní API? Petr Dvorak
 
Smart Cards and Devices Forum 2016 - Bezpečnost multi-banking mobilních aplikací
Smart Cards and Devices Forum 2016 - Bezpečnost multi-banking mobilních aplikacíSmart Cards and Devices Forum 2016 - Bezpečnost multi-banking mobilních aplikací
Smart Cards and Devices Forum 2016 - Bezpečnost multi-banking mobilních aplikacíPetr Dvorak
 
Bankovní API ve světě
Bankovní API ve světěBankovní API ve světě
Bankovní API ve světěPetr Dvorak
 
PSD2 a bankovní API: Top 5 mýtů, které dnes slyšíte
PSD2 a bankovní API: Top 5 mýtů, které dnes slyšítePSD2 a bankovní API: Top 5 mýtů, které dnes slyšíte
PSD2 a bankovní API: Top 5 mýtů, které dnes slyšítePetr Dvorak
 
Představení Zingly API Serveru a popis integrace
Představení Zingly API Serveru a popis integracePředstavení Zingly API Serveru a popis integrace
Představení Zingly API Serveru a popis integracePetr Dvorak
 
Lime - PowerAuth 2.0 and mobile QRToken introduction
Lime - PowerAuth 2.0 and mobile QRToken introductionLime - PowerAuth 2.0 and mobile QRToken introduction
Lime - PowerAuth 2.0 and mobile QRToken introductionPetr Dvorak
 
Lime - Push notifications. The big way.
Lime - Push notifications. The big way.Lime - Push notifications. The big way.
Lime - Push notifications. The big way.Petr Dvorak
 
Zingly - Dopad multi-bankingu a otevřených bankovních API do obchodního fungo...
Zingly - Dopad multi-bankingu a otevřených bankovních API do obchodního fungo...Zingly - Dopad multi-bankingu a otevřených bankovních API do obchodního fungo...
Zingly - Dopad multi-bankingu a otevřených bankovních API do obchodního fungo...Petr Dvorak
 
Co musí banka udělat pro zapojení do Zingly?
Co musí banka udělat pro zapojení do Zingly?Co musí banka udělat pro zapojení do Zingly?
Co musí banka udělat pro zapojení do Zingly?Petr Dvorak
 
Bezpečnost Zingly a detaily protokolu PowerAuth 2.0
Bezpečnost Zingly a detaily protokolu PowerAuth 2.0Bezpečnost Zingly a detaily protokolu PowerAuth 2.0
Bezpečnost Zingly a detaily protokolu PowerAuth 2.0Petr Dvorak
 
Zingly - Single app for all banks
Zingly - Single app for all banksZingly - Single app for all banks
Zingly - Single app for all banksPetr Dvorak
 
Fashiontech 2015 - iBeacon: Co to je a k čemu je to dobré?
Fashiontech 2015 - iBeacon: Co to je a k čemu je to dobré?Fashiontech 2015 - iBeacon: Co to je a k čemu je to dobré?
Fashiontech 2015 - iBeacon: Co to je a k čemu je to dobré?Petr Dvorak
 
Webinář: Co je to iBeacon a proč by vás to mělo zajímat?
Webinář: Co je to iBeacon a proč by vás to mělo zajímat?Webinář: Co je to iBeacon a proč by vás to mělo zajímat?
Webinář: Co je to iBeacon a proč by vás to mělo zajímat?Petr Dvorak
 
Chytré telefony v ČR - H1/2015
Chytré telefony v ČR -  H1/2015Chytré telefony v ČR -  H1/2015
Chytré telefony v ČR - H1/2015Petr Dvorak
 
What are "virtual beacons"?
What are "virtual beacons"?What are "virtual beacons"?
What are "virtual beacons"?Petr Dvorak
 
mDevCamp 2015 - iBeacon aneb jak ochytřit vaše aplikace o kontext uživatele
mDevCamp 2015 - iBeacon aneb jak ochytřit vaše aplikace o kontext uživatelemDevCamp 2015 - iBeacon aneb jak ochytřit vaše aplikace o kontext uživatele
mDevCamp 2015 - iBeacon aneb jak ochytřit vaše aplikace o kontext uživatelePetr Dvorak
 
iCON DEV - iBeacon, aneb jak ochytřit vaše aplikace o kontext uživatele
iCON DEV - iBeacon, aneb jak ochytřit vaše aplikace o kontext uživateleiCON DEV - iBeacon, aneb jak ochytřit vaše aplikace o kontext uživatele
iCON DEV - iBeacon, aneb jak ochytřit vaše aplikace o kontext uživatelePetr Dvorak
 

Más de Petr Dvorak (20)

Czech Banks are Under Attack, Clients Lose Money.
Czech Banks are Under Attack, Clients Lose Money.Czech Banks are Under Attack, Clients Lose Money.
Czech Banks are Under Attack, Clients Lose Money.
 
Innovations on Banking - Digital Banking Security in the Age of Open Banking
Innovations on Banking - Digital Banking Security in the Age of Open BankingInnovations on Banking - Digital Banking Security in the Age of Open Banking
Innovations on Banking - Digital Banking Security in the Age of Open Banking
 
mDevCamp 2016 - Zingly, or how to design multi-banking app
mDevCamp 2016 - Zingly, or how to design multi-banking appmDevCamp 2016 - Zingly, or how to design multi-banking app
mDevCamp 2016 - Zingly, or how to design multi-banking app
 
Jak vypadá ideální bankovní API?
Jak vypadá ideální bankovní API? Jak vypadá ideální bankovní API?
Jak vypadá ideální bankovní API?
 
Smart Cards and Devices Forum 2016 - Bezpečnost multi-banking mobilních aplikací
Smart Cards and Devices Forum 2016 - Bezpečnost multi-banking mobilních aplikacíSmart Cards and Devices Forum 2016 - Bezpečnost multi-banking mobilních aplikací
Smart Cards and Devices Forum 2016 - Bezpečnost multi-banking mobilních aplikací
 
Bankovní API ve světě
Bankovní API ve světěBankovní API ve světě
Bankovní API ve světě
 
PSD2 a bankovní API: Top 5 mýtů, které dnes slyšíte
PSD2 a bankovní API: Top 5 mýtů, které dnes slyšítePSD2 a bankovní API: Top 5 mýtů, které dnes slyšíte
PSD2 a bankovní API: Top 5 mýtů, které dnes slyšíte
 
Představení Zingly API Serveru a popis integrace
Představení Zingly API Serveru a popis integracePředstavení Zingly API Serveru a popis integrace
Představení Zingly API Serveru a popis integrace
 
Lime - PowerAuth 2.0 and mobile QRToken introduction
Lime - PowerAuth 2.0 and mobile QRToken introductionLime - PowerAuth 2.0 and mobile QRToken introduction
Lime - PowerAuth 2.0 and mobile QRToken introduction
 
Lime - Push notifications. The big way.
Lime - Push notifications. The big way.Lime - Push notifications. The big way.
Lime - Push notifications. The big way.
 
Zingly - Dopad multi-bankingu a otevřených bankovních API do obchodního fungo...
Zingly - Dopad multi-bankingu a otevřených bankovních API do obchodního fungo...Zingly - Dopad multi-bankingu a otevřených bankovních API do obchodního fungo...
Zingly - Dopad multi-bankingu a otevřených bankovních API do obchodního fungo...
 
Co musí banka udělat pro zapojení do Zingly?
Co musí banka udělat pro zapojení do Zingly?Co musí banka udělat pro zapojení do Zingly?
Co musí banka udělat pro zapojení do Zingly?
 
Bezpečnost Zingly a detaily protokolu PowerAuth 2.0
Bezpečnost Zingly a detaily protokolu PowerAuth 2.0Bezpečnost Zingly a detaily protokolu PowerAuth 2.0
Bezpečnost Zingly a detaily protokolu PowerAuth 2.0
 
Zingly - Single app for all banks
Zingly - Single app for all banksZingly - Single app for all banks
Zingly - Single app for all banks
 
Fashiontech 2015 - iBeacon: Co to je a k čemu je to dobré?
Fashiontech 2015 - iBeacon: Co to je a k čemu je to dobré?Fashiontech 2015 - iBeacon: Co to je a k čemu je to dobré?
Fashiontech 2015 - iBeacon: Co to je a k čemu je to dobré?
 
Webinář: Co je to iBeacon a proč by vás to mělo zajímat?
Webinář: Co je to iBeacon a proč by vás to mělo zajímat?Webinář: Co je to iBeacon a proč by vás to mělo zajímat?
Webinář: Co je to iBeacon a proč by vás to mělo zajímat?
 
Chytré telefony v ČR - H1/2015
Chytré telefony v ČR -  H1/2015Chytré telefony v ČR -  H1/2015
Chytré telefony v ČR - H1/2015
 
What are "virtual beacons"?
What are "virtual beacons"?What are "virtual beacons"?
What are "virtual beacons"?
 
mDevCamp 2015 - iBeacon aneb jak ochytřit vaše aplikace o kontext uživatele
mDevCamp 2015 - iBeacon aneb jak ochytřit vaše aplikace o kontext uživatelemDevCamp 2015 - iBeacon aneb jak ochytřit vaše aplikace o kontext uživatele
mDevCamp 2015 - iBeacon aneb jak ochytřit vaše aplikace o kontext uživatele
 
iCON DEV - iBeacon, aneb jak ochytřit vaše aplikace o kontext uživatele
iCON DEV - iBeacon, aneb jak ochytřit vaše aplikace o kontext uživateleiCON DEV - iBeacon, aneb jak ochytřit vaše aplikace o kontext uživatele
iCON DEV - iBeacon, aneb jak ochytřit vaše aplikace o kontext uživatele
 

Último

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Último (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

iOS Development Lecture 1 - The Basics

  • 1. iOS Development Lecture 1 - The basics Petr Dvořák Partner & iOS Development Lead @joshis_tweets
  • 3. Outline • iOS app development ecosystem • Required hardware • iOS Developer Account & App Store • iOS Overview • XCode and Instruments • The cool stuff you can do
  • 4. Outline • Objective-C and iOS SDK • Basic language syntax • Classes, protocols, categories • Memory management
  • 5. Outline • UI Elements on iOS • Overview of the UI building blocks • Storyboard / Interface Builder
  • 6. Outline • Network aware applications • Connecting to on-line resources • Processing XML and JSON
  • 8. Required hardware • Any computer/laptop with Mac OS X • Mac Mini - from 13 990 CZK • MacBook Pro 13” - from 27 990 CZK
  • 9. iOS Developer Account • Bound to Apple ID • Registration is free • XCode/SDK download is free • but it offers development for iOS simulator only
  • 10. iOS Developer Account • iOS Developer Program - $99 / year • Installation on devices • App Store publishing • Support
  • 11. Member Center • A dashboard website, a quick pointer • Dev Centers • Provisioning Portal • iTunes Connect • Resource Center, Developer Support, Forums
  • 12. Developer Center • Separate dev centers for iOS, Mac OS and Web development • A place to find • Resources, videos, tutorials, docs, ... • Early access downloads
  • 13. Provisioning portal • Register your development devices • max. 100 iOS devices / year • one-time removal • Manage certificates • Register AppID • Create a provisioning profile
  • 14. Provisioning profile • Development / Distribution profiles • A composite entity that contains • Certificates • AppID • Devices
  • 16. iTunes Connect • Manage applications • Manage legal contracts • Sales statistics • Financial Reports, User Management, Contact
  • 17. Member Center • A dashboard that points to • Dev Centers ~ Learn & Do • Provisioning Portal ~ Test • iTunes Connect ~ Distribute • Resource Center, Developer Support, Forums
  • 20. iOS Overview • Unix based, high performance • Strict memory management • Multi-tasking since iOS 4 • Apps are sandboxed • Specific features accessed via public iOS SDK APIs
  • 21. Memory management • Application receives memory warnings from the OS • Must react on it quickly • ... free up as much memory as possible as quickly as possible • ... otherwise, it’s killed
  • 22. Multi-tasking • Application transitions among states • Not Running • Inactive • Active • Background • Suspended
  • 23. User’s perspective • Multitasking is transparent • “List of last used apps” • “List of running apps” • Default.png should resemble the first app screen
  • 24. Multi-tasking • Apps may remain alive • audio • voip • location • newsstand • external / bluetooth accessory
  • 25. Application sandbox • Every application has a home folder • Documents folder - is backed up • Cache folder - isn’t backed up • tmp folder
  • 27. XCode • IDE used for Mac / iOS development • Tight git VCS integration • LLVM / GCC compiler • App Store submit, ad-hoc archives • Distributed builds
  • 31. Instruments • Set of visual debugging tools • Memory leaks / Zombie objects • CPU / Activity monitoring • Quartz performance • OpenGL ES performance
  • 32. iPhone/iPad Simulator • Almost like a real device • Intel instruction set • Inherits computer CPU and memory • Limited set of device specific features • no push, no App Store, no phone calls, no accelerometer, ...
  • 34. Advanced demos • Augmented reality • Qualcom AR SDK for iOS • https://developer.qualcomm.com/develop/ mobile-technologies/augmented-reality • Face recognition • OpenCV library built for iOS • http://opencv.willowgarage.com
  • 38. Objective-C • Object oriented language • Derived from C • It’s not a C++, it’s not even similar • More similar to SmallTalk • Dynamic, improved in a rapid pace
  • 39. Confusing parts • Methods are called selectors • YES/NO instead of TRUE/FALSE • nil instead of null • self instead of this • *.m files are implementation files
  • 40. Confusing parts • Map is called NSDictionary • NSString constant is written as @”aa” • NS stands for NextStep • “hello” is a C/C++ string
  • 41. Calling a selector • Java int a = inst.method(12.0); MyClass.staticMethod(a, b); • Objective-C int a = [inst methodWithParam:12.0]; [MyClass staticMethodWithParam1:a param2:b];
  • 42. Selector • Yes, it is split in multiple parts • Named parameters improve readability self.label.textColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0]; NSString *imageName = [NSString stringWithFormat:@”image_%d.png”, i]; [[UIImage imageNamed:imgName] stretchableImageWithLeftCapWidth:27 topCapHeight:9]; string = [basePath stringByAppendingPathComponent: @"/some/file.txt"];
  • 43. Declaring a selector • Java public int method(double number); private static void staticMethod(int a, bool b); • Objective-C - (int) methodWithParam:(double)number; + (void) staticMethodWithParam1:(int)a param2:(BOOL)b; // note: avoid “and”, “with”, ... in selector name // WRONG=> initWithName:andSurname: // OK=> initWithName:surname:
  • 44. Declaring a class // Employee.h #import <Foundation/Foundation.h> @interface Employee: NSObject <EmployeeProtocol> { NSString _name; // often not necessary } @property (nonatomic, strong) NSString *name; @property (nonatomic, strong) NSString *surname; - (id) initWithName:(NSString*)name surname:(NSString*)surname; @end
  • 45. Defining a class // Employee.m #import “Employee.h” @implementation Employee @synthesize name = _name, surname; - (id) initWithName:(NSString*)_name surname:(NSString*)_surname { self = [super init]; if (self != nil) { self.name = _name; self.surname = _surname; } return self; } ...
  • 46. Defining a class ... - (void) greet { NSLog(@”Hello, %@ %@!”, self.name, self.surname); } @end
  • 47. Declaring a protocol • Protocol ~ Interface // EmployeeProtocol.h #import <Foundation/Foundation.h> @protocol EmployeeProtocol <NSObject> - (void) greet; @optional - (void) greetPolitely; @end
  • 48. Using a protocol Protocol // Employee.h #import <Foundation/Foundation.h> @interface Employee: NSObject <EmployeeProtocol> { int someInstanceVariable; } @property (nonatomic, strong) NSString *name; @property (nonatomic, strong) NSString *surname; - (id) initWithName:(NSString*)name surname:(NSString*)surname;
  • 49. Declaring a category • Category = Extending class without subclassing // NSString+Crypto.h #import <Foundation/Foundation.h> @interface NSString (Crypto) - (NSString*) cryptedString; @end
  • 50. Declaring a category • Category = Extending class without subclassing // NSString+Crypto.m #import "NSString+Crypto.h" @implementation NSString (Crypto) - (NSString*) cryptedString { ... } @end
  • 51. Class Extension • “Category” with nothing in the brackets • Usually implemented in the class implementation file • Used to implement private properties or to mask read-only modifier on a property
  • 52. Blocks ^ • Block = piece of code • Used throughough the SDK • ~ Lambda, ~ anonymous • Blocks are clojures • __block type specifier
  • 53. Blocks - UI Animations imageView.alpha = 0.0; [UIView animateWithDuration:1.0 animations:^{ imageView.alpha = 1.0; } completion:^(BOOL finished) { if (finished) { // ... } else { // ... } }];
  • 54. Blocks - Set filtering NSSet *iSet = [NSSet set]; // ... add objects to the set [set objectsPassingTest:^(id obj, BOOL *stop) { return [self testValue:id]; // custom comparison }];
  • 56. Memory management • Every NSObject keeps a reference count • Object is created => references = 1 • note: created ~ init, new, copy • Object is retained => references++ • Object is released => references-- • (references == 0) => dealloc
  • 57. Memory management • Before iOS 5: manual memory management was needed • retain / release / autorelease • mechanical, tedious, boring MyClass inst = [[MyClass alloc] init]; // ... do something [inst release];
  • 58. Since iOS 5 - ARC • Automatic Reference Counting is available • Occurs during compilation • Still some libraries without ARC MyClass inst = [[MyClass alloc] init]; // ... do something // object will get released in due course
  • 59. Autorelease pools • Every thread has a stack of autorelease pools • Object can register in the pool • In due course, the pool sends release to the object • When drained, the pool sends release to the object • Useful when creating many objects
  • 60. Autorelease pools // HeavyMasacreComputator.m - (void) doSomething { for (int i = 0; i < TRILLION_TRILLIONS; i++) { for (int j = 0; j < TRILLION; j++) { MyClass c = [[MyClass alloc] init]; // do stuff with my class } } }
  • 61. Autorelease pools // HeavyMasacreComputator.m - (void) doSomething { for (int i = 0; i < TRILLION_TRILLIONS; i++) { @autoreleasepool { for (int j = 0; j < TRILLION; j++) { MyClass c = [[MyClass alloc] init]; // do stuff with my class } } } }
  • 62. Autorelease pools // HeavyMasacreComputator.m - pre iOS 5 - (void) doSomething { for (int i = 0; i < TRILLION_TRILLIONS; i++) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; for (int j = 0; j < TRILLION; j++) { MyClass c = [[[MyClass alloc] init] autorelease]; // do stuff with my class } [pool drain]; } }
  • 63. Ownership Qualifiers • How objects are assigned • __strong - retained • __unsafe_unretained - not retained • __weak - dtto, set to nil on dealloc • __autoreleasing - retained, autoreleased
  • 64. Properties • Getter / Setter for the instance variables • “Dot notation” for access • Flags in the header file • Synthesized in the implementation file • Read-only / read-write properties
  • 65. Properties • Property vs. iVar • self.name ~ getter / setter used • [self name]; • [self setName:@”Petr”]; • name ~ direct access to iVar • name = @”hello”;
  • 66. Properties • Implied ownership qualifiers for iVar • strong, retain, copy => __strong • weak => __weak • assign, unsafe_unretained => __unsafe_unretained
  • 68. UIKit - The Gist • Framework for iOS UI • UI Components, gesture recognizers • MVC approach • UIViewController manages UIView • UIViewController references model
  • 69. UIKit - MVC diagram Model
  • 70. UI Consistency • Controls and views are customizable • iOS is a very consistent platform, less is often more • Follow iOS Human Interface Guidelines
  • 71. iOS UI - Tools • Storyboard / Interface Builder • Hints in code for actions/outlets • IBAction • IBOutlet • “Segue” since iOS 5 • View transitions for free
  • 73. Networking • Three classes to make it work • [NSURL URLWithString:@”http://google.com”]; • [NSURLRequest requestWithUrl:url]; • [NSURLConnection connectionWithRequest:request delegate:self] ???
  • 74. Delegate • Similar to observer pattern • “Only one instance of observer” • An object that receives callbacks • Uses protocol to define the callbacks • Musn’t be retained to avoid retain cycles => “weak”
  • 75. DataSource • Structure is the same as for the delegate • not retained • bound by a protocol • Callbacks are used to feed data to a view
  • 76. Connection callbacks // NSURLConnectionDataDelegate formal protocol since iOS 5 // HTTP response - (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response; // Data chunk received - (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data; // All done - (void) connectionDidFinishLoading:(NSURLConnection *)conn; // Problem with connection - (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
  • 77. Processing JSON • JSON-Framework • New BSD Licence • JSON parser and generator • http://stig.github.com/json- framework/
  • 78. Processing XML • TouchXML • Modified BSD Licence • DOM parser + XPath, XML Namespaces • https://github.com/TouchCode/ TouchXML
  • 79. Resources • Stack Overflow • iOS Dev Center • iOS Human Interface Guidelines • View Controller Catalog for iOS • clang: a C language family frontend for LLVM • Augmented Reality (Vuforia™) • OpenCV Wiki • JSON Framework on GitHub • TouchXML on GitHub
  • 80. Thank you http://www.inmite.eu/talks Petr Dvořák Partner & iOS Development Lead @joshis_tweets