iphone OS Overview

Size: px
Start display at page:

Download "iphone OS Overview"

Transcription

1 Founda'on Framework

2 iphone OS Overview

3 iphone OS Overview

4 iphone OS Overview

5 iphone OS Overview

6 iphone OS Overview

7 iphone OS Overview

8 iphone Development Environment

9 Cocoa in the architecture of ios

10 Cocoa Touch Architecture

11 Founda'on Framework Value and collec'on classes User defaults Archiving No'fica'ons Tasks, 'mers, threads File system, pipes, I/O, bundles

12

13

14 NSObject Root class Implements many basics Memory management Introspec'on Object equality

15 Adopted Protocols NSObject autorelease class conformstoprotocol: descrip'on hash isequal: iskindofclass: ismemberofclass: isproxy performselector: performselector:withobject: performselector:withobject:withobject: release respondstoselector: retain retaincount self superclass zone

16 Class Introspec'on You can ask an object about its class Class myclass = [myobject class]; NSLog(@"My class is %@", [myobject classname]); Tes'ng for general class membership (subclasses included): if ([myobject iskindofclass:[uicontrol class]]) { // something } Tes'ng for specific class membership (subclasses excluded): if ([myobject ismemberofclass:[nsstring class]]) { // something string specific }

17 Iden'ty versus Equality Iden'ty tes'ng equality of the pointer values if (object1 == object2) { } NSLog(@"Same exact object instance"); Equality tes'ng object abributes if ([object1 isequal: object2]) { } NSLog(@"Logically equivalent, but may be different object instances");

18 Descrip'on NSObject implements - descrip'on (NSString *)descrip'on; Objects represented in format strings using %@ When an object appears in a format string, it is asked for its descrip'on [NSString The answer is: %@, myobject]; You can log an object s descrip'on with: NSLog([anObject descrip'on]); Your custom subclasses can override descrip'on to return more specific informa'on

19 NSString General- purpose Unicode string support Unicode is a coding system which represents all of the world s languages Consistently used throughout Cocoa Touch instead of char * Without doubt the most commonly used class Easy to support any language in the world with Cocoa

20 String Constants In C constant strings are simple In ObjC, constant strings just as simple Constant strings are NSString instances NSString *astring Hello World! ;

21 Format Strings Similar to prink, but with added for objects NSString *astring Johnny ; NSString *log = [NSString It s %@, astring]; log would be set to It s Johnny Also used for logging NSLog(@ I am a %@, I have %d items, [array classname], [array count]); would log something like: I am a NSArray, I have 5 items

22 NSString Onen ask an exis'ng string for a new string with modifica'ons (NSString *)stringbyappendingstring:(nsstring *)string; (NSString *)stringbyappendingformat:(nsstring *)string; (NSString *)stringbydele'ngpathcomponent; Example: NSString *mystring Hello ; NSString *fullstring; fullstring = [mystring stringbyappendingstring:@ world! ]; fullstring would be set to Hello world!

