Objective-C

13
Objective-C Drew Cheng CS420

description

Objective-C. Drew Cheng CS420. Overview. True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language Relies on outside libraries Iterative/Imperative Flexibility, most things are done at runtime Dynamic Typing Dynamic Binding - PowerPoint PPT Presentation

Transcript of Objective-C

Page 1: Objective-C

Objective-CDrew ChengCS420

Page 2: Objective-C

OverviewTrue superset of ANSI CObject-Oriented methods from SmallTalkThere is no formal written standard for the language

Relies on outside libraries

Iterative/ImperativeFlexibility, most things are done at runtime

Dynamic TypingDynamic BindingDynamic LinkingMessage Passing

Page 3: Objective-C

HistoryCreated by Brad Cox and Tom Love at their company StepstoneBoth were introduced to SmallTalk while working at ITTCox was interested in the problems of true reusability in software design and programmingModified C compiler and created a Object-Oriented extension of C called OOPCTom Love added more to OOPC from SmallTalk creating Objective-C

Page 4: Objective-C

1986 – Stepstone releases Objective-C1988 – Steve Jobs acquires Objective-C license for NeXTNeXT releases their own Objective-C compiler and libraries used in NeXTstep Operating System and OpenStep API1993 – GNU Objective-C runtime, currently in use, created by Kresten Thorup1996 – Apple Inc. acquires NeXT and uses OpenStep in new Mac OS XApple combines Objective-C and NeXT’s Objective-C, creates Cocoa API, most significant environment

Page 5: Objective-C

UniquenessMessaging/Forwarding

Does not call method, sends messageTarget of message is resolved at runtimeMessage passing has no type checkingReceiver not guaranteed to respond. No response either return null pointer or “forward” to an object that will respondInitial interpretation of message in Objc-C 3x longer than C++ virtual method call. Messages are cached and subsequent calls 50% faster than C++ method call.

Categories/Protocols

Page 6: Objective-C

PrimitivesInt, float, double, charUnsigned, signed, short, long, long longid – Generic object type

Can be used to store any object Essential to Objective-C’s dynamic binding

If/Else Statements, For/While/Do LoopsCombine features by nesting, “and/or” conditionalsAbstraction – variables, functions, classes

Page 7: Objective-C

Functions

Page 8: Objective-C

Variable PassingDefault method is pass-by-value for primitive data typesObjects use pass-by-referenceImpossible to use pass-by-value for ObjectsDoes not pass by result, value-result, name, or need

Page 9: Objective-C

Type CheckingDynamic type checkingConsidered weak typed languageLanguage supports coercion

When adding float and int, one is changed

Does not support type inference

Page 10: Objective-C

Object-OrientedDoes not support multiple inheritanceClass must inherit from Object/NSObject classVariable inheritance is dynamicMethod inheritance is dynamicThe super-method invocation uses method from class that super is called in (dynamic)No operation and method overloading

Page 11: Objective-C
Page 12: Objective-C
Page 13: Objective-C

ConclusionVery easy to learnSimple way of handling classes and objectsDynamism allows flexibility in codeErrors may are not found until runtimeNot a very used language outside Apple