OVERVIEW. Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net

Similar documents
Intro to Native ios Development. Dave Koziol Arbormoon Software, Inc.

ITP 342 Advanced Mobile App Dev. Memory

Review. iphone Application Programming Lecture 2: Objective-C, Cocoa. History. Objective-C. Device restrictions. Interaction paradigm changes

Questions. Exams: no. Get by without own Mac? Why ios? ios vs Android restrictions. Selling in App store how hard to publish? Future of Objective-C?

Objective-C Primer. iphone Programmer s Association. Lorenzo Swank September 10, 2008

Design Phase. Create a class Person. Determine the superclass. NSObject (in this case)

Announcement. Final Project Proposal Presentations and Updates

CS193P - Lecture 3. iphone Application Development. Custom Classes Object Lifecycle Autorelease Properties

Building GUIs with UIKit. Kevin Cathey

IPHONE DEVELOPMENT. Getting Started with the iphone SDK

Review. iphone Application Programming Lecture 2: Objective-C, Cocoa. History. Objective-C. Device restrictions. Interaction paradigm changes

Mobile Application Development

epicurious Anatomy of an ios app Robert Tolar Haining June 25, 2010 ConvergeSE

CSC 581: Mobile App Development Spring 2018

Designing iphone Applications

View Controllers CPRE 388

ITP 342 Mobile App Dev. Fundamentals

ios: Objective-C Primer

Mobile Application Programming. Objective-C Classes

CS193p Spring 2010 Thursday, April 29, 2010

iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5

Objective-C and COCOA Applications

Stanford CS193p. Developing Applications for ios Fall Stanford CS193p. Fall 2013

CS193E Lecture #3 Categories and Protocols Cocoa Memory Management

Object-Oriented Programming with Objective-C. Lecture 2

iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department

Memory Management: The Details

The MVC Design Pattern

Your First iphone OS Application

Object-Oriented Programming in Objective-C

Corrections and version notes

iphone Application Tutorial

User Experience: Windows & Views

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010

Principles of Programming Languages. Objective-C. Joris Kluivers

Objective-C ICT/7421ICTNathan. René Hexel. School of Information and Communication Technology Griffith University.

Your First iphone Application

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Spring Stanford CS193p Spring 2011

CS193p Spring 2010 Monday, April 12, 2010

Acollada ios Charting Components

InterfaceBuilder and user interfaces

My First iphone App. 1. Tutorial Overview

Navigation bar (Xcode version 4.5.2) 1. Create a new project. From the Xcode menu, select File > New > Project

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016

View Controller Lifecycle

Objective-C and Cocoa User Guide and Reference Manual

Praktikum Entwicklung von Mediensystemen mit

Mobile Computing. Overview. What is ios? 8/26/12. CSE 40814/60814 Fall 2012

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Introductory ios Development

Objective-C. Stanford CS193p Fall 2013

Lesson 1: Hello ios! 1

Porting Objective-C to Swift. Richard Ekle

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

View Concepts. iphone Application Programming Lecture 4: User Interface Design. SDK provide many types of Views to show your content

ios Development Lecture 1 Introduction to Objective-C Ing. Simone Cirani

COCOA WORKSHOP PART 1. Andreas Monitzer

Page 1. GUI Programming. Lecture 13: iphone Basics. iphone. iphone

Mobile Application Development

CS 47. Beginning iphone Application Development

Developing Applications for ios

Cocoa. Last Week... Music 3SI: Introduction to Audio/Multimedia App. Programming. Today... Why Cocoa? Wikipedia - Cocoa

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

Mobile Application Development

Advanced ios. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 20 11/01/2012

Praktikum Entwicklung von Mediensystemen mit ios

Structuring an App Copyright 2013 Apple Inc. All Rights Reserved.

Mobile Application Development

ios Application Development Course Details

Lecture 8 Demo Code: Cassini Multithreading

Intro to Development for ios. Dave Koziol Arbormoon Software, Inc.

CSE 438: Mobile Application Development Lab 2: Virtual Pet App

Duration 5 days (For basic crowd 5+3days needed)

IPHONE. Development Jump Start. phil nash levelofindirection.com

Review (Basic Objective-C)

ITP 342 Mobile App Dev. Connections

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015

View Concepts. iphone Application Programming Lecture 4: User Interface Design. SDK provide many types of Views to show your content

Introduction to Cocoa Programming

Topics in Mobile Computing

