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

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

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

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

Contents. iphone Training. Industry Trainers. Classroom Training Online Training ON-DEMAND Training. Read what you need

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

CSC 581: Mobile App Development Spring 2018

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

Assignment II: Foundation Calculator

User Experience: Windows & Views

Acollada ios Charting Components

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

Assignment IV: Smashtag Mentions

Cocoa Touch Best Practices

IPHONE DEVELOPMENT. Getting Started with the iphone SDK

CS193p Spring 2010 Monday, April 12, 2010

Announcement. Final Project Proposal Presentations and Updates

iphone Programming Touch, Sound, and More! Norman McEntire Founder Servin Flashlight CodeTour TouchCount CodeTour

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

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

ITP 342 Advanced Mobile App Dev. Memory

ITP 342 Mobile App Development. Singleton

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

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

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

Designing iphone Applications

What's new in ios 5?

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

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

Mobile Application Development

lecture 10 UI/UX and Programmatic Design cs : spring 2018

Objective-C Runtime. Cocoa s Jewel in the Crown. NSConference Nicolas

Apple Development Technology Workshops

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

MVC and Interface Builder IAP 2010

Monday, 1 November The ios System

InterfaceBuilder and user interfaces

iphone Application Programming Lecture 5: View Programming

View Controller Lifecycle

Stichwortverzeichnis. 379, #define 287, 407 #import 50, 99 #pragma mark 415

New UIKit Support for International User Interfaces

Building GUIs with UIKit. Kevin Cathey

Developing Applications for ios

Enhancing your apps for the next dimension of touch

Your First iphone OS Application

ios Application Development Course Details

Lesson 1: Hello ios! 1

CS193P - Lecture 8. iphone Application Development. Scroll Views & Table Views

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

COCOA WORKSHOP PART 1. Andreas Monitzer

AVAudioRecorder & System Sound Services

Using Swift with Cocoa and Objective-C

A Better MVC. 300 line view controllers or bust. Dave A guy who thinks too deeply about stuff

Collections & Memory Management. Lecture 2

CS193E Lecture #3 Categories and Protocols Cocoa Memory Management

Your First iphone Application

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

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

Using Advanced Interface Objects and Views

The MVC Design Pattern

Review. Objective-C Classes, Methods, Properties, Protocols, Delegation, Memory Management

Document Version Date: 1st March, 2015

Data IAP 2010 iphonedev.csail.mit.edu edward benson / Thursday, January 14, 2010

iphone Application Tutorial

Advanced Memory Analysis with Instruments. Daniel Delwood Performance Tools Engineer

Types of Views. View category Purpose Examples of views. Display a particular type of content, such as an image or text.

iphone Game Software development using Apple Core API s Mobile video content streaming for iphone using HTTP Live Streaming

Localizing with Xcode 6

Introduction to Cocoa Programming

Mobile Application Programming. Memory Management

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

COMP327 Mobile Computing Session: Lecture Set 1a - Swift Introduction and the Foundation Framework Part 2

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

CS193p Spring 2010 Thursday, April 29, 2010

AVAudioPlayer. avtouch Application

Working Effectively with Objective-C on iphone OS. Blaine Garst Wizard of Runtimes

Data Management

Mobile Application Programming. Controls

Examples and solutions for iphone & ipad. J. Harrington B. Trebitowski C. Allen S. Appelcline MANNING

Science. Computer Science

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

COPYRIGHTED MATERIAL. part I Developing a Professional UI. Chapter 1: Creating a Personal Library. Chapter 2: Advancing with Tableviews

Views. A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space

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

Naviga&on and Tab Bar Controllers and Table View

Core Animation. Building Animated UI s. Bill Dudney. Gala Factory Software LLC. Bill Dudney Core Animation: Building Animated UI s Slide 1

User Experience: Windows & Views

Testing ios Apps. Graham Lee Monday, 25 March 13

Assignment III: Graphing Calculator

CS193P: HelloPoly Walkthrough

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

SAMPLE CHAPTER. Brendan G. Lim Martin Conte Mac Donell MANNING

Mobile Application Development

Introducing the Modern WebKit API

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

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

APP. ios. Construction Strategy and Main Technology of the Mobile Library APP Take ios for Instance. 2 ios. ios. UI MVC ios APP G250 APP

iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department

Mastering UIKit on tvos

Objective-C and COCOA Applications

COMP327 Mobile Computing. Lecture Set 9 - Model, View, Controller

Transcription:

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

Disclaimer Content was blatantly and unapologetically stolen from the WWDC 2007 Fundamentals of Cocoa session, as well as from CocoaDevCentral.com. This content, the ipa modifications to it, and my sarcastic comments are not endorsed or approved by the original content authors. All material is used for academic purposes and is, therefore, probably fair use. Thank you.

Overview What is Cocoa Touch? Objective-C Overview

Resources Apple Developer Connection Resource Library http://developer.apple.com/resourcelibrary

What is Cocoa Touch? Object-oriented APIs Frameworks Foundation UIKit Others

Foundation Core framework for non-ui functionality - Root class

Foundation Core framework for non-ui functionality - Root class NSObject