23 NSString Common NSString methods (BOOL)isEqualToString:(NSString *)string; (BOOL)hasPrefix:(NSString *)string; (int)intvalue; (double)doublevalue; Example: NSString *mystring Hello ; NSString *otherstring 449 ; if ([mystring hasprefix:@ He ]) { // will make it here } if ([otherstring intvalue] > 500) { // won t make it here }

24 NSMutableString NSMutableString subclasses NSString Allows a string to be modified Common NSMutableString methods + (id)string; - (void)appendstring:(nsstring *)string; - (void)appendformat:(nsstring *)format,...; NSMutableString *newstring = [NSMutableString string]; [newstring appendstring:@ Hi ]; [newstring appendformat:@, my favorite number is: %d, [self favoritenumber]];

25 Collec'ons Array - ordered collec'on of objects Dic'onary - collec'on of key- value pairs Set - unordered collec'on of unique objects Common enumera'on mechanism Immutable and mutable versions Immutable collec'ons can be shared without side effect Prevents unexpected changes Mutable objects typically carry a performance overhead

26 NSArray Common NSArray methods + arraywithobjects:(id)firstobj,...; // nil terminated!!! - (unsigned)count; - (id)objectatindex:(unsigned)index; - (unsigned)indexofobject:(id)object; NSNotFound returned for index if not found NSArray *array = [NSArray arraywithobjects:@ Green, nil]; if ([array indexofobject:@ Purple ] == NSNotFound) { NSLog (@ No color purple ); } Be careful of the nil termina'on!!!

27 NSArray Examples NSArray *array; array = [NsArray one, three, nil]; int i; for (i=0; i< [array count]; i++) { NSLog (@ index %d has %a., i, [array objectatindex:i];}

28 NSArray Examples NSString *string ; NSArray *chunks = [string : ]; string = [chunks :- ) ];

29 NSMutableArray NSMutableArray subclasses NSArray So, everything in NSArray Common NSMutableArray Methods + (NSMutableArray *)array; - (void)addobject:(id)object; - (void)removeobject:(id)object; - (void)removeallobjects; - (void)insertobject:(id)object atindex:(unsigned)index; NSMutableArray *array = [NSMutableArray array]; [array addobject:@ Red ]; [array addobject:@ Green ]; [array addobject:@ Blue ]; [array removeobjectatindex:1];

30 Enumerator NSEnumator * enumerator; Enumerator = [array objectenumerator]; id thingie; while (thingie = [enumerator nextobject]) { NSLog (@ I found %a, thingie); }

31 Fast Enumera'on } for (NSString *string in array) { NSLog (@ I found %a, string);

32 NSDic'onary Common NSDic'onary methods + dic'onarywithobjectsandkeys: (id)firstobject,...; - (unsigned)count; - (id)objectforkey:(id)key; nil returned if no object found for given key NSDic'onary *colors = [NSDic'onary dic'onarywithobjectsandkeys:@ Color Color Color 3, nil]; NSString *firstcolor = [colors objectforkey:@ Color 1 ]; if ([colors objectforkey:@ Color 8 ]) { // won t make it here }

33 NSMutableDic'onary NSMutableDic'onary subclasses NSDic'onary Common NSMutableDic'onary methods + (NSMutableDic'onary *)dic'onary; - (void)setobject:(id)object forkey:(id)key; - (void)removeobjectforkey:(id)key; - (void)removeallobjects; NSMutableDic'onary *colors = [NSMutableDic'onary dic'onary]; [colors setobject:@ Orange forkey:@ HighlightColor ];

34 Another Example NSDic'onary *dict = [NSDic'onary NSMutableDic'onary *anotherdict = [NSMutableDic'onary dic'onary]; [anotherdict setobject: dict forkey: "sub- dic'onary- key"]; [anotherdict String" test"]; NSLog(@"Dic'onary: %@, Mutable Dic'onary: %@", dict, anotherdict); // now we can save these to a file NSString *savepath = [@"~/Documents/Saved.data" stringbyexpandingtildeinpath]; [anotherdict writetofile: savepath atomically: YES]; //and restore them NSMutableDic'onary *restored = [NSDic'onary dic'onarywithcontentsoffile: savepath]

35 NSSet Unordered collec'on of objects Common NSSet methods + setwithobjects:(id)firstobj,...; // nil terminated - (unsigned)count; - (BOOL)containsObject:(id)object;

36 NSMutableSet NSMutableSet subclasses NSSet Common NSMutableSet methods + (NSMutableSet *)set; - (void)addobject:(id)object; - (void)removeobject:(id)object; - (void)removeallobjects; - (void)intersectset:(nsset *)otherset; - (void)minusset:(nsset *)otherset;

37 Enumera'on Consistent way of enumera'ng over objects in collec'ons Use with NSArray, NSDic'onary, NSSet, etc. NSArray *array =... ; // assume an array of People objects // old school Person *person; int count = [array count]; for (i = 0; i < count; i++) { person = [array objectatindex:i]; NSLog([person descrip'on]); } // new school for (Person *person in array) { NSLog([person descrip'on]); }

38 NSEnumerator Example NSMutableDic'onary *mymutabledic'onary =... ; NSMutableArray *keystodeletearray = [NSMutableArray arraywithcapacity:[mymutabledic'onary count]]; NSString *akey; NSEnumerator *keyenumerator = [mymutabledic'onary keyenumerator]; while (akey = [keyenumerator nextobject]){ if ( /* test criteria for key or value */ ) { [keystodeletearray addobject:akey]; }} [mymutabledic'onary removeobjectsforkeys:keystodeletearray];

39 Fast Enumera'on for ( Type newvariable in expression ) { statements } The enumera'on is considerably more efficient than, for example, using NSEnumerator directly. The syntax is concise. Enumera'on is safe the enumerator has a muta'on guard so that if you abempt to modify the collec'on during enumera'on, an excep'on is raised.

40 Fast Enumera'on Example NSDic'onary *dic'onary = nil]; NSString *key; for (key in dic'onary) { } NSLog(@"English: %@, La'n: %@", key, [dic'onary objectforkey:key]); NSArray *array = nil]; NSEnumerator *enumerator = [array reverseobjectenumerator]; for (NSString *element in enumerator) { } if ([element isequaltostring:@"three"]) { break; } NSString *next = [enumerator nextobject];

41 Fast Enumera'on and Loop NSArray *array = /* assume this exists */; NSUInteger index = 0; for (id element in array) { } NSLog(@"Element at index %u is: %@", index, element); index++; NSArray *array = /* assume this exists */; NSUInteger index = 0; for (id element in array) { if (index!= 0) { NSLog(@"Element at index %u is: %@", index, element); } if (++index >= 6) { break; } }

42 NSNumber In Objec've- C, you typically use standard C number types NSNumber is used to wrap C number types as objects Subclass of NSValue No mutable equivalent! Common NSNumber methods + (NSNumber *)numberwithint:(int)value; + (NSNumber *)numberwithdouble:(double)value; + (NSNumber *) numberwithbool: (BOOL) value; - (int)intvalue; - (double)doublevalue; - (BOOL) boolvalue;

43 NSValue An NSValue object is a simple container for a single C or Objec've- C data item. It can hold any of the scalar types such as int, float, and char, as well as pointers, structures, and object ids. The purpose of this class is to allow items of such data types to be added to collec'ons such as instances of NSArray and NSSet, which require their elements to be objects. NSValue objects are always immutable. Constant Length

44 NSValue + (NSValue) valuewithbytes: (const void*) value objctype: (const char *) type; - (void) getvalue: (void *) value; typedef struct { float real; float imaginary; } ImaginaryNumber; ImaginaryNumber minumber, minumber2; minumber.real = 1.0; minumber.imaginary = 2.0; NSvalue *mivalue = [NSValue value: &minumber withobjctype:@encode(imaginarynumber)]; // encode using the type name [array addobject: mivalue]; value = [array objectatindex:0]; [value getvalue: &minumber2];

45 NSNull The NSNull class defines a singleton object used to represent null values in collec'on objects (which don t allow nil values). + (NSNull*) null [contact setobject: [NSNull null] home fax machine ]; id home; Homefax = [contact home fax machine ]; if (home == [NSNull null]) { } //.. No fax machine

46 Other Classes NSData / NSMutableData Arbitrary sets of bytes NSDate / NSCalendarDate Times and dates NSRange, NSPoint, NSSize, NSRect Stucture, not Object- C Object Peformance NSMakePoint(), NSMakeSize(), NSMakeRect()

47 NSDate NSDate *date =[NSDate date]; today is date]; NSDate *yesterday=[nsdate datawithtimeintervalsincenow: - (24*60*60)]; NSLog (@yesterday is %@, yesterday);

48 NSData Constant char *string = Hi There is a C string ; NSData *data=[nsdata datawithbytes: string length: strlen (string)+1]; NSLog (@ data is %@, data); NSLog (@ %d byte string is %s, [data length], [data bytes]);

49 NSData NSString *thepath NSData *mydata = [NSData datawithcontentsoffile:thepath]; unsigned char abuffer[20]; NSString *mystring string."; const char *ukstring = [mystring UTF8String]; NSData *mydata = [NSData datawithbytes: ukstring length: strlen(ukstring)]; [mydata getbytes:abuffer]; NSString *mystring const char *ukstring = [mystring UTF8String]; NSRange range = {2, 4}; NSData *data1, *data2; data1 = [NSData datawithbytes:ukstring length:strlen(ukstring)]; data2 = [data1 subdatawithrange:range]; To determine if two data objects are equal, use the isequaltodata: method, which does a byte- for- byte comparison.

50 NSFileManger The NSFileManager class enables you to perform many generic file- system opera'ons and insulates an applica'on from the underlying file system. NSFileManager *filemanager = [NSFileManager defaultmanager]; NSURL *srcurl = <#Get the source URL#>; NSURL *des'na'onurl = <#Create the des'na'on URL#>; NSError *error = nil; if (![filemanager moveitematurl:srcurl tourl:des'na'onurl error:&error]) { // Handle the error.} File Transfer Protocol (np://) Hypertext Transfer Protocol (hbp://) Secure 128- bit Hypertext Transfer Protocol (hbps://) Local file URLs (file:///)

51 #import <Founda'on/Founda'on.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSFileManager *manager; manager = [NSFileManager defaultmanager]; NSString *filename; while (filename = [direnum nextobject]) { if ([[filename pathextension] { [files addobject: filename]; } } NSString *home; home = [@"~" stringbyexpandingtildeinpath]; NSDirectoryEnumerator *direnum; direnum = [manager enumeratoratpath: home]; NSMutableArray *files; files = [NSMutableArray arraywithcapacity: 42]; } NSEnumerator *fileenum; fileenum = [files objectenumerator]; while (filename = [fileenum nextobject]) { NSLog (@"%@", filename); } [pool drain]; return 0;

52 #import <Founda'on/Founda'on.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSFileManager *manager; manager = [NSFileManager defaultmanager]; NSString *home; home = [@"~" stringbyexpandingtildeinpath]; NSMutableArray *files; files = [NSMutableArray arraywithcapacity: 42]; for (NSString *filename in [manager enumeratoratpath: home]) { if ([[filename pathextension] { [files addobject: filename]; } } for (NSString *filename in files) { NSLog (@"%@", filename); } } [pool drain]; return 0;

53 Homework 1 Write a program to 1) discover all the different file extensions in your computer; for each extension; 2) store all the files with that extension in a set; 3) construct a dic'onary to map each extension (key) to its corresponding set of files; 4) calculate the overall file size for each extension (number of total bytes).

CS193P - Lecture 2. iphone Application Development. Objective-C Foundation Framework

CS193P - Lecture 2. iphone Application Development. Objective-C Foundation Framework CS193P - Lecture 2 iphone Application Development Objective-C Foundation Framework Announcements Enrollment process is complete! Contact cs193p@cs.stanford.edu if you are unsure of your status Please drop

More information

CS193P - Lecture 2. iphone Application Development. Objective-C Foundation Framework

CS193P - Lecture 2. iphone Application Development. Objective-C Foundation Framework CS193P - Lecture 2 iphone Application Development Objective-C Foundation Framework 1 Announcements 2 Announcements Enrollment process is almost done 2 Announcements Enrollment process is almost done 2

More information

Announcements. Today s Topics

Announcements. Today s Topics Announcements Discuss Final Project Ideas on Wednesday Final Project teams will consist of 3 4 people No teams of 1 or 2 people Extensible Networking Platform 1 1 - CSE 438 Mobile Application Development

More information

Monday, 1 November The ios System

Monday, 1 November The ios System The ios System System Overview System Overview System Overview System Overview System Overview System Overview Foundation Classes (Useful) Foundation Framework Value and collection classes User defaults

More information

Collections & Memory Management. Lecture 2

Collections & Memory Management. Lecture 2 Collections & Memory Management Lecture 2 Demo: Accessing Documentation Collections NSArray a list of objects in order [array objectatindex:0] [array objectatindex:3] Counting starts at zero, not one NSSet

More information

Collections. Fall, Prof. Massimiliano "Max" Pala

Collections. Fall, Prof. Massimiliano Max Pala Collections Fall, 2012 Prof. Massimiliano "Max" Pala pala@nyu.edu Overview Arrays Copy and Deep Copy Sets Dictionaries Examples Arrays Two Classes NSArray and NSMutableArray (subclass of NSArray) int main(int

More information

NSObject. - (NSString *)description Provides us with a string description of the object

NSObject. - (NSString *)description Provides us with a string description of the object FoundationFramework NSObject - (NSString *)description Provides us with a string description of the object NSString - (NSString *)stringbyappendingstring:(nsstring *)string Creates a new string by adding

More information

COMP327 Mobile Computing Session: Tutorial Objective-C and the Foundation Framework

COMP327 Mobile Computing Session: Tutorial Objective-C and the Foundation Framework COMP327 Mobile Computing Session: 2010-2011 Tutorial 4-5 - Objective-C and the Foundation Framework 1 In these Tutorial Slides... These slides introduce you to Objective-C, with a focus on the object-oriented

More information

Getting Help. iphone Application Programming Lecture 3: Foundation Classes. Data Structures in Objective C. Online Documentation.

Getting Help. iphone Application Programming Lecture 3: Foundation Classes. Data Structures in Objective C. Online Documentation. iphone Application Programming Lecture 3: Foundation Classes Prof. Jan Borchers Media Computing Group RWTH Aachen University Winter Semester 2013/2014 http://hci.rwth-aachen.de/iphone Online Documentation

More information

iphone Application Programming Lecture 3: Foundation Classes

iphone Application Programming Lecture 3: Foundation Classes iphone Application Programming Lecture 3: Foundation Classes Prof. Jan Borchers Media Computing Group RWTH Aachen University Winter Semester 2013/2014 http://hci.rwth-aachen.de/iphone Getting Help Online

More information

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

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Spring Stanford CS193p Spring 2011 Developing Applications for iphone 4, ipod Touch, & ipad Today Dynamic Binding Introspection Foundation Framework Enumeration More Objective-C Allocating and Initializing objects Memory Management Demo

More information

Mobile Application Development

Mobile Application Development Mobile Application Development Lecture 12 Introduction to ObjectiveC 2013/2014 Parma Università degli Studi di Parma Lecture Summary ObjectiveC language basics Classes and objects Methods Instance variables

More information

Advanced Object- C Features

Advanced Object- C Features Advanced Object- C Features Advanced Features Proper6es Categories Protocols Delegates Selectors Key- Value Coding Predicators Proper6es Provide access to object a?ributes Shortcut to implemen6ng ge?er/se?er

More information

COCOA WORKSHOP PART 1. Andreas Monitzer

COCOA WORKSHOP PART 1. Andreas Monitzer COCOA WORKSHOP PART 1 Andreas Monitzer 2009-02-17 WORKSHOP SCHEDULE 1. Introduction, Foundation 2. GUI Programming 3. Hands-On 4. Advanced 2009-02-17 2009-02-19 2009-02-24 2009-02-26 STRUCTURE Introduction

More information

CS193p Spring 2010 Thursday, April 29, 2010

CS193p Spring 2010 Thursday, April 29, 2010 CS193p Spring 2010 Announcements You should have received an e-mail by now If you received e-mail approving enrollment, but are not in Axess, do it! If you have any questions, please ask via e-mail or

More information

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

Objective-C ICT/7421ICTNathan. René Hexel. School of Information and Communication Technology Griffith University. Objective-C 2.0 2501ICT/7421ICTNathan René Hexel School of Information and Communication Technology Griffith University Semester 1, 2012 Outline Fast Enumeration and Properties 1 Fast Enumeration and Properties

More information

For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to

For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance About the Author...

More information

Developing applications for ios

Developing applications for ios Developing applications for ios Lecture 3: Objective-C in Depth Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Content More on Dot Notation Instance

More information

Abstract Data Types. 2501ICT/7421ICTNathan. René Hexel. Semester 1, School of Information and Communication Technology Griffith University

Abstract Data Types. 2501ICT/7421ICTNathan. René Hexel. Semester 1, School of Information and Communication Technology Griffith University Collections 2501ICT/7421ICTNathan School of Information and Communication Technology Griffith University Semester 1, 2012 Outline Collections 1 Collections 2 Linear Collections Collections Collections

More information

Objective-C and COCOA Applications

Objective-C and COCOA Applications Objective-C and COCOA Applications Fall, 2012 Prof. Massimiliano "Max" Pala pala@nyu.edu Overview X-Code IDE Basics Objective-C Classes Methods Invocations Important Types Memory Management Protocols Exceptions

More information

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

ios Development Lecture 1 Introduction to Objective-C Ing. Simone Cirani ios Development Lecture 1 Introduction to ObjectiveC Ing. Simone Cirani email: simone.cirani@unipr.it http://www.tlc.unipr.it/cirani Simone Cirani, Ph.D. Corso IFTS Cisita ios Development 2014 Parma Università

More information

CS193E Lecture #3 Categories and Protocols Cocoa Memory Management

CS193E Lecture #3 Categories and Protocols Cocoa Memory Management CS193E Lecture #3 Categories and Protocols Cocoa Memory Management Winter 2008, Dempsey/Marcos 1 Today s Topics Questions from Assignment 1A or 1B? Categories Protocols Cocoa Memory Management Object life

More information

Introductory ios Development

Introductory ios Development Introductory ios Development 152-164 Unit 2 - Basic Objective-C Syntax Quick Links & Text References Console Application Pages Running Console App Pages Basic Syntax Pages Variables & Types Pages Sequential

More information

Review (Basic Objective-C)

Review (Basic Objective-C) Classes Header.h (public) versus Implementation.m (private) @interface MyClass : MySuperclass... @end (only in header file) @interface MyClass()... @end (only in implementation file) @implementation...

More information

Getting Help. iphone Application Programming Lecture 3: Foundation Classes. Data Structures in Objective C. Online Documentation.

Getting Help. iphone Application Programming Lecture 3: Foundation Classes. Data Structures in Objective C. Online Documentation. iphone Application Programming Lecture 3: Foundation Classes Prof. Jan Borchers Media Computing Group RWTH Aachen University Winter Semester 2013/2014 http://hci.rwth-aachen.de/iphone Online Documentation

More information

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

Working Effectively with Objective-C on iphone OS. Blaine Garst Wizard of Runtimes Working Effectively with Objective-C on iphone OS Blaine Garst Wizard of Runtimes 2 Working Effectively with Objective-C on ios 4 Blaine Garst Wizard of Runtimes 3 Objective-C is the language of Cocoa

More information

1.The basics 5 Comments 5 Variables and basic types 6 Operators 8 Object variables 10 A note on prefixes and namespaces 11

1.The basics 5 Comments 5 Variables and basic types 6 Operators 8 Object variables 10 A note on prefixes and namespaces 11 1.The basics 5 Comments 5 Variables and basic types 6 Operators 8 Object variables 10 A note on prefixes and namespaces 11 2.Branching and decisions 12 If-else statement 12 Switch statement 13 Ternary

More information

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

Stanford CS193p. Developing Applications for ios. Spring Stanford CS193p. Spring 2012 Developing Applications for ios Foundation Framework NSObject Base class for pretty much every object in the ios SDK Implements introspection methods, etc. - (NSString *)description is a useful method

More information

ITP 342 Mobile App Development. Data Persistence

ITP 342 Mobile App Development. Data Persistence ITP 342 Mobile App Development Data Persistence Persistent Storage Want our app to save its data to persistent storage Any form of nonvolatile storage that survives a restart of the device Want a user

More information

CS 47. Beginning iphone Application Development

CS 47. Beginning iphone Application Development CS 47 Beginning iphone Application Development Introductions Who, why, which? Shameless Plug: LoudTap Wifi Access (If it works..) SSID: Stanford Username/password: csp47guest Expectations This is a programming

More information

ITP 342 Mobile App Development. Data Persistence

ITP 342 Mobile App Development. Data Persistence ITP 342 Mobile App Development Data Persistence Persistent Storage Want our app to save its data to persistent storage Any form of nonvolatile storage that survives a restart of the device Want a user

More information

NSTableView + Cocoa Bindings + Core Data + Drag & Drop. HMDT Makoto Kinoshita

NSTableView + Cocoa Bindings + Core Data + Drag & Drop. HMDT Makoto Kinoshita NSTableView + Cocoa Bindings + Core Data + Drag & Drop HMDT Makoto Kinoshita NSTableView + Cocoa Bindings binding content NSArrayController NSMutableArray NSTableView + Cocoa Bindings + Core Data binding

More information

Files & Archiving. Lecture 8

Files & Archiving. Lecture 8 Files & Archiving Lecture 8 Persistent Data NSUserDefaults Dead simple to use Just one big file Only supports property list types What if you want more features? File Tasks Finding the file path User selected

More information

Cocoa Programming. David Chisnall. March 18,

Cocoa Programming. David Chisnall. March 18, March 18, 2010 http://cs.swan.ac.uk/~csdavec/papers/safariwebcast.pdf The Story So Far What is Cocoa? Why Cocoa? GNUstep Overview GNUstep Look and Feel A Brief History of Objective-C 1980: Smalltalk-80

More information

IPHONE DEVELOPMENT. Getting Started with the iphone SDK

IPHONE DEVELOPMENT. Getting Started with the iphone SDK IPHONE DEVELOPMENT Getting Started with the iphone SDK OBJECTIVE-C The Big Picture STRICT SUPERSET OF C The Objective C Language Any C stuff applies Standard libs are here (time, sqrt etc) The C Language

More information

COSC$4355/6355$ $Introduction$to$Ubiquitous$Computing$ Exercise$3$ September!17,!2015!

COSC$4355/6355$ $Introduction$to$Ubiquitous$Computing$ Exercise$3$ September!17,!2015! COSC4355/6355 IntroductiontoUbiquitousComputing Exercise3 September17,2015 Objective Inthisexercise,youwilllearnhowtowriteunittestsforyourapplicationandalsohowtouse NSUserDefaults.WewillalsoimplementObjectiveCCcategories*welearntlastweek.

More information

Sorting. Sorting. 2501ICT/7421ICTNathan. René Hexel. School of Information and Communication Technology Griffith University.

Sorting. Sorting. 2501ICT/7421ICTNathan. René Hexel. School of Information and Communication Technology Griffith University. 2501ICT/7421ICTNathan School of Information and Communication Technology Griffith University Semester 1, 2012 Outline 1 Sort Algorithms Many Sort Algorithms Exist Simple, but inefficient Complex, but efficient

More information

Concepts in Objective-C Programming

Concepts in Objective-C Programming Concepts in Objective-C Programming Contents About the Basic Programming Concepts for Cocoa and Cocoa Touch 7 At a Glance 7 How to Use This Document 7 Prerequisites 8 See Also 8 Class Clusters 9 Without

More information

Data Management

Data Management Core Data Utility Tutorial Data Management 2010-09-19 Apple Inc. 2005, 2010 Apple Inc. All rights reserved. exclusion may not apply to you. This warranty gives you specific legal rights, and you may also

More information

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

Objective-C Runtime. Cocoa s Jewel in the Crown. NSConference Nicolas Objective-C Runtime Cocoa s Jewel in the Crown NSConference 2011 Nicolas Seriot @nst021 [isa kindof:magic] 1. Objective-C 2. Recipes 3. Introspection 4. Debugging Objective-C Runtime OO, Smalltalk-like,

More information

Objective-C and Cocoa User Guide and Reference Manual

Objective-C and Cocoa User Guide and Reference Manual Objective-C and Cocoa User Guide and Reference Manual Version 7.1 Copyright and Trademarks LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual Version 7.1 March 2017 Copyright 2017

More information

ios: Objective-C Primer

ios: Objective-C Primer ios: Objective-C Primer Jp LaFond Jp.LaFond+e76@gmail.com TF, CS76 Announcements n-puzzle feedback this week (if not already returned) ios Setup project released Android Student Choice project due Tonight

More information

ITP 342 Mobile App Dev. Data Types

ITP 342 Mobile App Dev. Data Types ITP 342 Mobile App Dev Data Types Types of Data Types C Primitives The vast majority of Objective-C s primitive data types are adopted from C, although it does define a few of its own to facilitate its

More information

Developing Applications for ios

Developing Applications for ios Developing Applications for ios Lab 2: RPN Calculator App (1 of 3) Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Task 1 Task: Create a new application

More information

App SandBox Directory

App SandBox Directory Data Persistence Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 App SandBox Directory

More information

Introductory ios Development

Introductory ios Development Instructor s Introductory ios Development Unit 3 - Objective-C Classes Introductory ios Development 152-164 Unit 3 - Swift Classes Quick Links & Text References Structs vs. Classes Structs intended for

More information

Advanced Memory Analysis with Instruments. Daniel Delwood Performance Tools Engineer

Advanced Memory Analysis with Instruments. Daniel Delwood Performance Tools Engineer Advanced Memory Analysis with Instruments Daniel Delwood Performance Tools Engineer 2 Memory Analysis What s the issue? Memory is critical to performance Limited resource Especially on iphone OS 3 4 Memory

More information

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

CS193E Lecture 7. Document-based Applications NSTableView Key-Value Coding CS193E Lecture 7 Document-based Applications NSTableView Key-Value Coding Agenda Questions? Review: delegates, MVC Document-based apps Table views Key Value Coding Model, View, Controller Controller Model

More information

OBJECTIVE-C BEST PRACTICES IN A TEAM ENVIRONMENT

OBJECTIVE-C BEST PRACTICES IN A TEAM ENVIRONMENT OBJECTIVE-C BEST PRACTICES IN A TEAM ENVIRONMENT by Rolin Nelson Presented at JaxMUG March 2013 1 GOALS Introduce / review Objective-C core features Review recent additions to Objective-C Discuss and propose

More information

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

Review. Objective-C Classes, Methods, Properties, Protocols, Delegation, Memory Management Data Persistence Review Objective-C Classes, Methods, Properties, Protocols, Delegation, Memory Management Foundation NSArray, NSDictionary, NSString (and mutable versions thereof) MVC and UIViewController

More information

Mobile Application Development

Mobile Application Development Mobile Application Development Lecture 13 Introduction to ObjectiveC Part II 2013/2014 Parma Università degli Studi di Parma Lecture Summary Object creation Memory management Automatic Reference Counting

More information

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

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011 Developing Applications for ios Today Persistence How to make things stick around between launchings of your app (besides NSUserDefaults) Persistence Property Lists Use writetourl:atomically: and initwithcontentsofurl:

More information

Assignment II: Foundation Calculator

Assignment II: Foundation Calculator Assignment II: Foundation Calculator Objective The goal of this assignment is to extend the CalculatorBrain from last week to allow inputting variables into the expression the user is typing into the calculator.

More information

O(1) objectatindex: firstobject: lastobject: addobject: removelastobject: O(log n) indexofobject:insortedrange:options:usingcomp arator:

O(1) objectatindex: firstobject: lastobject: addobject: removelastobject: O(log n) indexofobject:insortedrange:options:usingcomp arator: ios - O(n) containsobject: indexofobject* removeobject: O(1) objectatindex: firstobject: lastobject: addobject: removelastobject: O(log n) indexofobject:insortedrange:options:usingcomp arator: Dictionary

More information

Principles of Programming Languages. Objective-C. Joris Kluivers

Principles of Programming Languages. Objective-C. Joris Kluivers Principles of Programming Languages Objective-C Joris Kluivers joris.kluivers@gmail.com History... 3 NeXT... 3 Language Syntax... 4 Defining a new class... 4 Object identifiers... 5 Sending messages...

More information

C Blocks Block CPRE 388

C Blocks Block CPRE 388 C Blocks CPRE 388 C Blocks int multiplier = 7; int (^myblock)(int) = ^(int num) { return num * multiplier; li li }; Notice that the block is able to make use of variables from the same scope in which

More information

ITP 342 Advanced Mobile App Dev. Memory

ITP 342 Advanced Mobile App Dev. Memory ITP 342 Advanced Mobile App Dev Memory Memory Management Objective-C provides two methods of application memory management. 1. In the method described in this guide, referred to as manual retain-release

More information

Using Swift with Cocoa and Objective-C

Using Swift with Cocoa and Objective-C Using Swift with Cocoa and Objective-C Contents Getting Started 5 Basic Setup 6 Setting Up Your Swift Environment 6 Understanding the Swift Import Process 7 Interoperability 9 Interacting with Objective-C

More information

Code Examples. C# demo projects. PHP Rest Client

Code Examples. C# demo projects. PHP Rest Client Code Examples Developers please use https://api-stage.bimplus.net/v2 (stage version of bim+ API) and http://portal-stage.bimplus.net/ (stage version of Shop/Portal) for testing purposes. The production

More information

Building a (Core) Foundation. Rob Napier

Building a (Core) Foundation. Rob Napier Building a (Core) Foundation Rob Napier A little background Mac OS X since 10.4 iphoneos since release Cisco Jabber, The Daily, RNCryptor Focus on low-level Today: Mac developer for... KACE NAPIER KUMAR

More information

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

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011 Developing Applications for ios Today icloud Sharing documents among a user s devices Fundamentally: nothing more than a URL of a shared directory However, since it is over the network, there are lots

More information

CS193E Lecture 14. Cocoa Bindings

CS193E Lecture 14. Cocoa Bindings CS193E Lecture 14 Cocoa Bindings Agenda Questions? Personal Timeline IV Key Value Coding Key Value Observing Key Value Binding Cocoa Bindings What are Cocoa Bindings? Added in Panther, more mature in Tiger

More information

By Ryan Hodson. Foreword by Daniel Jebaraj

By Ryan Hodson. Foreword by Daniel Jebaraj 1 By Ryan Hodson Foreword by Daniel Jebaraj 2 Copyright 2012 by Syncfusion Inc. 2501 Aerial Center Parkway Suite 200 Morrisville, NC 27560 USA All rights reserved. I mportant licensing information. Please

More information

Objective-C. Stanford CS193p Fall 2013

Objective-C. Stanford CS193p Fall 2013 New language to learn! Strict superset of C Adds syntax for classes, methods, etc. A few things to think differently about (e.g. properties, dynamic binding) Most important concept to understand today:

More information

This reference will take you through simple and practical approach while learning Objective-C Programming language.

This reference will take you through simple and practical approach while learning Objective-C Programming language. About the Tutorial Objective-C is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. This is the main programming language used by

More information

ITP 342 Mobile App Dev. Fundamentals

ITP 342 Mobile App Dev. Fundamentals ITP 342 Mobile App Dev Fundamentals Objective-C Classes Encapsulate data with the methods that operate on that data An object is a runtime instance of a class Contains its own in-memory copy of the instance

More information

Mobile Application Programming. Memory Management

Mobile Application Programming. Memory Management Mobile Application Programming Memory Management Memory Management Ownership Model Memory Management in Objective-C is based on an ownership model. Objects may have many owners. Actions that result in

More information

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

Intro to Native ios Development. Dave Koziol Arbormoon Software, Inc. Intro to Native ios Development Dave Koziol Arbormoon Software, Inc. About Me Long time Apple Developer (20 WWDCs) Organizer Ann Arbor CocoaHeads President & ios Developer at Arbormoon Software Inc. Wunder

More information

Proofreader Charlotte Kughen Publishing Coordinator Vanessa Evans

Proofreader Charlotte Kughen Publishing Coordinator Vanessa Evans Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark

More information

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

Review. iphone Application Programming Lecture 2: Objective-C, Cocoa. History. Objective-C. Device restrictions. Interaction paradigm changes Review iphone Application Programming Lecture 2: Objective-C, Cocoa Device restrictions Gero Herkenrath Media Computing Group RWTH Aachen University Winter Semester 2013/2014 http://hci.rwth-aachen.de/iphone

More information

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

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010 Developing Applications for iphone 4, ipod Touch, & ipad Today More Core Data What does the code for the custom NSManagedObject subclasses generated by Xcode look like? Querying for (fetching) objects

More information

Objective-C. CS 442: Mobile App Development Michael Saelee

Objective-C. CS 442: Mobile App Development Michael Saelee Objective-C CS 442: Mobile App Development Michael Saelee 1 Agenda - ObjC overview - ObjC object-oriented syn/sem - Memory management - Declared properties - Blocks 2 Overview 3 ObjC = proper

More information

Data Storage. Dr. Sarah Abraham

Data Storage. Dr. Sarah Abraham Data Storage Dr. Sarah Abraham University of Texas at Austin CS329e Fall 2016 Model Layer of MVC Contains the data to be displayed Data can be: Stored on device Pulled down from a server Data displayed

More information

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

CS193P - Lecture 3. iphone Application Development. Custom Classes Object Lifecycle Autorelease Properties CS193P - Lecture 3 iphone Application Development Custom Classes Object Lifecycle Autorelease Properties 1 Announcements Assignments 1A and 1B due Wednesday 1/13 at 11:59 PM Enrolled Stanford students

More information

AVAudioPlayer. avtouch Application

AVAudioPlayer. avtouch Application AVAudioPlayer avtouch Application iphone Application Index 1. iphone Application 1) iphone Application 2) iphone Application Main Method 3) iphone Application nib(.xib) 2. avtouch Application 1) avtouch