ITP 342 Mobile App Dev. Connections

CS193p Spring 2010 Wednesday, March 31, 2010

ios Development Lecture 3 Controllers of View Controllers Ing. Simone Cirani

About MSDOSX. Lecture 0

Xcode and Swift CS 4720 Mobile Application Development

CS193E Lecture 7. Document-based Applications NSTableView Key-Value Coding

Why Model-View-Controller?

Assignment I Walkthrough

Praktikum Entwicklung von Mediensystemen mit ios

MVC & Onwards. CS 442: Mobile App Development Michael Saelee

ios Mobile Development

Mobile Application Programming. Memory Management

Objectives. Submission. Register for an Apple account. Notes on Saving Projects. Xcode Shortcuts. CprE 388 Lab 1: Introduction to Xcode

Introductory ios Development

Objective-C Part 2 (ECS189H) Ken Joy Serban Porumbescu

X Review. Mac OS X Roots: NeXT. BWS Available for virtually every OS

CS193P: HelloPoly Walkthrough

Esri Developer Summit in Europe ArcGIS Runtime for ios

Widget Tour. iphone and ipod touch Development Fall 2009 Lecture 7

ios Mobile Development

Transcription:

OVERVIEW Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net

Microsoft MVP for 4 years C#, WinForms, WPF, Silverlight Joined Cynergy about 2 years ago Working in native ios ever since ijoshsmith.com (my ios blog)

MY BOOK ios Programming for.net Developers iosfordotnetdevs.com Paperback, ibooks, Kindle, Nook

WHY MOBILE? Huge demand for mobile devs Large budgets for mobile projects Lots of greenfield dev work! :-)

WHY IOS? Not the only choice, but a good one Many mobile projects focus on ios Perceived difficulty == Mo Money

IOS APP PLATFORMS Xamarin/MonoTouch - C# PhoneGap - HTML/JavaScript Native - Objective-C

MY FIRST REAL IOS PROJECT

TRANE MAP For HVAC salespeople Select systems to sell Present systems to homeowner Create and sign proposal on ipad Generate PDF proposal document

VIDEO Trane MAP via Cynergy.com

LESSONS LEARNED Mobile apps are a different breed Mobile form factor matters Apps can (easily) run out of memory Naming conventions are important Core Data is terrific Be careful re: data model versioning

NOT IN KANSAS ANYMORE Windows Visual Studio OS X Xcode C# or VB.NET Objective-C Garbage Collection.NET Runtime Base Class Library WPF or SL or WinForms Reference Counting Objective-C Runtime Foundation UIKit

TOUR DE XCODE Let s take a guided tour of Apple s IDE...

OBJECTIVE-C!= C#

OBJECTIVE-C Superset of C Object orientation a la Smalltalk Obj-C Runtime supports OO

POINTERS 101 Pointer is 8 bytes of memory Stores a memory address Not guaranteed to be valid

POINTERS EXAMPLE int *pointertoint = NULL; int someint = 42; // Assign the pointer the address of someint. pointertoint = &someint; // Dereference the pointer and assign it a value. *pointertoint = 101; assert(someint == 101);

NIL / NULL nil - for pointer to Obj-C object NULL - for pointer to C value NSNull - similar to.net DBNull Nil - for pointer to a Class object

NIL HANDLING nil is false and non-nil is true if (apointer!= nil)...is equivalent to... if (apointer)

CALLING A METHOD Obj-C message passing [anobject somemethod]; C# anobject.somemethod();

MESSAGE TO NIL Messages sent to nil are ignored Evaluates to default of return type (0) Edge cases if method returns C struct

PASSING AN ARGUMENT Obj-C [dev learnskill:@ ios ]; C# dev.learnskill( ios );

PASSING ARGUMENTS Obj-C [obj setoffset:42 animated:yes]; C# obj.setoffset(42, true);

CREATING AN OBJECT Obj-C JASFoo *f = [[JASFoo alloc] init]; JASFoo *f = [JASFoo new]; C# Foo f = new Foo();

.H &.M FILES Classes are split between two files Header (.h) - declarations Implementation (.m) - definitions

CLASS DECLARATION Obj-C (in.h file) @interface JASFoo : NSObject - (BOOL)hello; @end C# does not have an equivalent

CLASS DEFINITION Obj-C (in.m file) @implementation JASFoo { } NSString *_anivar; - (BOOL)hello { return NO; } @end C# (in.cs file) public class Foo { } private string _afield; public bool Hello() { return false; }

