1 / 35

OS X Development

OS X Development. Tom Schroeder. Table of Contents. Who cares? History Objective-C Cocoa Environment Design. Who cares?. 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.

kieve
Download Presentation

OS X Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OS X Development Tom Schroeder

  2. Table of Contents • Who cares? • History • Objective-C • Cocoa • Environment • Design

  3. Who cares? • 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) • Atomicity

  9. Object Life Cycle 1 2 1 0 alloc retain release release 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 <NSTabViewDelegate> delegate;

  12. Categories • Open classes • Add methods to existing classes (even those in an imported framework) • Extensions • Anonymous categories • Commonly used to redeclarereadonly 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 • Localization • Portability • Wrappers • Primitives • 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: • NSString • NSMutableString • NSArray • NSMutableArray • NSThread • NSDate • NSURL

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

  20. Core Data • Provides means to manage the data of an application • Data model • Serialization • XML • Binary • SQLite • Persistence • Managed Objects • Command Pattern • Undo/Redo

  21. Other Frameworks • Audio & Video • Core Audio • Core Video • Core MIDI • Graphics/Animation • Core Animation • Core Image • OpenGL • Quartz • Bridges • Ruby • Python • Networking • Bonjour • Kerberos

  22. Environment • Great environment  Excellent development experience • Tools • Xcode • 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-Controller • Delegation • Others…

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

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

  31. Model-View-Controller Mediator Controller Update Action Model View Notify Update Observer 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 • NSInvocation • Undo/redo • Observer pattern • KVO: Key-Value Observer • Adapter pattern • Protocols • Singleton Pattern • NSFileManager • NSApplication • Memento • Archiving • Serialization • Proxy • NSProxy

  34. Design Patterns • Composite • View Hierarchy • Decorator • Categories • Façade • NSImage • 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

More Related