More information

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

Review. iphone Application Programming Lecture 2: Objective-C, Cocoa. History. Objective-C. Device restrictions. Interaction paradigm changes Review iphone Application Programming Lecture 2: Objective-C, Cocoa Device restrictions Gero Herkenrath Media Computing Group RWTH Aachen University Winter Semester 2013/2014 http://hci.rwth-aachen.de/iphone

More information

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

Design Phase. Create a class Person. Determine the superclass. NSObject (in this case) Design Phase Create a class Person Determine the superclass NSObject (in this case) 8 Design Phase Create a class Person Determine the superclass NSObject (in this case) What properties should it have?

More information

Agenda. Core Data! Next Week! Storing your Model permanently in an object-oriented database.! Multitasking! Advanced Segueing! Map Kit?

Agenda. Core Data! Next Week! Storing your Model permanently in an object-oriented database.! Multitasking! Advanced Segueing! Map Kit? ios Mobile Design Agenda Core Data! Storing your Model permanently in an object-oriented database.! Next Week! Multitasking! Advanced Segueing! Map Kit? Core Data Database! Sometimes you need to store

More information

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

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010 Developing Applications for iphone 4, ipod Touch, & ipad Today Blocks Language syntax for declaring a function on the fly. Grand Central Dispatch C API for leveraging blocks to make writing multithreaded