METHODS Declared in.h file (optional) Defined in.m file Class methods prefixed with + Instance methods prefixed with -

CLASS METHODS Similar to static methods in.net Can be overridden by subclasses!!! Template: + (return_type)methodname:(arg_type)argname Example: + (JASFoo *)foowithurl:(nsurl *)url;

INSTANCE METHODS Template: - (return_type)methodname:(arg_type)argname Example: - (int)indexofobject:(id)anobject;

PROPERTIES Declared in.h @property (nonatomic, copy) NSString *name; Synthesized by compiler Custom accessor methods in.m Example usage: obj.name = @ Arthur Dent ;

THE SELF POINTER Similar to this in C# Points to object in instance methods Points to a Class in class methods

THE SELF POINTER Obj-C float f = [self instancemethod]; double d = self->_anivar; C# float f = this.instancemethod(); double d = this.afield;

OBJECT INITIALIZER Like a constructor in.net - (id)init { self = [super init]; if (self) { // Assign initial values. _anivar = 42; } return self; }

DEALLOC Called before an object is killed - (void)dealloc { [_anivar cleanup]; // Only if ARC disabled... [super dealloc]; }

MEMORY MANAGEMENT

MEMORY MANAGEMENT No Garbage Collector Reference/Retain Counting Automatic Reference Counting (ARC)

OBJECT OWNERSHIP Objects live while owned Owned == Retained An owner retains an object

OBJECT OWNERSHIP Deallocated when retain count is 0 Deallocated immediately by runtime Pointer to dead object is dangling

NSOBJECT +ALLOC +alloc Allocates new object Initial retain count of 1

NSOBJECT -RETAIN -retain method Increments receiver s retain count

NSOBJECT -RELEASE -release method Decrements receiver s retain count If retain count reaches 0 object dies

NSOBJECT -AUTORELEASE -autorelease method Delayed decrement of retain count Used when returning a new object

NSOBJECT -DEALLOC -dealloc method Relinquish ownership of objects Invoked when retain count is 0

EXAMPLE Foo *f = [[Foo alloc] init]; // f s retain count is 1 [f dosomethingawesome]; [f release]; // f s retain count is 0 // f s -dealloc executes f = nil; // Assign nil to avoid dangling pointer

ARC Compiler feature Adds memory mgmt to your code Introduced in ios 5

EXAMPLE WITH ARC Foo *f = [[Foo alloc] init]; [f dosomethingawesome];

FOUNDATION VS. BCL

OBJECT VS. NSOBJECT

STRING VS. NSSTRING

STRINGBUILDER VS. NSMUTABLESTRING

DATETIME VS. NSDATE

ARRAY VS. NSARRAY

HASHTABLE VS. NSMUTABLEDICTIONARY

UIKIT

UIKIT High-level user interface API Provides the ios look & feel Based on MVC pattern

DRAWING SYSTEMS

VIEWS UIView is the basic UI object Views can contain subviews Views are contained by a superview

UIVIEW SUBCLASSES UIButton UILabel UITextField UIImageView UITableView

VIEW CONTROLLERS Manage a set of Views Container controller (manages controllers) Content controller (displays stuff)

CONTAINER CONTROLLERS UINavigationController UITabBarController UIPageViewController UISplitViewController (ipad only)

CONTENT CONTROLLERS UITableViewController subclasses Your UIViewController subclasses

MODAL PRESENTATION Controllers can be presented Presented controllers are modal Modal controllers are dismissed

PRESENTATION EXAMPLE

XIB FILE Contains a View XML data Edited via Interface Builder

STORYBOARD FILE Contains multiple Views ( scenes ) Defines navigation paths ( segues ) Edited via Interface Builder

OUTLETS A property or ivar on a Controller Assigned a View pointer automatically Hooked up in Interface Builder

ACTIONS UI event handling methods Defined in Controller classes Hooked up in Interface Builder

LET S WRITE AN APP! Create View with Interface Builder Add outlets and action to Controller Concatenate two NSStrings Display calculated value in View

SUMMARY Different terms, similar ideas Xcode is Apple s free IDE Objective-C is (kinda) like C# Foundation contains common classes UIKit and Interface Builder create UIs There is a lot more to know...

LEARN MORE iosfordotnetdevs.com ios Programming for.net Developers

Q&A