ios Dev Crib Sheet In the Shadow of C

Similar documents
INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011

An Introduction to Modern Software Development Tools Creating A Simple GUI-Based Tool Appleʼs XCode Version 3.2.6

ios Development Tutorial Nikhil Yadav CSE 40816/60816: Pervasive Health 09/09/2011

iphone Objective-C Exercises

INTRODUCTION TO IOS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 13 02/22/2011

Introduction to iphone Development

geniusport mobility training experts

Creating a Custom Class in Xcode

Praktikum Entwicklung von Mediensystemen mit

MA-WA1920: Enterprise iphone and ipad Programming

Application Programming on the Mac COSC346

ios Dev Fest Research Network Operations Center Thursday, February 7, 13

Objective C and iphone App

Assignment I Walkthrough

Objective-C and Cocoa User Guide and Reference Manual. Version 5.0

Moving from CS 61A Scheme to CS 61B Java

Chapter 1. Introduction to ios Development. Objectives: Touch on the history of ios and the devices that support this operating system.

Source Code Translation

View Controller Programming Guide for ios

ios App Development for Everyone

Object Oriented Programming and the Objective-C Programming Language 1.0. (Retired Document)

Customize Mobile Apps with MicroStrategy SDK: Custom Security, Plugins, and Extensions

Start Developing ios Apps Today

MEAP Edition Manning Early Access Program Hello! ios Development version 14

UML FOR OBJECTIVE-C. Excel Software

Using PyObjC for Developing Cocoa Applications with Python

How To Develop An App For Ios (Windows)

NSPersistentDocument Core Data Tutorial for Mac OS X v10.4. (Retired Document)

Developing for the App Store. (Legacy)

Mobility Introduction Android. Duration 16 Working days Start Date 1 st Oct 2013

Xcode Application note

Tag Specification Document

Key-Value Coding Programming Guide

ios Design Patterns Jackie Myrose CSCI 5448 Fall 2012

Teaching App Development with Swift Course Materials Overview

Using the Caché Objective-C Binding

Swift for PHP Developers

Praktikum Entwicklung von Mediensystemen mit ios

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

Programming Cocoa with Ruby Create Compelling Mac Apps Using RubyCocoa

2. About iphone ios 5 Development Essentials. 5. Joining the Apple ios Developer Program

1 Introduction. 2 An Interpreter. 2.1 Handling Source Code

ios Application Development &

ios Development: Getting Started Min Tsai March 1, 2011 terntek.com v1.0

Contents. About Testing with Xcode 4. Quick Start 7. Testing Basics 23. Writing Test Classes and Methods 28. At a Glance 5 Prerequisites 6 See Also 6

Objective-C Tutorial

This documentation is made available before final release and is subject to change without notice and comes with no warranty express or implied.

COLLIN COLLEGE COURSE SYLLABUS

A Java Crib Sheet. First: Find the Command Line

Kevin Hoffman. Sams Teach Yourself. Mac OS* X Lion" App Development. 800 East 96th Street, Indianapolis, Indiana, USA

Getting Started with the Internet Communications Engine

Developing Applications for ios

Application Development for Mobile and Ubiquitous Computing

Introduction to Object-Oriented Programming

IOS App Development Training

Ruby and Python Programming Topics for Mac. (Retired Document)

Cocoa Fundamentals Guide. (Retired Document)

Softwareprojekt: Mobile Development Einführung Objective-C. Miao Wang, Tinosch Ganjineh Freie Universität Berlin, Institut für Informatik

Mobile Application Development

Xcode User Default Reference. (Legacy)

Copyright 2010 The Pragmatic Programmers, LLC.

Development of an iphone business application

Cross-platform mobile development with Visual C

Learning ios Programming

Appendix... B. The Object Constraint

Swift vs. Objective-C: A New Programming Language

3 Improving the Crab more sophisticated programming

Xcode Project Management Guide. (Legacy)

Developing Mapping Applications with ArcGIS Runtime SDK for Windows Mobile. Jay Chen Justin Colville

Star Micronics Cloud Services ios SDK User's Manual

Java Application Developer Certificate Program Competencies

Bonus ChapteR. Objective-C

A Way Out of the Mobile App Development Conundrum

Salesforce Mobile Push Notifications Implementation Guide

research: technical implemenation

Learn iphone and ipad game apps development using ios 6 SDK. Beginning. ios 6 Games. Development. Lucas Jordan. ClayWare Games tm

The C Programming Language course syllabus associate level

VB.NET Programming Fundamentals

geniusport mobility training experts

D06 PROGRAMMING with JAVA. Ch3 Implementing Classes

Everything is Terrible

Reactive Variability Realization with Test-Driven Development and Refactoring

THE ROAD TO CODE. ANDROID DEVELOPMENT IMMERSIVE May 31. WEB DEVELOPMENT IMMERSIVE May 31 GENERAL ASSEMBLY

Accessibility on ios. Make an app for everyone. Chris Fleizach ios Accessibility. Wednesday, December 1, 2010

A Comparison of Programming Languages for Graphical User Interface Programming

ArcGIS Viewer for Silverlight An Introduction

Transcription:

ios Dev Crib Sheet As you dive into the deep end of the ios development pool, the first thing to remember is that the mother ship holds the authoritative documentation for this endeavor http://developer.apple.com/ios Some of this documentation is also available from within Xcode, so that is worth figuring out as well But, until then, here are some notes that may help get you started and acclimatized In the Shadow of C The ios programming language is Objective-C: it is a superset of C, with object-oriented constructs This provenance drives virtually every idiosyncrasy in the language the verbose syntax, lack of true garbage collection, occasional repetitiveness, and other things that quite frankly drive programmers who know other languages pretty batty But, it can call existing C code seamlessly; is this a worthwhile tradeoff? Now there s a fun language design discussion The question is academic for development though, as this is the single official ios programming language

The Long Arm of Java As it turns out, JavaScript is not the only name that was motivated by the marketing mojo that Java used to have in ios, we have Cocoa (or, more precisely, Cocoa Touch) Where Objective-C is the language of ios development, Cocoa Touch is its primary library To complete the triumvirate, we have Xcode, the primary development environment for the platform A Bit of History All of these technologies trace their lineage, quite directly, to NeXTSTEP, the development platform of the NeXT computers from the late 1980s to 1990s This technology became the basis for Mac OS X, which in turn is the basis for what is now ios This is why many of the classes you ll see start with NS yes, they go back that far Would you say that the technology is showing is age? That is another fun discussion

Objective-C Tidbits (This assumes that you are familiar with object-oriented programming concepts and terms) Objective-C classes are typically separated into.h files, which define what is publicly accessible about them, and.m files, which supply their implementation A class s definition is given in a block that starts with @interface and ends with (reasonably enough) @end Its implementation, in turn, is delimited by (surprise) @implementation and @end To distinguish Objective-C s constructs from C, strikingly different syntax is used: Methods are written in infix notation, preceded by for instance methods and + for class methods, with colons : separating a method s name segments from its parameters Method invocations are delimited by brackets [ ] Certain declarations take the form of keywords preceded by the @ sign Objective-C also has a form of closure, called blocks they begin with a caret ^ followed by the block s return type and parameters, both in parentheses

Constructors can actually be any class method that returns an instance of that class The typical baseline constructor separates object memory allocation (the alloc class method) from initialization (the init instance method): [[Classname alloc] init]; Objective-C (in ios) does not have automatic garbage collection you generally invoke the retain method if you want to keep an object beyond the current scope then call release when you no longer need it If you want the gory details, look up Objective-C memory management Other concepts/keywords/types include: protocols These are similar to Java s interfaces; classes that satisfy a protocol specify it between angle brackets < > nil This is Objective-C s null object keyword self This is Objective-C s this object keyword id This is Objective-C s generic object data type " " literals are standard C strings; to specify an actual string object i.e., an instance of the NSString class use @" " IBOutlet and IBAction These keywords mark properties and methods that are visible to user interface components (more on those later) Classes to learn about first: NSObject (duh), NSString, NSArray, NSDictionary, NSInteger, and NSNumber

ios App Fundamentals Like all C programs, the entry point to an ios app is the main function, typically in a file named main.m The main function eventually calls UIApplicationMain, which in turn instantiates your app delegate class this is typically where your actual code starts The rest of your application is a collection of model objects, views, and controllers Cocoa adheres to the MVC paradigm quite closely Creating Views In Cocoa, views (user interface elements) may be created both programmatically (i.e., in Objective-C code) or visually, using an interface builder tool (separate in Xcode versions < 4, integrated after that) Visually created views are stored in separate files called NIBs (there s that NeXTSTEP legacy again NIB stood for NeXT Interface Builder ) Special hooks associate the user interface in a NIB with a particular owning class (usually its controller)

Typical ios Workflow 1. Initialize an ios project using Xcode with one of its prebuilt templates this creates a baseline app of a certain type (as determined by the template), with stubbed out methods and NIBs (sure, you can start up a project from absolutely nothing, but why bother when a lot of pieces are relatively standardized) 2. Start tweaking the NIBs to your liking (presumably you have a design already sketched out) stay cognizant of ios user interface guidelines while doing this 3. Modify the NIBs owning classes to correspond with the user interface elements that you have defined and the methods that they need to call: a. User interface elements that you will need to access programmatically should be defined as IBOutlet properties of the owning class b. Methods that your user interface elements will call (usually in response to user actions or events) should have the signature (IBAction)methodName:(id)sender 4. Associate the NIBs user interface elements with their corresponding outlets and actions 5. Build, run, and test the app; rinse and repeat

Digging Deeper As with most object-oriented platforms, effective ios development relies on familiarity with and proper use of its class library get to know the structure of the available documentation so you can find the class that you need and the things that it can do Heed the MVC paradigm well: data and core computation should be separated into their own, plain old classes (model objects), and user actions (events) in views should call controller methods that then update or use these model objects Write unit tests Objective-C/Cocoa s testing framework can call unit tests in isolated functional parts ( logic tests ) or within the full context of the ios app ( application tests ) Start putting your app on an actual ios device getting started here is a whole other set of hoops to jump, but is pretty straightforward once you get over the setup pains, not the least of which is interacting with the ios Provisioning Portal web site at: https://developer.apple.com/ios/manage/overview/index.action Get to know the plethora of events, notifications, and transitions that an ios app experiences, as well as what to do when these take place