Advanced Object- C Features
|
|
- Maximillian Hodge
- 6 years ago
- Views:
Transcription
1 Advanced Object- C Features
2 Advanced Features Proper6es Categories Protocols Delegates Selectors Key- Value Coding Predicators
3 Proper6es Provide access to object a?ributes Shortcut to implemen6ng ge?er/se?er methods Also allow you to specify: read- only versus read- write access memory management policy
4 Defining Proper6es #import Person : NSObject { // instance variables NSString *name; int age; // method declara6ons - (NSString *) name; (void)setname:(nsstring *)value; - // (int) property age; declara6ons (void)setage:(int)age; int (BOOL) canlegallyvot; (copy) NSString * (readonly) BOOL canlegallyvot; -
5 Synthesizing Person - (int)age return age; name; - - (BOOL)canLegallyVote (void)setage:(int)value { age return = value; (age > 17); - (NSString *)name { return - (void)setname:(nsstring *)value { if (value!= name) { [name release]; name = [value copy]; - (void)canlegallyvote {...
6 Property A?ributes Read- only versus read- int age; // read- write by (readonly) BOOL canlegallyvote; Memory management policies (only for object (assign) NSString *name; // pointer (retain) NSString *name; // retain (copy) NSString *name; // copy called
7 (nonatomic, copy) NSString *string; the synthesized se?er method is similar to the following: - (void)setstring:(nsstring *)newstring { if (string!= newstring) { [string release]; string = [newstring copy];
8 Releasing Proper6es Do you have to release a property? By using the retain (copy) se?er seman6c se`ng in statement you're asking the compiler to build a se?er that calls retain on the object (or copy a new one) Since you are retaining that object (even though it's via magically auto- generated code), you have to release it! Where to release? in - (void)dealloc.
9 #import X : X - (void)release { NSLog(@"Releasing %p, next count = %d", self, [self retaincount]- 1); [super release]; - (id)retain { NSLog(@"Retaining %p, next count = %d", self, [self retaincount]+1); return [super retain]; - (void)dealloc { NSLog(@"Dealloc %p", self); Y : NSObject { X* (nonatomic, retain) x; - (void)dealloc { [x release]; [super int main () { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; Y* y = [[Y alloc] init]; X* x = [[X alloc] init]; y.x = x; [y release]; [x release]; [pool drain]; return 0;
10 Atomicity This a?ribute specifies that accessor methods are not atomic. (There is no keyword to denote atomic.) Nonatomic Specifies that accessors are non- atomic. By default, accessors are atomic. Without nonatomic, then in a reference counted environment a synthesized get accessor for an object property uses a lock and retains and autoreleases the returned value: [_internal lock]; // lock using an object- level lock id result = [[value retain] autorelease]; [_internal unlock]; return result; With nonatomic, then a synthesized accessor for an object property simply returns the value directly.
11 Property Names vs. Instance Variables Property name can be different than instance Person : NSObject { int age = Whether or not you specify the name of the instance can only use an instance variable from the current class, not a superclass.
12 Proper6es Mix and match synthesized and implemented name; - (void)setage:(int)value { age = value; // now do something with the new age Se?er method explicitly implemented Ge?er method s6ll synthesized
13 @interface MyClass : NSObject { NSMutableArray (nonatomic, copy) myarray; - (void)setmyarray:(nsmutablearray *)newarray { if (myarray!= newarray) [myarray release]; myarray = [newarray mutablecopy];
14 Proper6es In Prac6ce Newer APIs Older APIs use ge?er/se?er methods Proper6es used heavily throughout UIKit APIs Not so much with Founda6on APIs Objec6ve- C 2.0 features only used on Mac OS X 10.5 (Leopard) or later You can use either approach Proper6es mean wri6ng less code, but magic can some6mes be non- obvious
15 Dot Syntax and self When used in custom methods, be careful with dot syntax for proper6es defined in your class References to proper6es and ivars behave very Person : NSObject { NSString (copy) Person - (void)dosomething { name Fred ; // accesses ivar directly! self.name Fred ; // calls accessor method
16 Common Pisall with Dot Syntax What will happen when this code Person - (void)setage:(int)newage { self.age = This is equivalent Person - (void)setage:(int)newage { [self setage:newage]; // Infinite
17 Further Reading Objec6ve- C 2.0 Programming Language Defining a Class Declared Proper6es Memory Management Programming Guide for Cocoa
18 Categories A category allows you to add methods to an exis6ng class even to one to which you do not have the source. This is a powerful feature that allows you to extend the func6onality of exis6ng classes without subclassing. Using categories, you can also split the implementa6on of your own classes between several files.
19 A Category Example Considering you are wri6ng a crossword puzzle program that takes a series of string, determines the length of each string, and put those lengths into an NSArray or NSDic6onary. You will need to wrap each length in an NSNumber object before adding it into the NSArray or NSDic6onary. NSNumber *number; number = [NSNumber numberwithunsignedint: [string length]];
20 @interface NSString (NumberConvenience) - (NSNumber *) // NSString (NumberConvenience) - (NSNumber *) lengthasnumber { unsigned int length = [self length]; return ([NSNumber numberwithunsignedint: length]); // // NumberConvenience int main (int argc, const char *argv[]) { NSAutoreleasePool *pool; pool = [[NSAutoreleasePool alloc] init]; NSMutableDic6onary *dict; dict = [NSMutableDic6onary dic6onary]; [dict setobject: [@"hello" lengthasnumber] [dict setobject: [@"ilikefish" lengthasnumber] [dict setobject: [@"Once upon a 6me" lengthasnumber] upon a 6me"]; NSLog (@"%@", dict); [pool release]; return (0); // main
21 Basic Rules for Categories You can t add new instance variables to a class When name collide (your category name is the same as the an exis6ng methods), the category wins. Category methods can do anything that methods defined in the class proper can do. At run6me, there s no difference. The methods the category adds to the class are inherited by all the class s subclasses, just like other methods.
22 Usage of Categories To extend classes defined by other implementors. As an alterna6ve to a subclass. To distribute the implementa6on of a new class into separate source NSWindow: NSWindow NSWindow(NSToolbarSupport) To declare informal protocols.
23 Protocols Protocols declare methods that can be implemented by any class. Protocols are useful in at least three situa6ons: To declare methods that others are expected to implement To declare the interface to an object while concealing its class To capture similari6es among classes that are not hierarchically related
24 Protocol Examples For example, the following methods that report user ac6ons on the mouse could be gathered into a protocol: - (void)mousedown:(nsevent *)theevent; - (void)mousedragged:(nsevent *)theevent; - (void)mouseup:(nsevent *)theevent; Any class that wanted to respond to mouse events could adopt the protocol and implement its methods.
25 Protocols and Subclass/Categories Class and category interfaces declare methods that are associated with a par6cular class mainly methods that the class implements. Informal and formal protocols, on the other hand, declare methods that are independent of any specific class, but which any class, and perhaps many classes, might implement. A protocol is simply a list of method declara6ons, una?ached to a class defini6on. Objects can be grouped into types not just on the basis of similari6es due to the fact that they inherit from the same class, but also on the basis of their similarity in conforming to the same protocol.
26 Formal Protocols Declaring NSCoding - (void) encodewithcoder: (NSCoder *) acoder; - (void) initwithcoder: (NSCoder *) Adop6ng Car: NSObject<NSCoding> { //
27 Op2onal Protocol You can to par66on your protocol into sec6ons as you see fit. If you do not specify any keyword, the MyProtocol (void)anop6onalmethod; (void)anotherrequiredmethod;
28 Protocol Objects Like class objects, Protocol objects are created automa6cally from the defini6ons and declara6ons found in source code and are used by the run6me system. They re not allocated and ini6alized in program source code. Source code can refer to a Protocol object using direc6ve: Protocol *myxmlsupportprotocol Protocols that are declared but not used (except for type checking as described below) aren t represented by Protocol objects at run6me.
29 Conforming to a Protocol A class is said to conform to a formal protocol if it adopts the protocol or inherits from another class that adopts it. It s possible to check whether an object conforms to a protocol by sending it a conformstoprotocol: message. if (! [receiver conformstoprotocol:@protocol(myxmlsupport)] ) { // Object does not conform to MyXMLSupport protocol // If you are expec6ng receiver to implement methods declared in the // MyXMLSupport protocol, this is probably an error
30 Informal Protocols You can define an informal protocol by grouping the methods in a category NSObject ( MyXMLSupport ) - initfromxmlrepresenta6on:(nsxmlelement *)XMLElement; - (NSXMLElement Informal protocols are typically declared as categories of the NSObject class, since that broadly associates the method names with any class that inherits from NSObject. Because all classes inherit from the root class, the methods aren t restricted to any part of the inheritance hierarchy
31 Informal Protocols Being informal, protocols declared in categories don t receive much language support. There s no type checking at compile 6me nor a check at run6me to see whether an object conforms to the protocol. To get these benefits, you must use a formal protocol. An informal protocol may be useful when all the methods are op6onal, such as for a delegate, but (on Mac OS X v10.5 and later) it is typically be?er to use a formal protocol with op6onal methods.
32 Delega6on Design Pa?ern The delega6on is a commonly used pa?ern in object- oriented programming. It is a situa6on where an object, instead of performing a tasks itself, delegates that task to another, helper object. The helper object is called the delegate. The delega6ng object keeps a reference to the other object the delegate and at the appropriate 6me sends a message to it. The message informs the delegate of an event that the delega6ng object is about to handle or has just handled. The delegate may respond to the message by upda6ng the appearance or state of itself or other objects in the applica6on, and in some cases it can return a value that affects how an impending event is handled.
33 Delegate in Cocoa The delega6ng object is typically a framework object, and the delegate is typically a custom controller object. The delega6ng object holds a weak reference to its delegate. NSApplica6on asks its delegate if it should open an Un5tled window when the applica6on launches NSWindow objects ask their delegates if they should allow a window to be closed
34 Delegate Example For example, suppose you have an NSWindow. And you'd like to implement its delegate's windowdidmove: MyClass - (void)windowdidmove:(nsno6fica6on*) no6fica6on { Then you could create an instance of MyClass and assign it as the window's delegate: MyClass *mydelegate = [[MyClass alloc] init]; [window setdelegate: mydelegate]; On the NSWindow side, it probably has code similar to this to see if the delegate responds to the windowdidmove: message using respondstoselector: and send it if appropriate. if([[self delegate] respondstoselector:@selector (windowdidmove:)]) { [[self delegate] windowdidmove:no6fica6on]; h?p://stackoverflow.com/ques6ons/626898/how- do- i- create- delegates- in- objec6ve- c
35 (In)Formal Protocol for NSObject(NSWindowNo6fica6ons) - (void)windowdidmove:(nsno6fica6on *)no6fica6on; //... other - (void)windowdidmove:(nsno6fica6on *)no6fica6on; //... other MyDelegate < NSWindowNo6fica6ons >
36 Selectors SEL sel NSString *lower = (([str NSLog (@"Responds to lowercasestring: %@", lower); if ([str respondstoselector:sel]) //(lower NSLog(@"lowercaseString is: %@", [str lowercasestring]);
37 Selectors In Objec6ve- C, selector has two meanings. It can be used to refer simply to the name of a method when it s used in a source- code message to an object. It also, though, refers to the unique iden6fier that replaces the name when the source code is compiled. Compiled selectors are of type SEL. All methods with the same name have the same selector. You can use a selector to invoke a method on an object this provides the basis for the implementa6on of the target- ac6on design pa?ern in Cocoa.
38 Methods and direc6ve lets you refer to the compiled selector SEL setwidthheight; setwidthheight Convert a character string to a selector at run6me: setwidthheight = NSSelectorFromString(aBuffer); Conversion in the opposite direc6on: NSString *method; method = NSStringFromSelector(setWidthHeight);
39 Key- Value Coding Key- value coding is a mechanism for accessing an object s proper6es indirectly, using strings to iden6fy proper6es, rather than through invoca6on of an accessor method or accessing them directly through instance variables. In essence, key- value coding defines the pa?erns and method signatures that your applica6on s accessor methods implement.
40 Predicate Basics A predicate is a logical operator that returns a Boolean value (true or false). comparison predicate compound predicate Cocoa supports a wide range of types of predicate, including the following: Simple comparisons, such as grade == 7 or firstname like 'Mark' Case or diacri6c insensi6ve lookups, such as name contains[cd] 'citroen' Logical opera6ons, such as (firstname beginswith 'M') AND (lastname like 'Adderley')
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 informationCS193P - 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 informationAnnouncement. 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 informationMobile 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 informationReview. 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 informationCS193E 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 informationCollections & 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 informationCS 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 informationObjective-C Part 2 (ECS189H) Ken Joy Serban Porumbescu
Objective-C Part 2 (ECS189H) Ken Joy joy@cs.ucdavis.edu Serban Porumbescu porumbes@cs.ucdavis.edu Today Objective-C Memory Management Properties Categories and Protocols Delegates Objective-C Memory Management
More informationReview. 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 informationIPHONE 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 informationITP 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 informationITP 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 informationReview (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 informationObjective-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 informationCS193p 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 informationMobile 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 informationObjective-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 informationios 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 informationCOMP327 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 informationIntroductory 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 informationObjective-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 informationiphone OS Overview
Founda'on Framework iphone OS Overview iphone OS Overview iphone OS Overview iphone OS Overview iphone OS Overview iphone OS Overview iphone Development Environment Cocoa in the architecture of ios Cocoa
More informationAnnouncements. 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 informationMobile 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 informationCOCOA 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 informationObject Oriented Programming. Feb 2015
Object Oriented Programming Feb 2015 Tradi7onally, a program has been seen as a recipe a set of instruc7ons that you follow from start to finish in order to complete a task. That approach is some7mes known
More informationQuestions. 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?
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? Grading: Lab/homework: 40%, project: 40%, individual report:
More informationObject-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 informationCS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++
CS101: Fundamentals of Computer Programming Dr. Tejada stejada@usc.edu www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++ 10 Stacks of Coins You have 10 stacks with 10 coins each that look and feel
More informationios: 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 informationWorking 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 informationObjective-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 informationGarbage collec,on Parameter passing in Java. Sept 21, 2016 Sprenkle - CSCI Assignment 2 Review. public Assign2(int par) { onevar = par; }
Objec,ves Inheritance Ø Overriding methods Garbage collec,on Parameter passing in Java Sept 21, 2016 Sprenkle - CSCI209 1 Assignment 2 Review private int onevar; public Assign2(int par) { onevar = par;
More informationCollections. 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 informationEncapsula)on, cont d. Polymorphism, Inheritance part 1. COMP 401, Spring 2015 Lecture 7 1/29/2015
Encapsula)on, cont d. Polymorphism, Inheritance part 1 COMP 401, Spring 2015 Lecture 7 1/29/2015 Encapsula)on In Prac)ce Part 2: Separate Exposed Behavior Define an interface for all exposed behavior In
More informationMobile Application Development
Object Lifecycle Mobile Application Development Creating objects Memory management Destroying objects Basic ios Development 11-Nov-11 Mobile App Development 1 11/11/11 2 Object Creation Two step process
More informationCS193E 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 informationCSE Compilers. Reminders/ Announcements. Lecture 15: Seman9c Analysis, Part III Michael Ringenburg Winter 2013
CSE 401 - Compilers Lecture 15: Seman9c Analysis, Part III Michael Ringenburg Winter 2013 Winter 2013 UW CSE 401 (Michael Ringenburg) Reminders/ Announcements Project Part 2 due Wednesday Midterm Friday
More informationAgenda. Excep,ons Object oriented Python Library demo: xml rpc
Agenda Excep,ons Object oriented Python Library demo: xml rpc Resources h?p://docs.python.org/tutorial/errors.html h?p://docs.python.org/tutorial/classes.html h?p://docs.python.org/library/xmlrpclib.html
More informationStanford 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 informationCocoa 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 informationIntro 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 informationOVERVIEW. 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 informationPrinciples 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 informationRelated Course Objec6ves
Syntax 9/18/17 1 Related Course Objec6ves Develop grammars and parsers of programming languages 9/18/17 2 Syntax And Seman6cs Programming language syntax: how programs look, their form and structure Syntax
More informationMobile Computing. Overview. What is ios? 8/26/12. CSE 40814/60814 Fall 2012
Mobile Computing CSE 40814/60814 Fall 2012 Overview ios is the opera8ng system that runs iphones, ipod Touches, ipads, and Apple TVs. The language used to develop sogware for ios is Objec8ve- C (very similar
More informationCS193P - 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 informationsrc7-malan/c/array/array/main.c // main.c // Array // David J. Malan // Harvard University // // Demonstrates arrays. 11.
src7-malan/c/array/array/main.c 1 1 1 1 2 2 2 2 2 2 2 2 2 30. 3 3 3 main.c Array David J. Malan Harvard University malan@harvard.edu Demonstrates arrays. #include int main(int argc, const char
More informationObjective-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 informationLecture 10: Potpourri: Enum / struct / union Advanced Unix #include function pointers
....... \ \ \ / / / / \ \ \ \ / \ / \ \ \ V /,----' / ^ \ \.--..--. / ^ \ `--- ----` / ^ \. ` > < / /_\ \. ` / /_\ \ / /_\ \ `--' \ /. \ `----. / \ \ '--' '--' / \ / \ \ / \ / / \ \ (_ ) \ (_ ) / / \ \
More informationFunc%ons. CS449 Fall 2017
Func%ons CS449 Fall 2017 1 Func%ons in C A group of statements performing a task Statements inside func%on is executed by calling it using the () operator Uses: Readability (through code modulariza%on)
More informationboolean add(e e); // Makes the collection contain e. // Returns true if e not already there.
1 1. (a) The Java collections classes includes the generic interface Collection for collections with element type E, which the collection classes implement. This includes the following method: boolean
More informationOBJECTIVE-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 informationITP 342 Mobile App Dev. Fundamentals
ITP 342 Mobile App Dev Fundamentals Object-oriented Programming Object-oriented programming (OOP) is a programming paradigm based on the concept of objects. Classes A class can have attributes & actions
More informationChapter 10 INHERITANCE 11/7/16 1
Chapter 10 INHERITANCE 11/7/16 1 Chapter Goals To learn about inheritance To implement subclasses that inherit and override superclass methods To understand the concept of polymorphism In this chapter,
More informationBindings Example Exercise James Dempsey - WWDC Pre-Show Cocoa Workshop
Bindings Example Exercise James Dempsey - WWDC Pre-Show Cocoa Workshop In this exercise you will create a basic document-based application using Cocoa Bindings. This application will allow the user to
More informationCS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 8: Abstract Data Types
CS101: Fundamentals of Computer Programming Dr. Tejada stejada@usc.edu www-bcf.usc.edu/~stejada Week 8: Abstract Data Types Object- Oriented Programming Model the applica6on/so9ware as a set of objects
More informationC++ Important Questions with Answers
1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children
More informationStanford 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 informationEncapsula)on CMSC 202
Encapsula)on CMSC 202 Types of Programmers Class creators Those developing new classes Want to build classes that expose the minimum interface necessary for the client program and hide everything else
More informationCS 371L - Mobile Computing (ios) Dr. William C. Bulko. CS 371L Mobile Computing (ios) Introduction
CS 371L - Mobile Computing (ios) Dr. William C. Bulko CS 371L Mobile Computing (ios) Introduction 2014 The Evolution of Computing Mainframes Minicomputers - fridge-size PCs - desktop and deskside Laptops
More informationDesign Pa*erns. + Anima/on Undo/Redo Graphics and Hints
Design Pa*erns + Anima/on Undo/Redo Graphics and Hints Design Pa*erns Design: the planning that lays the basis for the making of every object or system Pa*ern: a type of theme of recurring events or objects
More informationPointers, Dynamic Data, and Reference Types
Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple
More informationITP 342 Mobile App Dev. Unit Testing
ITP 342 Mobile App Dev Unit Testing Testing Xcode provides you with capabilities for extensive software testing. Testing your projects enhances robustness, reduces bugs, and speeds the acceptance of your
More informationChapter 6 Introduction to Defining Classes
Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of
More informationPraktikum 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 informationSubclassing, con.nued Method overriding, virtual methods, abstract classes/methods. COMP 401, Spring 2015 Lecture 9 2/19/2015
Subclassing, con.nued Method overriding, virtual methods, abstract classes/methods COMP 401, Spring 2015 Lecture 9 2/19/2015 Subclassing So Far A subclass inherits implementa.on details from its superclass
More informationObject-Oriented Programming, Iouliia Skliarova
Object-Oriented Programming, Iouliia Skliarova CBook a = CBook("C++", 2014); CBook b = CBook("Physics", 1960); a.display(); b.display(); void CBook::Display() cout
More informationITP 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 informationMemory Management. CS449 Fall 2017
Memory Management CS449 Fall 2017 Life9mes Life9me: 9me from which a par9cular memory loca9on is allocated un9l it is deallocated Three types of life9mes Automa9c (within a scope) Sta9c (dura9on of program)
More informationCMPS 20 Game Design Experience
CMPS 20 Game Design Experience Winter 2013 Week 4/5: Design Patterns Computational Cinematics Studio // Center for Games and Playable Media http://games.soe.ucsc.edu/ccs // http://games.soe.ucsc.edu Arnav
More informationFor 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 informationObjec+ves. Review. Basics of Java Syntax Java fundamentals. What are quali+es of good sooware? What is Java? How do you compile a Java program?
Objec+ves Basics of Java Syntax Java fundamentals Ø Primi+ve data types Ø Sta+c typing Ø Arithme+c operators Ø Rela+onal operators 1 Review What are quali+es of good sooware? What is Java? Ø Benefits to
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 21 October 21 st, 2015 Transi@on to Java Announcements HW5: GUI & Paint Due Tomorrow, October 22 nd at 11:59pm HW6: Java Programming (Pennstagram)
More informationAgenda. Address vs. Value Consider memory to be a single huge array. Review. Pointer Syntax. Pointers 9/9/12
Agenda CS 61C: Great Ideas in Computer Architecture Introduc;on to C, Part II Instructors: Krste Asanovic Randy H. Katz hep://inst.eecs.berkeley.edu/~cs61c/f12 Review Pointers Administrivia Arrays Technology
More informationLesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014
Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class
More informationCS193P - 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 informationDeveloping 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 informationCOSC 121: Computer Programming II. Dr. Bowen Hui University of Bri?sh Columbia Okanagan
COSC 121: Computer Programming II Dr. Bowen Hui University of Bri?sh Columbia Okanagan 1 A1 Posted over the weekend Two ques?ons (s?ll long ques?ons) Review of main concepts from COSC 111 Prac?ce coding
More informationArchitecture of so-ware systems
Architecture of so-ware systems Lecture 13: Class/object ini
More informationAbout MSDOSX. Lecture 0
About MSDOSX Lecture 0 Goal: make an app of your own design for the Mac or iphone The Plan Lectures + Labs for several weeks Project proposals (about halfway through the semester) Work on project Present
More informationResearch opportuni/es with me
Research opportuni/es with me Independent study for credit - Build PL tools (parsers, editors) e.g., JDial - Build educa/on tools (e.g., Automata Tutor) - Automata theory problems e.g., AutomatArk - Research
More informationsrc2/section2.0/section2/main.m // main.m // Students7 // David J. Malan // Harvard University // // Demonstrates mutable arrays.
src2/section0/section2/main.m 1 1 1 1 2 2 2 2 2 2 2 2 2 30. 3 3 3 3 3 3 3 3 3 40. 4 4 4 4 main.m Students7 David J. Malan Harvard University malan@harvard.edu Demonstrates mutable arrays. #import
More informationMo#va#ng the OO Way. COMP 401, Fall 2017 Lecture 05
Mo#va#ng the OO Way COMP 401, Fall 2017 Lecture 05 Arrays Finishing up from last #me Mul#dimensional Arrays Mul#dimensional array is simply an array of arrays Fill out dimensions lef to right. int[][]
More informationPrinciples of Programming Languages
Principles of Programming Languages h"p://www.di.unipi.it/~andrea/dida2ca/plp- 14/ Prof. Andrea Corradini Department of Computer Science, Pisa Lesson 18! Bootstrapping Names in programming languages Binding
More informationData 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 information02 Features of C#, Part 1. Jerry Nixon Microsoft Developer Evangelist Daren May President & Co-founder, Crank211
02 Features of C#, Part 1 Jerry Nixon Microsoft Developer Evangelist Daren May President & Co-founder, Crank211 Module Overview Constructing Complex Types Object Interfaces and Inheritance Generics Constructing
More information1.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 informationChapter 11. Abstract Data Types and Encapsulation Concepts ISBN
Chapter 11 Abstract Data Types and Encapsulation Concepts ISBN 0-321-49362-1 Chapter 11 Topics The Concept of Abstraction Introduction to Data Abstraction Design Issues for Abstract Data Types Language
More informationA 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 informationGetting 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 informationVectors and Pointers CS 16: Solving Problems with Computers I Lecture #13
Vectors and Pointers CS 16: Solving Problems with Computers I Lecture #13 Ziad Matni Dept. of Computer Science, UCSB Announcements Midterm grades will be available on Tuesday, 11/21 If you *need* to know
More informationAuthor Bob Ippolito Conference. PyObjC Hacking. PyCon DC, March 2005
Author Bob Ippolito Conference PyObjC Hacking PyCon DC, March 2005 Intended Audience Python developers using Mac OS X 10.3 or later... that aren't (very) afraid of C Who probably know a little about Objective-C...
More informationAnnouncements. Today s Topics
Announcements Lab 2 is due tonight Lab 3 is posted Due next Wednesday Sept 30 th 1 Extensible - CSE 436 Software Networking Engineering Platform Workshop 1 Today s Topics Designing iphone Applica;ons Model-
More informationMethods. Methods. Mysteries Revealed
Methods Methods and Data (Savitch, Chapter 5) TOPICS Invoking Methods Return Values Local Variables Method Parameters Public versus Private A method (a.k.a. func2on, procedure, rou2ne) is a piece of code
More informationiphone 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 informationCSE Opera,ng System Principles
CSE 30341 Opera,ng System Principles Lecture 5 Processes / Threads Recap Processes What is a process? What is in a process control bloc? Contrast stac, heap, data, text. What are process states? Which
More informationIPHONE. Development Jump Start. phil nash levelofindirection.com
IPHONE Development Jump Start phil nash levelofindirection.com Who? been in a professional developer for the last 18 years - mostly windows - c++, c#, Java, Python etc - then, Aug 2008, decided to write
More informationCSE Opera,ng System Principles
CSE 30341 Opera,ng System Principles Synchroniza2on Overview Background The Cri,cal-Sec,on Problem Peterson s Solu,on Synchroniza,on Hardware Mutex Locks Semaphores Classic Problems of Synchroniza,on Monitors
More information