Introduction to Cocoa Programming

Similar documents
GNUstep: What is it? gnustep.org

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

These are exciting times for Macintosh users. When Apple unleashed Mac

Xcode and Swift CS 4720 Mobile Application Development

Principles of Programming Languages. Objective-C. Joris Kluivers

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

Praktikum Entwicklung von Mediensystemen mit

Welcome to CS193E. Mac OS X Cocoa Programming. James Dempsey Paul Marcos

COCOA WORKSHOP PART 1. Andreas Monitzer

AppleScript Overview

Toyin Adedokun & Daniel Laughlin. Exploring the iphone SDK

Chapter 2. Operating-System Structures

Computer Science, a Mac, and You. Kevin Cathey Junior, Computer Science

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

Cocoa Programming. David Chisnall. March 18,

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

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

Operating System Services. User Services. System Operation Services. User Operating System Interface - CLI. A View of Operating System Services

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

CS193P: HelloPoly Walkthrough

Mobile App Development. ios Platform

CS 371L - Mobile Computing (ios) Dr. William C. Bulko. CS 371L Mobile Computing (ios) Introduction

iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department

CHAPTER 2: SYSTEM STRUCTURES. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Chapter 2: Operating-System Structures

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

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edition

CS193E Lecture #3 Categories and Protocols Cocoa Memory Management

Xcode. Chapter 1. Creating a Project

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edit9on

Topics in Mobile Computing

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?

Cocoa Fundamentals Guide

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

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

ITP 342 Advanced Mobile App Dev. Memory

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

MacOS X Cocoa Programming for Vision Scientist --- #1

Objective-C and COCOA Applications

My First Cocoa Program

Introduction to Java Programming

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

Cocoa Programming A Quick-Start Guide for Developers

Richard Mallion. Swift for Admins #TEAMSWIFT

CS 47. Beginning iphone Application Development

ios Application Development Course Details

What s New in the LLVM Compiler. Chris Lattner LLVM Chief Architect

Chapter 2: System Structures. Operating System Concepts 9 th Edition