More information

A little more Core Data

A little more Core Data A little more Core Data A little more Core Data NSFetchedResultsController Interacts with the Core Data database on your behalf [fetchedresultscontroller objectatindexpath:] gets at row data [fetchedresultscontroller

More information

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

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011 Developing Applications for ios Today Core Data and Documents This is how you store something serious in ios Easy entreé into icloud NSNotificationCenter The little radio station we talked about in the

More information

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

Stanford CS193p. Developing Applications for ios Fall Stanford CS193p. Fall 2013 Developing Applications for ios -14 Today What is this class all about? Description Prerequisites Homework / Final Project ios Overview What s in ios? MVC Object-Oriented Design Concept Objective C (Time

More information

CS193E Lecture 12. Formatters Cocoa Text More View Drawing

CS193E Lecture 12. Formatters Cocoa Text More View Drawing CS193E Lecture 12 Formatters Cocoa Text More View Drawing Quick Scroll View Demo Announcements Questions on previous material or assignment? If you don t get a grade by Sunday, please let us know Some

More information

An Introduction to Smalltalk for Objective-C Programmers

An Introduction to Smalltalk for Objective-C Programmers An Introduction to Smalltalk for Objective-C Programmers O Reilly Mac OS X Conference October 25 28, 2004 Philippe Mougin - pmougin@acm.org http://www.fscript.org IT Management & Consulting What you will

More information

Announcement. Final Project Proposal Presentations and Updates

Announcement. Final Project Proposal Presentations and Updates Announcement Start Final Project Pitches on Wednesday Presentation slides dues by Tuesday at 11:59 PM Email slides to cse438ta@gmail.com Extensible Networking Platform 1 1 - CSE 438 Mobile Application

More information

Announcements. Today s Topics

Announcements. Today s Topics Announcements We will discuss final project ideas on Monday Three guest presenters coming to class Lab 5 is due on Wednesday Nov 4 th 1 Extensible - CSE 436 Software Networking Engineering Platform Workshop

More information

Objective-C. Deck.m. Deck.h. Let s look at another class. This one represents a deck of cards. #import <Foundation/Foundation.h> #import "Deck.

Objective-C. Deck.m. Deck.h. Let s look at another class. This one represents a deck of cards. #import <Foundation/Foundation.h> #import Deck. Deck.h #import @interface Deck : NSObject @interface Deck() @implementation Deck Deck.m Let s look at another class. This one represents a deck of cards. Deck.h #import

More information

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

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015 Stanford CS193p Developing Applications for ios Today Objective-C Compatibility Bridging Property List NSUserDefaults Demo: var program in CalculatorBrain Views Custom Drawing Demo FaceView Bridging Objective-C

More information

Object-Oriented Programming with Objective-C. Lecture 2

Object-Oriented Programming with Objective-C. Lecture 2 Object-Oriented Programming with Objective-C Lecture 2 Objective-C A Little History Originally designed in the 1980s as a fusion of Smalltalk and C Popularized by NeXTSTEP in 1988 (hence the ubiquitous

More information

Developing Applications for ios

Developing Applications for ios Developing Applications for ios Lecture 10: and Categories Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Content and Documents This is how you

More information

Data Management: Data Types & Collections

Data Management: Data Types & Collections Property List Programming Guide Data Management: Data Types & Collections 2010-03-24 Apple Inc. 2010 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval

More information

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

Objective-C Primer. iphone Programmer s Association. Lorenzo Swank September 10, 2008 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

More information

Bhumi: A simple, extensible, agent-based-modeling framework

Bhumi: A simple, extensible, agent-based-modeling framework Bhumi: A simple, extensible, agent-based-modeling framework Vivin Suresh Paliath Arizona State University vivin.paliath@asu.edu Abstract Agent-based models belong to a class of computational models and

More information

Praktikum Entwicklung von Mediensystemen mit ios

Praktikum Entwicklung von Mediensystemen mit ios Praktikum Entwicklung von Mediensystemen mit ios WS 2011 Prof. Dr. Michael Rohs michael.rohs@ifi.lmu.de MHCI Lab, LMU München Today Saving data Networking Location Sensors Exercise 2 2 Timeline # Date

More information

ITP 342 Advanced Mobile App Dev. Core Data

ITP 342 Advanced Mobile App Dev. Core Data ITP 342 Advanced Mobile App Dev Core Data Persistent Data NSUser Defaults Typically used to save app preferences Property List (plist) in Documents Directory Data is in a dictionary or an array Coders

More information

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

OVERVIEW. Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net 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

More information

Praktikum Entwicklung von Mediensystemen mit ios

Praktikum Entwicklung von Mediensystemen mit ios Praktikum Entwicklung von Mediensystemen mit ios SS 2011 Michael Rohs michael.rohs@ifi.lmu.de MHCI Lab, LMU München Milestones 26.5. Project definition, brainstorming, main functions, persona 9.6. (week

More information

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

Stanford CS193p. Developing Applications for ios. Spring Stanford CS193p. Spring 2012 Developing Applications for ios Today Blocks Objective-C language feature for in-lining blocks of code Foundation of multi-threaded support (GCD) What is a block? A block of code (i.e. a sequence of statements

More information

Mobile Application Programming. Objective-C Classes

Mobile Application Programming. Objective-C Classes Mobile Application Programming Objective-C Classes Custom Classes @interface Car : NSObject #import Car.h + (int) viper; - (id) initwithmodel:(int)m; @implementation Car Point position; float velocity;

More information

SQLitePersistentObjects

SQLitePersistentObjects SQLite Without the SQL Jeff LaMarche And that is spelled with an A contrary to the sign out front. Contacting Me jeff_lamarche@mac.com http://iphonedevelopment.blogspot.com Twitter: jeff_lamarche A lot

More information