Presentation is loading. Please wait.

Presentation is loading. Please wait.

OS X Development Tom Schroeder. Table of Contents Who cares? HistoryObjective-CCocoaEnvironmentDesign.

Similar presentations


Presentation on theme: "OS X Development Tom Schroeder. Table of Contents Who cares? HistoryObjective-CCocoaEnvironmentDesign."— Presentation transcript:

1 OS X Development Tom Schroeder

2 Table of Contents Who cares? HistoryObjective-CCocoaEnvironmentDesign

3 Objective-C TIOBE: Language of the Year - 2011 Currently ranked #3 Mac and OS X market share continues to rise Flourishing App Store OS X and iOS apps numerous

4 History 1985: Steve Jobs leaves Apple Jobs founds NeXT Mission: Create powerful computers for universities NeXTSTEP Object-Oriented, Multitasking Operating System Interesting Note Tim Berners-Lee designed and built first web browser on NeXTSTEP 1996: NeXT purchased by Apple NeXTSTEP becomes Mac OS X 2001: Cheetah (10.0) 2012: Mountain Lion (10.8)

5 Objective-C Object-oriented language ANSI C language (strict superset) Smalltalk-inspired extension Developed in early 80s Stepstone (Brad Cox and Tom Love) Goal: facilitate reusability and backwards compatible to C Features & Constructs Messages Interfaces and Implementation Properties Object Life Cycle ARC Protocols Categories Dynamic Typing

6 Messages Message is sent Target and interpretation of message calculated runtime Inspired by Smalltalk Bracket Syntax

7 Interface and Implementation Declaration and Definition Interface - @interface Instance variables Properties Method declarations Inheritance Protocol adoption Implementation - @implementation Definition of methods, properties, protocol conformity

8 Properties Simple way to declare accessor methods Encapsulation Methods are generated by compiler - @synthesize Allow use of “dot syntax” Declaration contains attributes Writability (readonly, readwrite) Setter semantics (strong, weak, copy, assign, retain) Setter semantics (strong, weak, copy, assign, retain)Atomicity

9 Object Life Cycle 1210 allocretainrelease Retain-Release Process

10 Object Life Cycle - ARC ARC: Automatic Reference Counting Automatic memory management Compiler inserts retains and releases Restrictive but effective Bridge casting C-style cast void *

11 Protocols Declare methods to be implemented by a class Adoption and Conformity Similar to “interface” in Java Objects can be referred to by the adopted protocol id delegate;

12 Categories Open classes Add methods to existing classes (even those in an imported framework) Extensions Anonymous categories Commonly used to redeclare readonly property as readwrite

13 Dynamic Typing id type Pointer to Objective-C object Message Forwarding Handle message Drop message Pass it on

14 Blocks Anonymous Functions Similar to standard C functions Usage Encapsulate code groups to execute concurrently Dispatch Execute on items in a collection Fast enumeration Easily parameterized

15 Comparison to C++ Objective-C is true superset of C (simple - small addition) C++ is complex - adds features such as templates, operator overloading, etc. C++ is generally faster Objective-C’s runtime is more complex (dynamic typing & message passing) Objective-C is dynamically typed Objective-C has built-in synchronization @synchronize

16 Cocoa Framework that provides applications the distinctive look and feel often associated with OS X Underlying Frameworks Foundation Kit Application Kit Core Data Other frameworks

17 Foundation Collection of base layer classes Applications can be created solely with Foundation Command line tools Functionalities General object behavior and life cycle NSObject – base class LocalizationPortabilityWrappersPrimitives Operating system level functionality Ports File I/O Threads

18 Foundation Classes Contains over 100 different classes NSObject - base class alloc, init, class conformsToProtocol:performSelector:onThread:withObject:waitUntilDone:NSStringNSMutableStringNSArrayNSMutableArrayNSThreadNSDateNSURL

19 AppKit Contains objects required in creating a graphical application WindowsButtons Scroll Boxes Text Fields Views NSView, NSTextView Controllers NSViewController, NSWindowController

20 Core Data Provides means to manage the data of an application Data model SerializationXMLBinarySQLitePersistence Managed Objects Command Pattern Undo/Redo

21 Other Frameworks Audio & Video Core Audio Core Video Core MIDI Graphics/Animation Core Animation Core Image OpenGLQuartzBridges Ruby PythonNetworking Bonjour Kerberos

22 Environment Great environment  Excellent development experience ToolsXcode General IDE Utilities Apple LLVM Engine Backend Interface Builder Graphical Interface Designer

23 Xcode General IDE Code Editor LLVM Engine Integration Interface Builder Integration Project Navigation Utilities Version Editor Instruments

24 Xcode

25 LLVM Engine Compiler - Clang C/Objective-C/C++ Syntax Highlighting Code Completion Live Issues Fix-it Static Analysis Improper memory allocation Unreachable code Improper loops llvm.org

26 Interface Builder Integrated into Xcode Design graphical interfaces for application Drag and Drop WYSIWYG IBActions & IBOutlets Connect visual design to code

27 Interface Builder

28 Design Objective-C and Cocoa utilize many design patterns and constructs Provides stability and familiarity Design Patterns Model-View-ControllerDelegationOthers…

29 Model-View-Controller Divides system into three components Model Domain-specific data and operations Platform-independentView Responsible for graphically displaying the model Controller Mediator for the model and view Handles interactions with the system

30 Model-View-Controller Smalltalk-80 MVC Paradigm ParcPlace Systems, Inc.

31 Model-View-Controller Controller ModelView Observer Mediator Command

32 Delegation One class delegates action to another (helper object) Inversion of control Delegate & Delegator Pass notifications No polling Utilizes protocols Delegate conforms to methods for which delegator is aware

33 Design Patterns Command pattern NSInvocationUndo/redo Observer pattern KVO: Key-Value Observer Adapter pattern Protocols Singleton Pattern NSFileManager NSApplicationMemento Archiving SerializationProxy NSProxy

34 Design Patterns Composite View Hierarchy DecoratorCategoriesFaçadeNSImage Bitmap (jpg, png) Vector (pdf) Iterator Fast enumeration Mediator Controller classes Abstract Factory Class Clusters NSString NSArray Chain of Responsibility NSResponder AppKit Responder Chain

35 Demo


Download ppt "OS X Development Tom Schroeder. Table of Contents Who cares? HistoryObjective-CCocoaEnvironmentDesign."

Similar presentations


Ads by Google