Foundation Core framework for non-ui functionality - Root class - Operating system facilities and interaction NSFileManager, NSBundle, NSPort, NSStream, NSTask, NSHost, NSRunLoop, NSDate

Foundation Core framework for non-ui functionality - Root class - Operating system facilities and interaction - Internationalization NSString, NSCharacterSet, NSNumberFormatter, NSDateFormatter, NSLocale

Foundation Core framework for non-ui functionality - Root class - Operating system facilities and interaction - Internationalization - Collections NSArray, NSMutableArray, NSDictionary, NSSet, Property Lists

Foundation Core framework for non-ui functionality - Root class - Operating system facilities and interaction - Internationalization - Collections - Scripting NSAppleScript, NSScriptCommand

Foundation Core framework for non-ui functionality - Root class - Operating system facilities and interaction - Internationalization - Collections - Scripting - XML processing, Web access NSXMLParser, NSXMLDocument, NSXMLNode, NSURL, NSUrlRequest, NSUrlResponse

Foundation Core framework for non-ui functionality - Root class - Operating system facilities and interaction - Internationalization - Collections - Scripting - XML processing, Web access - Lots of other stuff

UIKit Core framework for UI functionality - Top Level Interfaces UIApplication, UIScreen

UIKit Core framework for UI functionality - Top Level Interfaces - Drawing UIWindow, UIView, UIColor, UIFont, UIImage, UIImageView

UIKit Core framework for UI functionality - Top Level Interfaces - Drawing - Event Handling UIEvent, UIAcceleration, UIAccelerometer, UITouch

UIKit Core framework for UI functionality - Top Level Interfaces - Drawing - Event Handling - Standard Controls UIControl, UIButton UILabel, UISegmentedControl, UIActivityIndicatorView, UIDatePicker

UIKit Core framework for UI functionality - Top Level Interfaces - Drawing - Event Handling - Standard Controls - Standard Views UIScrollView, UIWebView, UITableView

UIKit Core framework for UI functionality - Top Level Interfaces - Drawing - Event Handling - Standard Controls - Standard Views - Standard View Controllers UIViewController, UINavigationController, UITabBarController, UITableViewController, UIImagePickerController

Interface Builder

UICatalog

What is Objective-C? Small superset of C - ANSI C - Some additional syntax - A few additional types Dynamic object runtime Single inheritance

Objective-C Defining a Method -(void)setwidth:(int)width height:(int)height { _width = width; _height = height; } Sending a message (Calling a method) [contentview setwidth:100 height:100]; [[viewarrays objectatindex:n] setwidth:100

Objective-C C Style: Method Names CreateAlertView(0.0f, 0.0f, 200.0f, 150.0f, warnstring, TRUE); Objective-C Style [[AlertView alloc] initwithoriginx: 0.0f originy: 0.0f width: 200.0f height: 150.0f text: warningstring, fadeoutwhenfinished: TRUE];

Objective-C Referring to a Method SEL myselector = @selector(setwidth:height:); Referring to an object Widget* currwidget; id currwidget; Referring to self [self setwidth:150 height:150];

Objective-C String literals NSString* stringname = @ This is a little text ;

Memory Management Cocoa Touch objects are reference counted

Memory Management Cocoa Touch objects are reference counted A freshly created object has a reference count of one Widget* mywidget = [[Widget alloc] init]; Widget* yourwidget = [mywidget copy];

Memory Management Cocoa Touch objects are reference counted A freshly created object has a reference count of one Widget* mywidget = [[Widget alloc] init]; Widget* yourwidget = [mywidget copy]; retain increments the reference count

Memory Management Cocoa Touch objects are reference counted A freshly created object has a reference count of one Widget* mywidget = [[Widget alloc] init]; Widget* yourwidget = [mywidget copy]; retain increments the reference count release decrements the reference count

Memory Management Cocoa Touch objects are reference counted A freshly created object has a reference count of one Widget* mywidget = [[Widget alloc] init]; Widget* yourwidget = [mywidget copy]; retain increments the reference count release decrements the reference count An instance of the object is deallocated when its reference count reaches 0 - Object is sent dealloc

Memory Management Cocoa Touch objects are reference counted A freshly created object has a reference count of one Widget* mywidget = [[Widget alloc] init]; Widget* yourwidget = [mywidget copy]; retain increments the reference count release decrements the reference count An instance of the object is deallocated when its reference count reaches 0 - Object is sent dealloc autorelease decrements a reference count later

Memory Management

Memory Management

Reference Counting alloc [NSObjectInstance alloc] +1 copy [NSObjectInstance copy] +1 retain [NSObjectInstance retain] +1 release [NSObjectInstance release] -1 autorelease [NSObjectInstance autorelease] -1*

Object Ownership If you create it, you own it. alloc/init, copy If you were handed an object you re going to need, retain it. When you pass an object to someone else don t retain it for them.

Important Concerns What happens...... if you release an object before you are done with it?... if an object is deallocated before you are done with it?... if you explicitly call dealloc?... if you don t retain an object that you need?

Summary Cocoa Touch Frameworks Foundation UIKit Objective-C Syntax Memory Management

End

ipa Areas of Research Call for Volunteers iphone Hardware Interfacing with other devices UIKit Making it do things that are not allowed