Objective-C Phrasebook (Developer's Library) By David Chisnall READ ONLINE

ROOT on ios and RootBrowser app

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

AC : OBJECTIVE-C VERSUS JAVA FOR SMART PHONE AP- PLICATIONS

Outline Smalltalk Overview Pragmatic Smalltalk Closing. Pragmatic Smalltalk. David Chisnall. February 7,

CS193p Spring 2010 Wednesday, March 31, 2010

My First iphone App. 1. Tutorial Overview

Collections & Memory Management. Lecture 2

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

Announcement. Final Project Proposal Presentations and Updates

The MVC Design Pattern

Beginning Mac Programming

Contents at a Glance

Chapter 0 : MVC review / Threading & Concurrency. CSCI 251 Android App Development

Architectural Support for Operating Systems. Jinkyu Jeong ( Computer Systems Laboratory Sungkyunkwan University

Chapter 2: System Structures

ITP 342 Mobile App Dev. Fundamentals

Traditional vs. Mobile Operating Systems

Introduction to PyObjC

Project Number: CS- MXC EVE Mac Suite

Traditional Smalltalk Playing Well With Others Performance Etoile. Pragmatic Smalltalk. David Chisnall. August 25, 2011

Another difference is that the kernel includes only the suspend to memory mechanism, and not the suspend to hard disk, which is used on PCs.

Objective-C: An Introduction (pt 1) Tennessee Valley Apple Developers Saturday CodeJam July 24, 2010 August 7, 2010

Richard Wentk. Cocoa. Developer Reference.

User Interfaces. Lecture 15. Application Programming on Mac OS. Hamza Bennani September 4, 2018

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

ArcGIS for Developers: An Introduction. Moey Min Ken

Christopher Sean Morrison

Using Doxygen to Create Xcode Documentation Sets

Grand Central Dispatch and NSOperation. CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015

Science. Computer Science

Integrating Game Center into a BuzzTouch 1.5 app

Four Components of a Computer System

IPHONE. Development Jump Start. phil nash levelofindirection.com

Amp Server and Amp Server Pro SDK

Programming Concepts: IDEs, Debug. Paulo Penteado. (

Memory Management: The Details

Certified Core Java Developer VS-1036

MANNING IN ACTION SAMPLE CHAPTER. Brendan G. Lim. WITH Jerry Cheung AND Jeremy McAnally

Author Bob Ippolito Conference. PyObjC Hacking. PyCon DC, March 2005

CS193E: Temperature Converter Walkthrough

Objective-c Gnustep Base Programming Manual

ITP 342 Mobile App Dev. Connections

Automator Programming Guide

Hello! ios Development

Introduction to Concurrent Software Systems. CSCI 5828: Foundations of Software Engineering Lecture 08 09/17/2015

Extensibility in GNUstep & Étoilé

Systems software design. Software build configurations; Debugging, profiling & Quality Assurance tools

E Event-based parser, XML, 180 Extended attributes, URLs, 118 API, 119 command line, 118 description, 118 NSURL category, 119

Richard Wentk. Cocoa. Developer Reference.

About Xcode and iphone SDK

Praktikum Entwicklung von Mediensystemen mit ios

Transcription:

Introduction to Cocoa Programming Dr. Ken Tabb Computer Science Dept. University of Hertfordshire

Agenda Brief history of Cocoa Apple s free Developer Tools - Xcode - Interface Builder Cocoa programming environment - Objective-C syntax - Cocoa frameworks Demos along the way

Cocoa: a brief history...

History of Cocoa API Object oriented API from NeXTSTEP / OPENSTEP... NS prefix to class names Originally only usable via Objective-C, now accessible from: - Java - AppleScript - Ruby - Python -... and others GNUstep provides a consistent API for non-mac flavours of UNIX / Linux www.gnustep.org

Apple s Developer Tools

Apple s Developer Tools QuartzDebug OpenGL Profiler MallocDebug ObjectAlloc Thread Viewer Spin Control Sampler Shark Window refreshing Monitor OpenGL calls Locate memory leaks Monitor object allocation Identify deadlocks / waits Identify waits / GUI locks Monitor performance Monitor performance

Apple s Developer Tools Xcode Code editor Compiler / Linker / Debugger Support for a variety of languages Distributed Build Fix and Continue Zero link Predictive Compile

Apple s Developer Tools Interface Builder Graphical interface designer Allows rapid designing of interfaces Provides conformance to Aqua human interface guidelines Can provide code stubs Enables code <-> GUI interaction

Demo: Building a web browser

Cocoa programming environment

Objective-C Superset of ANSI C allowing objectoriented programming C code works fine Stored in.h and.m files Can be mixed with other languages Syntax is very Smalltalk-like Easy to learn entire Obj-C syntax Learning entire Cocoa API takes much longer

Other language syntaxes C afunction (astruct,...,...,...); C++ (instance) anobject. amethod(...,...,...); C++ (pointer) anobjectptr -> amethod(...,...,...); Java anobject. amethod(...,...,...);

Objective-C syntax [ anobject amessage : value1 with2ndparameter : value2 and3rdparameter : value3 ] ;

Xcode & IB Integration IBOutlet Connects code to GUI IBOutlet id mytextfield; [mytextfield setfloatvalue:123.456]; IBOutlet IBAction Connects GUI to code Do Something IBAction - (IBAction)zoomIn:(id)sender { [self scaleimageto:(_scale * 2)]; //double size }

Objective-C memory Obj-C does not have Java s garbage collection Obj-C does not have C/C++ s memory headaches either Obj-C uses reference counting: [myobject retain]; //increments reference count [myobject release]; //decrements reference count [myobject autorelease]; //decrements reference count later

Cocoa Frameworks Foundation Data types Core technologies Application Kit (a.k.a. AppKit) Application architecture objects GUI widgets WebKit, OpenGL, CoreAudio, QuickTime, others...

Demo: Wrapping UNIX in Aqua

NSTask class Allows integration between Cocoa and UNIX commands Can be piped together (using NSPipe class) Runs command asynchronously Doesn t expand environment variables - Doesn t know about $PATH - You have to specify /bin/, /usr/bin/, /sbin/ etc.

The Objective-C code - (IBAction)runTask:(id)sender { NSTask *thetask = [[NSTask alloc] init]; NSString *theoutput; NSPipe *outputpipe = [[NSPipe alloc] init]; NSFileHandle *handle; [thetask setlaunchpath:[taskfield stringvalue]]; [thetask setarguments:[nsarray arraywithobject:[argsfield stringvalue]]]; [thetask setcurrentdirectorypath:[directoryfield stringvalue]]; [thetask setstandardoutput:outputpipe]; handle = [outputpipe filehandleforreading]; [thetask launch]; theoutput = [[NSString alloc] initwithdata: [handle readdatatoendoffile] encoding:nsasciistringencoding]; [outputfield setstring:theoutput]; } [theoutput autorelease]; [outputpipe autorelease]; [thetask autorelease];

Some light reading

Useful Books... Cocoa 382 pages, 25 ISBN: 0596003013 648 pages, 32 ISBN: 0596002351 128 pages, 9 ISBN: 0596004230 566 pages, 28 ISBN: 0596004621

Q&A Dr. Ken Tabb Computer Science Dept. University of Hertfordshire