Your SlideShare is downloading. ×
0
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Objective c
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Objective c

523

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
523
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide


































  • Transcript

    • 1. Objective-C - an introduction Spencer Pieters RovingBird
    • 2. RovingBird
    • 3. RovingBird
    • 4. RovingBird
    • 5. RovingBird
    • 6. RovingBird
    • 7. Experience C# C Other C++ Objective-C 14% 4% 36% 43% 4%
    • 8. Topics History Classes Objects Memory Management OO Interesting Bits Recommended Books
    • 9. popularity++; June 2010, TIOBE index “Despite the fact that Objective-C only gained 0.08% last month, it has entered the top-10 for the first time.”
    • 10. popularity++;
    • 11. History Created by Brad Cox and Tom Love (StepStone, early 1980) Licensed by NeXT Used to build NeXTstep and project builder Used in Mac OS X Now: Xcode, Interface Builder, Cocoa
    • 12. What ? “Objective-C is a reflective, object-oriented programming language which adds Smalltalk-style messaging to the C programming language.”
    • 13. Class Definition @interface Classname: ItsSuperclass { instance variable definitions } + (void)someMethod; - (void)anotherMethod; @end
    • 14. Class Implementation @implementation Classname method definitions @end
    • 15. Objects All objects are of type id Every object has isa instance variable Used by runtime to find out stuff about objects
    • 16. Make objects do stuff [receiver message]; Runtime resolves target of the message Receiving object interprets message
    • 17. Message examples [myRect display]; [myRect setWidth:20]; [myRect setOriginX:10 y:20];
    • 18. Messaging how-to [object <keyword>:(type)<argument>]
    • 19. Message examples if (x.insersectsArc(35, 19, 23, 90, 120))
    • 20. Message examples if (x.insersectsArc(35, 19, 23, 90, 120)) if ([x intersectsArcWithRadius:35 centeredAtX:19 Y:23 fromAngle:90 toAngle:120])
    • 21. Memory (1/3) retainCount new/alloc/copy: retainCount = 1 [object retain]: retainCount increase [object release]: retainCount decrease
    • 22. Memory (2/3)
    • 23. Memory (2/3) When retainCount becomes zero, object is free
    • 24. Memory (3/3) NSArray *cars = [[NSArray alloc] init...]; Car *car = [[Car alloc] init]; [cars addObject:car]; [car release]; car = nil;
    • 25. Categories Add new methods to existing classes without subclassing @interface NSString (CategoryName) - (NSString*)firstChar; @end
    • 26. Limitations You can’t add instance variables to classes Collisions in method names (prefixes)
    • 27. Fast Enumeration for (Type newVariable in expression) { statements } Expression conforms to NSFastEnumeration
    • 28. Protocols List of methods Make a class conform to a protocol Aka interfaces @interface ClassName <ProtocolName> @required @optional @end
    • 29. Interesting bits In Objective-C it is valid to send a message to nil Boolean:YES/NO No abstract/final classes Exception handling via @try, @catch, @finally No namespaces. Prefixes are used.
    • 30. dot syntax car.color = whatever; [car setColor:whatever]; [car setValue:whatever forKey:@”color”];
    • 31. Recommended Books
    • 32. More recommended http://developer.apple.com/library/mac/#documentation/ Cocoa/Conceptual/ObjectiveC/ObjC.pdf
    • 33. Interested in Cocoa? http://www.cocoaheads.be
    • 34. More Info www.rovingbird.com spencer@rovingbird.com

    ×