Mobile Application Development
|
|
- Denis Harvey
- 6 years ago
- Views:
Transcription
1 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 allocate memory to store the object initialize object state + alloc Class method that knows how much memory is needed - init Instance method to set initial values, perform other setup Create = Allocate + Initialize Person *person = nil; person = [[Person alloc] init]; 11/11/11 3 Implementing Your own -init Method #import 2id)init{ //allowsuperclasstoinitializeitsstatefirst ifself=[superinit]){ age=0; name=@ Bob ; //dootherinitialization... 11/11/11 4
2 Multiple init Methods Classes may define multiple init methods - id)init; - id)initwithname:nsstring *)name; - id)initwithname:nsstring *)name age:int)age; Less specific ones typically call more specific with default values 2id)init{ return[selfinitwithname:@ NoName ]; 2id)initWithName:NSString*)name{ return[selfinitwithname:nameage:0]; Finishing Up With an Object Person *person = nil; person = [[Person alloc] init]; [person setname:@ Jimmy Jones ]; [person setage:32]; [person castballot]; [person dosomethingelse]; // What do we do with person when we re done? 11/11/ /11/11 6 Memory Management Allocation Destruction C Malloc Free Objective-C Alloc dealloc Calls must be balanced, otherwise, your program may leak or crash Reference Counting Every object has a retain count Defined on NSObject As long as retain count is > 0, object is alive and valid +alloc and -copy create objects with retain count of 1 Why we release in methods objects created with alloc -retain increments retain count -release decrements retain count When retain count reaches 0, object is destroyed -dealloc method invoked automatically 11/11/ /11/11 8
3 Balanced Calls Person *person = nil; person = [[Person alloc] init]; [person setname:@ Jimmy Jones ]; [person setage:32]; [person castballot]; [person dosomethingelse]; Reference Counting in Action Person *person = [[Person alloc] init]; Retain count begins at 1 with +alloc [person retain]; Retain count increases to 2 with -retain [person release]; Retain count decreases to 1 with -release [person release]; Retain count decreases to 0, -dealloc automatically called // When we re done with person, release it [person release]; // person will be destroyed here 11/11/ /11/11 10 Messaging deallocated objects Person *person = [[Person alloc] init]; //... [person release]; // Object is deallocated person = nil; [person dosomething]; // No effect Implementing a -dealloc method 2 void)dealloc{ //Doanycleanupthat snecessary //... //whenwe redone,callsupertocleanusup 11/11/ /11/11 12
4 Object Lifecycle Recap Objects begin with a retain count of 1 Increase and decrease with -retain and - release When retain count reaches 0, object deallocated automatically You never call dealloc explicitly in your code Exception is calling 2[superdealloc] You only deal with alloc, copy, retain, release Object Ownership { //instancevariables NSString*name;//Personclass owns thename intage; //methoddeclarations 2NSString*)name; 2void)setName:NSString*)value; 2int)age; 2void)setAge:int)age; 2BOOL)canLegallyVote; 11/11/ /11/11 14 Object Ownership 2NSString*)name{returnname; void)setname:nsstring*)newname{ ifname!=newname){ [namerelease]; //ifwedon tdothis,wewouldlosethe //referencetotheobjectpointedtobynameafter //theassignment,whichwouldcauseamemoryleak name=[newnameretain]; //PersonistakingownershipofnewName //name 11/11/11 15 Releasing Instance Variables #import 2void)dealloc{ //Doanycleanupthat snecessary [name&release];& & //whenwe redone,callsupertocleanus up 11/11/11 16
5 Returning a Newly Created Object Attempt #1 2NSString*)fullName{ NSString*result; result= [[NSStringalloc]initWithFormat:@ %@%@, firstname,lastname]; returnresult; Not ideal: caller must remember to call release on the NSString after using it Returning a Newly Created Object Attempt #2 2NSString*)fullName{ NSString*result; result= [[NSStringalloc]initWithFormat:@ %@%@, firstname,lastname]; [resultrelease]; returnresult; Wrong: result is released too early! Method would return bogus value 11/11/ /11/11 18 Returning a Newly Created Object Attempt #3 2NSString*)fullName{ NSString*result; result= [[NSStringalloc]initWithFormat:@ %@%@, firstname,lastname]; [resultautorelease]; returnresult; Just right: result is released, but not right away Caller gets valid object and could retain if needed Autoreleasing Objects Calling -autorelease flags an object to be sent release at some point in the future Lets you fulfill your retain/release obligations while allowing an object some additional time to live Makes it much more convenient to manage memory Very useful in methods which return a newly created object 11/11/ /11/11 20
6 Method Names & Autorelease Methods whose names includes alloc, copy, or new return a retained object that the caller needs to release NSMutableString *string = [[NSMutableString alloc] init]; // We are responsible for calling -release or autorelease [string autorelease]; All other methods return autoreleased objects NSMutableString *string = [NSMutableString string]; // The method name doesn t indicate that we need to release // So don t- we re cool! This is a convention - follow it in methods you define! How does -autorelease work? Object is added to current autorelease pool Autorelease pools track objects scheduled to be released When the pool itself is released, it sends release to all its objects UIKit automatically wraps a pool around every event dispatch Autorelease is not garbage collection Objective-C on iphone OS does not have garbage collection 11/11/ /11/11 22 Autorelease Pools in pictures) Pool$ [object$release];$ [object$release];$ [object$release];$ Pool$released$ Objects$autoreleased$ Here$go$into$pool$ Pool$created$ [object$ autorelease];$ Hanging Onto an Autoreleased Object Many methods return autoreleased objects Remember the naming conventions... They re hanging out in the pool and will get released later If you need to hold onto those objects you need to retain them Bumps up the retain count before the release happens name$=$[nsmutablestring$string];$ //$We$want$the$name$to$remain$valid!$ [name$retain];$ //$...$ //$Eventually,$we ll$release$it$maybe$in$our$hdealloc?)$ [name$release];$ 11/11/ /11/11 24
7 Memory Management Revisited What is going to happen if you were to run the code below assuming other parts are implemented perfectly? 2void)viewDidLoad{ stuff=arr; [arrrelease]; 25 Memory Management Revisited How about this piece of code? { 2void)viewDidLoad{ NSArray*arr=[[NSArrayalloc] self.stuff=arr; [arrrelease]; 26 Memory Management Revisited First version would crash as soon as the app is started, while the second version would work just fine The difference? Whether or not self is used: self.stuff = arr; This is quite puzzling. Shouldn t we be able to access the class instance variable directly? Yes, we do. We can certainly manipulate instance variables within the class without having to use: self. What is the problem then? Memory Management Revisited The problem is related to memory management Why version 1 crashed? stuff = arr; this assignment does not retain the array arr) aside from the implicit retain via alloc+init) When the next statement is executed: [arr release]; the retain count of the array arr) drops to 0, and therefore, it is deallocated => stuff would point to nothing, which caused the crash Why version 2 works? self.stuff = arr; in this assignment, we are actually calling the setter of the property, which would increase the retain count by 1 due to the property nonatomic, retain) NSArray *stuff; 27 28
8 Property nonatomic, retain) NSArray *stuff; retain means that the retain count for the property) will be increased after the assignment self.stuff = arr; // stuff s retain count will be increased by 1 Furthermore, the previous object which stuff pointed to) is sent a release message This is why we can do this in viewdidunload: self.namefield = nil; However, the release message is sent to instance variables directly in dealloc: method [namefield release]; The self Keyword self is to be used within a method definition to refer to the object that performs the method You normally send a message to self However, the dot notation for declared properties introduced in Objective-C 2.0) added confusion, especially for C++/Java programmers What does self.stuff mean? self.stuff = arr; // equivalent to [self setstuff: arr]; arr = self.stuff; // equivalent to arr = [self stuff]; Automatic Reference Counting Still not garbage collection They want to keep GC out; don t want the possibility of unexpected delays in run This is just the compiler inserting appropriate reference counting code automatically Based on static analysis of code Clang static analyser It is still important to understand the rules of retain/release ARC vs GC ARC is more deterministic Follows the same rigid rules of retain/release, just inserted automatically by the compiler GC can result in sawtooth memory consumption patterns No UI stutter with ARC 11-Nov-11 Mobile App Development Nov-11 Mobile App Development 32
9 Concurrency With only one thread, long-running operations can interfere with user interaction System can t update the screen App looks like it s hung Multiple threads allow multiple computations without locking up your entire application Blocking operation can happen on the background thread Threads on iphone Based on POSIX threads API /usr/include/pthread.h Higher-level wrappers in Foundation framework NSThread Object-oriented, easy to use 11/11/ /11/11 34 NSThread Run loop automatically instantiated for each thread Run loop is the main event loop that the app runs App spends most of its time in the run loop Each NSThread needs to create its own autorelease pool One is not created for you Includes methods for inter-thread messaging NSThread Creating a new thread Attach a selector to the new thread The selector method does the actual work Once the work is complete, the selector on the background thread sends a message back to the main thread to notify completion All interaction with the user must happen on the main thread 11/11/ /11/11 36
10 Using NSThread 2void)someAction:id)sender{ //Fireupnewthread withtarget:selfobject:somedata]; 2 void)dowork:id)somedata{ NSAutoreleasePool*pool=[[NSAutoreleasePoolalloc]init]; [somedatadolotsofwork]; //Sendmessagebacktomainthread [selfperformselectoronmainthread:@selectoralldone:) withobject:[somedataresult]waituntildone:no]; [poolrelease]; Dangers of Multiple Threads Can add considerable amount of complexity to app design Threads share memory; they have access to the same data structures Need coordination to decide which thread has access to a particular data structure at a particular time Synchronization and Locking 11/11/ /11/11 38 UIKit and Threadsafety Threadsafety A single data object accessed in two different threads may lead to a race condition UIKit classes are not threadsafe Objects must be created and messaged from the main thread Notable exception: UIImage can be created in a background thread But since UIImageView is not threadsafe, you can t set it in a background thread 11/11/11 39 Locks Protect critical sections of code Thread-safety NSLock 2void)init{ mylock=[[nslockalloc]init]; 2void)someMethod{ [mylocklock]; //Executecriticalsectioncode [mylockunlock]; 11/11/11 40
11 Conditions NSCondition is useful for producer/ consumer model //Ontheproducerthread 2void)produceData{ [conditionlock]; //Producenewdata newdataexists=yes; [conditionsignal]; [conditionunlock]; //Ontheconsumerthread 2void)consumeData{ [conditionlock]; while!newdataexists){ [conditionwait]; //Consumethenewdata newdataexists=no; [conditionunlock]; Danger of Locks Very easy to make mistakes All it takes is one poorly behaved client Accessing shared data outside of a lock Deadlocks Priority inversion Main thread is always supposed to have highest priority 11/11/ /11/11 42 Threading Pitfalls Subtle, nondeterministic bugs may be introduced Notoriously difficult to replicate Code may become more difficult to maintain Poorly managed threads and synchronization may actually result in slower code Alternatives to Explicit Threading Asynchronous nonblocking) functions Call a function, and pass a pointer to a callback function Specify a target/action or a delegate for callback Timers One-shot or recurring Specify a callback method Managed by the run loop NSOperation: higher level construct 11/11/ /11/11 44
12 NSOperation Manages thread creation and lifecycle Encapsulate a unit of work in an object System can schedule the operation when it is appropriate Specify priorities and dependencies Creating an NSOperation Subclass Define a custom init method 2id)initWithSomeObject:id)someObject{ self=[superinit]; ifself){ self.someobject=someobject; returnself; Override main method 2void)main{ [someobjectdolotsoftimeconsumingwork]; 11/11/ /11/11 46 NSOperationQueue Operations are typically scheduled by adding to a queue Choose a maximum number of concurrent operations Runtime worries about creating an appropriate number of threads Queue runs operations based on priority and dependencies NSInvocationOperation Concrete subclass of NSOperation For lightweight tasks 2void)someAction:id)sender{ NSInvocationOperation*operation= [[NSInvocationOperationalloc]initWithTarget:self selector:@selectordowork:) object:someobject]; [queueaddoperation:operation]; [operationrelease]; 11/11/ /11/11 48
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 informationCS193P - Lecture 10. iphone Application Development. Performance
CS193P - Lecture 10 iphone Application Development Performance 1 Announcements 2 Announcements Paparazzi 2 is due next Wednesday at 11:59pm 2 Announcements Paparazzi 2 is due next Wednesday at 11:59pm
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 informationCS193P - Lecture 11. iphone Application Development. Text Input Presenting Content Modally
CS193P - Lecture 11 iphone Application Development Text Input Presenting Content Modally 1 Announcements 2 Announcements Paparazzi 3 assignment is due Wednesday 2/17 2 Announcements Paparazzi 3 assignment
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 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 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 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 informationAnnouncements. Paparazzi 3 assignment is due Wednesday 2/17 This Friday s extra session will feature Evan Doll
CS193P - Lecture 11 iphone Application Development Text Input Presenting Content Modally 1 Announcements Paparazzi 3 assignment is due Wednesday 2/17 This Friday s extra session will feature Evan Doll
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 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 informationAnnouncements. 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 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 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 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 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 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 informationGrand Central Dispatch and NSOperation. CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015
Grand Central Dispatch and NSOperation CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015 1 Credit Where Credit Is Due Most of the examples in this lecture were inspired by example code
More informationMobile 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 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 informationMemory Management: The Details
Lecture 10 Memory Management: The Details Sizing Up Memory Primitive Data Types Complex Data Types byte: char: short: basic value (8 bits) 1 byte 2 bytes Pointer: platform dependent 4 bytes on 32 bit machine
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 informationThread Sanitizer and Static Analysis
Developer Tools #WWDC16 Thread Sanitizer and Static Analysis Help with finding bugs in your code Session 412 Anna Zaks Manager, Program Analysis Team Devin Coughlin Engineer, Program Analysis Team 2016
More informationConcurrency. CS 442: Mobile App Development Michael Saelee
Concurrency CS 442: Mobile App Development Michael Saelee note: ios devices are now (mostly) multi-core; i.e., concurrency may allow for real performance gains! but the more common incentive
More informationthe gamedesigninitiative at cornell university Lecture 9 Memory Management
Lecture 9 Gaming Memory Constraints Redux Wii-U Playstation 4 2GB of RAM 1GB dedicated to OS Shared with GPGPU 8GB of RAM Shared GPU, 8-core CPU OS footprint unknown 2 Two Main Concerns with Memory Getting
More informationAdvanced 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 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 informationPerformance
Threading Programming Guide Performance 2010-04-28 Apple Inc. 2010 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form
More informationigc Garbage Collection
igc Garbage Collection User s Manual Harnix Technologies Inc. 2011-08-16 - 2 - Contents Overview... 6 Basic Concepts... 6 Architecture... 7 How the Garbage Collector Works... 7 Enabling Garbage Collection...
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 informationQUIZ. What is wrong with this code that uses default arguments?
QUIZ What is wrong with this code that uses default arguments? Solution The value of the default argument should be placed in either declaration or definition, not both! QUIZ What is wrong with this code
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 informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Multithreading Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to large compute clusters Can perform multiple
More informationAssignment 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 informationDealing with Issues for Interprocess Communication
Dealing with Issues for Interprocess Communication Ref Section 2.3 Tanenbaum 7.1 Overview Processes frequently need to communicate with other processes. In a shell pipe the o/p of one process is passed
More informationThe Myx Architectural Style
The Myx Architectural Style The goal of the Myx architectural style is to serve as an architectural style that is good for building flexible, high performance tool-integrating environments. A secondary
More informationObjective-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 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 informationThreads Questions Important Questions
Threads Questions Important Questions https://dzone.com/articles/threads-top-80-interview https://www.journaldev.com/1162/java-multithreading-concurrency-interviewquestions-answers https://www.javatpoint.com/java-multithreading-interview-questions
More informationCOMP327 Mobile Computing Session: Lecture Set 1a - Swift Introduction and the Foundation Framework Part 2
COMP327 Mobile Computing Session: 2018-2019 Lecture Set 1a - Swift Introduction and the Foundation Framework Part 2 73 Other Swift Guard Already seen that for optionals it may be necessary to test that
More informationProcess Characteristics
Threads 1 Chapter 4 2 Process Characteristics We ve mentioned a process as having two characteristics Unit of resource ownership: processes have their own dedicated memory address space processes temporarily
More informationIT 540 Operating Systems ECE519 Advanced Operating Systems
IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (5 th Week) (Advanced) Operating Systems 5. Concurrency: Mutual Exclusion and Synchronization 5. Outline Principles
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 informationCSE 153 Design of Operating Systems Fall 2018
CSE 153 Design of Operating Systems Fall 2018 Lecture 5: Threads/Synchronization Implementing threads l Kernel Level Threads l u u All thread operations are implemented in the kernel The OS schedules all
More informationMemory management COSC346
Memory management COSC346 Life cycle of an object Create a reference pointer Allocate memory for the object Initialise internal data Do stuff Destroy the object Release memory 2 Constructors and destructors
More informationE Event-based parser, XML, 180 Extended attributes, URLs, 118 API, 119 command line, 118 description, 118 NSURL category, 119
Index A Access control lists (ACLs), 113 Application distribution, 353 certificate utility, 358 App ID creation, 358 App Store, 363 center, 357 no of certificates, 358 code sign identity, 362 configuring
More informationLearning from Bad Examples. CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014
Learning from Bad Examples CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014 1 Goals Demonstrate techniques to design for shared mutability Build on an example where multiple threads
More informationView Controller Lifecycle
View Controller Lifecycle View Controllers have a Lifecycle A sequence of messages is sent to them as they progress through it Why does this matter? You very commonly override these methods to do certain
More informationCS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers
CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers 1 Critical sections and atomicity We have been seeing that sharing mutable objects between different threads is tricky We need some
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Memory Management and Garbage Collection CMSC 330 - Spring 2013 1 Memory Attributes! Memory to store data in programming languages has the following lifecycle
More informationTopics in Mobile Computing
Topics in Mobile Computing Workshop 1I - ios Fundamental Prepared by Y.H. KWOK What is ios? From Wikipedia (http://en.wikipedia.org/wiki/ios): ios is an operating system for iphone, ipad and Apple TV.
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 informationSynchronization SPL/2010 SPL/20 1
Synchronization 1 Overview synchronization mechanisms in modern RTEs concurrency issues places where synchronization is needed structural ways (design patterns) for exclusive access 2 Overview synchronization
More informationChapter 4: Threads. Operating System Concepts 9 th Edit9on
Chapter 4: Threads Operating System Concepts 9 th Edit9on Silberschatz, Galvin and Gagne 2013 Chapter 4: Threads 1. Overview 2. Multicore Programming 3. Multithreading Models 4. Thread Libraries 5. Implicit
More informationAdvanced Topics in Operating Systems
Advanced Topics in Operating Systems MSc in Computer Science UNYT-UoG Dr. Marenglen Biba 8-9-10 January 2010 Lesson 10 01: Introduction 02: Architectures 03: Processes 04: Communication 05: Naming 06:
More informationChapter 4: Multi-Threaded Programming
Chapter 4: Multi-Threaded Programming Chapter 4: Threads 4.1 Overview 4.2 Multicore Programming 4.3 Multithreading Models 4.4 Thread Libraries Pthreads Win32 Threads Java Threads 4.5 Implicit Threading
More informationios Performance and Concurrency Patrick Thomson
ios Performance and Concurrency Patrick Thomson Performance Matters ios devices are resource-constrained Users will notice performance issues The deciding factor between a good and an awful app Demo Obligatory
More informationObject Oriented Programming in C++
2501ICT/7421ICT Nathan School of Information and Communication Technology Griffith University Semester 1, 2012 Outline 1 Subclasses, Access Control, and Class Methods Subclasses and Access Control Class
More informationThreads Chapter 5 1 Chapter 5
Threads Chapter 5 1 Chapter 5 Process Characteristics Concept of Process has two facets. A Process is: A Unit of resource ownership: a virtual address space for the process image control of some resources
More informationChap.6 Limited Direct Execution. Dongkun Shin, SKKU
Chap.6 Limited Direct Execution 1 Problems of Direct Execution The OS must virtualize the CPU in an efficient manner while retaining control over the system. Problems how can the OS make sure the program
More informationAsynchronous Interactions and Managing Modeless UI with Autodesk Revit API
Asynchronous Interactions and Managing Modeless UI with Autodesk Revit API Arnošt Löbel Sr. Principal Software Engineer, Autodesk, Inc. Class Summary In this class we will explore the realms of challenging
More informationCS 160: Interactive Programming
CS 160: Interactive Programming Professor John Canny 3/8/2006 1 Outline Callbacks and Delegates Multi-threaded programming Model-view controller 3/8/2006 2 Callbacks Your code Myclass data method1 method2
More informationComputation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007
CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Threads and Synchronization May 8, 2007 Computation Abstractions t1 t1 t4 t2 t1 t2 t5 t3 p1 p2 p3 p4 CPU 1 CPU 2 A computer Processes
More informationCS342: Software Design. November 21, 2017
CS342: Software Design November 21, 2017 Runnable interface: create threading object Thread is a flow of control within a program Thread vs. process All execution in Java is associated with a Thread object.
More information1 2 http://www.d.umn.edu/~gshute/softeng/object-oriented.html Polymorphism and overloading can lead to confusion if used excessively. However, the capability of using words or names to mean different things
More informationPage 1. Analogy: Problems: Operating Systems Lecture 7. Operating Systems Lecture 7
Os-slide#1 /*Sequential Producer & Consumer*/ int i=0; repeat forever Gather material for item i; Produce item i; Use item i; Discard item i; I=I+1; end repeat Analogy: Manufacturing and distribution Print
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 informationObjective-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 informationMy First iphone App. 1. Tutorial Overview
My First iphone App 1. Tutorial Overview In this tutorial, you re going to create a very simple application on the iphone or ipod Touch. It has a text field, a label, and a button. You can type your name
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Memory Management and Garbage Collection CMSC 330 Spring 2017 1 Memory Attributes Memory to store data in programming languages has the following lifecycle
More informationObject Oriented Programming and Design in Java. Session 18 Instructor: Bert Huang
Object Oriented Programming and Design in Java Session 18 Instructor: Bert Huang Announcements Homework 4 due Mon. Apr. 19 No multithreading in programming part Final Exam Monday May 10, 9 AM - noon, 173
More informationnptr = new int; // assigns valid address_of_int value to nptr std::cin >> n; // assigns valid int value to n
Static and Dynamic Memory Allocation In this chapter we review the concepts of array and pointer and the use of the bracket operator for both arrays and pointers. We also review (or introduce) pointer
More informationProcess Description and Control
Process Description and Control 1 Process:the concept Process = a program in execution Example processes: OS kernel OS shell Program executing after compilation www-browser Process management by OS : Allocate
More informationMultithreaded Programming Part II. CSE 219 Stony Brook University, Department of Computer Science
Multithreaded Programming Part II CSE 219 Stony Brook University, Thread Scheduling In a Java application, main is a thread on its own Once multiple threads are made Runnable the thread scheduler of the
More informationConcurrent & Distributed Systems Supervision Exercises
Concurrent & Distributed Systems Supervision Exercises Stephen Kell Stephen.Kell@cl.cam.ac.uk November 9, 2009 These exercises are intended to cover all the main points of understanding in the lecture
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 informationCS193P: HelloPoly Walkthrough
CS193P: HelloPoly Walkthrough Overview The goal of this walkthrough is to give you a fairly step by step path through building a simple Cocoa Touch application. You are encouraged to follow the walkthrough,
More informationEMBEDDED SYSTEMS PROGRAMMING OO Basics
EMBEDDED SYSTEMS PROGRAMMING 2014-15 OO Basics CLASS, METHOD, OBJECT... Class: abstract description of a concept Object: concrete realization of a concept. An object is an instance of a class Members Method:
More information연세대학교전기전자공학과프로세서연구실박사과정김재억.
이강좌는연세대학교이용석교수연구실에서제작되었으며 copyright가없으므로비영리적인목적에한하여누구든지복사, 배포가가능합니다. 연구실홈페이지에는 고성능마이크로프로세서에관련된많은강의가있으며누구나무료로다운로드받을 수있습니다. 연세대학교전기전자공학과프로세서연구실박사과정김재억 Email: yonglee@yonsei.ac.kr 멀티스레드프로그래밍 (Multithreaded
More informationiphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department
iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department pmadden@acm.org http://optimal.cs.binghamton.edu General Outline Overview of the tools, and where to get more information
More informationC# Asynchronous Programming Model
Spring 2014 C# Asynchronous Programming Model A PRACTICAL GUIDE BY CHRIS TEDFORD TABLE OF CONTENTS Introduction... 2 Background Information... 2 Basic Example... 3 Specifications and Usage... 4 BeginInvoke()...
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 informationiphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5
iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5 Questions? Announcements Assignment #1 due this evening by 11:59pm Remember, if you wish to use a free late you must email me before
More information10/10/ Gribble, Lazowska, Levy, Zahorjan 2. 10/10/ Gribble, Lazowska, Levy, Zahorjan 4
What s in a process? CSE 451: Operating Systems Autumn 2010 Module 5 Threads Ed Lazowska lazowska@cs.washington.edu Allen Center 570 A process consists of (at least): An, containing the code (instructions)
More informationOperating Systems 2 nd semester 2016/2017. Chapter 4: Threads
Operating Systems 2 nd semester 2016/2017 Chapter 4: Threads Mohamed B. Abubaker Palestine Technical College Deir El-Balah Note: Adapted from the resources of textbox Operating System Concepts, 9 th edition
More informationConcurrency, Thread. Dongkun Shin, SKKU
Concurrency, Thread 1 Thread Classic view a single point of execution within a program a single PC where instructions are being fetched from and executed), Multi-threaded program Has more than one point
More informationWhat s in a process?
CSE 451: Operating Systems Winter 2015 Module 5 Threads Mark Zbikowski mzbik@cs.washington.edu Allen Center 476 2013 Gribble, Lazowska, Levy, Zahorjan What s in a process? A process consists of (at least):
More informationOperating System Architecture. CS3026 Operating Systems Lecture 03
Operating System Architecture CS3026 Operating Systems Lecture 03 The Role of an Operating System Service provider Provide a set of services to system users Resource allocator Exploit the hardware resources
More informationItem 18: Implement the Standard Dispose Pattern
Item 18: Implement the Standard Dispose Pattern 1 Item 18: Implement the Standard Dispose Pattern We ve discussed the importance of disposing of objects that hold unmanaged resources. Now it s time to
More informationProcesses. Johan Montelius KTH
Processes Johan Montelius KTH 2017 1 / 47 A process What is a process?... a computation a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other
More informationGrand Central Dispatch
A better way to do multicore. (GCD) is a revolutionary approach to multicore computing. Woven throughout the fabric of Mac OS X version 10.6 Snow Leopard, GCD combines an easy-to-use programming model
More informationThe issues. Programming in C++ Common storage modes. Static storage in C++ Session 8 Memory Management
Session 8 Memory Management The issues Dr Christos Kloukinas City, UoL http://staff.city.ac.uk/c.kloukinas/cpp (slides originally produced by Dr Ross Paterson) Programs manipulate data, which must be stored
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 information27/04/2012. We re going to build Multithreading Application. Objectives. MultiThreading. Multithreading Applications. What are Threads?
Objectives MultiThreading What are Threads? Interrupting threads Thread properties By Võ Văn Hải Faculty of Information Technologies Summer 2012 Threads priorities Synchronization Callables and Futures
More informationThe MVC Design Pattern
The MVC Design Pattern The structure of iphone applications is based on the Model-View-Controller (MVC) design pattern because it benefits object-oriented programs in several ways. MVC based programs tend
More informationChapter 4: Threads. Chapter 4: Threads. Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues
Chapter 4: Threads Silberschatz, Galvin and Gagne 2013 Chapter 4: Threads Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues 4.2 Silberschatz, Galvin
More informationConcurrency. Glossary
Glossary atomic Executing as a single unit or block of computation. An atomic section of code is said to have transactional semantics. No intermediate state for the code unit is visible outside of the
More information