22
OBJECTIVE-C AND IOS FOR .NET DEVELOPERS EDUARDO SCOZ CHICAGO ALT.NET SEPT 2011

Obj-C and iOS for .NET Developers

  • Upload
    escoz

  • View
    7.498

  • Download
    5

Embed Size (px)

Citation preview

Page 1: Obj-C and iOS for .NET Developers

OBJECTIVE-C AND IOSFOR .NET DEVELOPERS

EDUARDO SCOZ

CHICAGO ALT.NET

SEPT 2011

Page 2: Obj-C and iOS for .NET Developers

ME

• Software Architect at

• .NET Developer for 5-6 years

• iOS Developer for the last 2 years

• Obj-C exclusively for 4 months

• http://escoz.com

• http://twitter.com/escoz

Page 3: Obj-C and iOS for .NET Developers

IOS DEV 101

What you need:

• A Mac• Register with Apple Dev Center - $100.00• Download XCode 4 (or beta) • Time and patience

Demo

Page 4: Obj-C and iOS for .NET Developers

SO, WHAT IS IT LIKE?

AFTER 6 MONTHS

Page 5: Obj-C and iOS for .NET Developers

IOS LIBRARIES ARE GREAT

• CocoaTouch works really well

• Really productive

• Easy to make good stuff fast

• NS objects get a while to get used to

• C functions are necessary every once in a while, which is strange, but not the end of the world

Page 6: Obj-C and iOS for .NET Developers

OBJ-C IS UGLY BUT ACCEPTABLE

• You’ll be missing features all the time

• Old language, learn to accept it

• Brackets everywhere

• You’ll go crazy for a few weeks• Once you’re over it, development is just like C#• C code in between is messy

Page 7: Obj-C and iOS for .NET Developers

XCODE JUST SUCKS

• Crash Fest

• IDE Helps you very little

• poor code navigation• poor refactoring

• Good to manage project, NIBs and CoreData mappings

• Great performance tool: Instruments

Page 8: Obj-C and iOS for .NET Developers

JETBRAINS APPCODE

Beautiful code development

• Doesn’t do everything, but it’s great at what it does

If you’re used to Resharper, you’ll feel at home

Still in beta, so buggy at times

• http://www.jetbrains.com/objc/

Page 9: Obj-C and iOS for .NET Developers

OBJ-CCreated in the early 80's, by StepStone

• Adds Smalltalk-like messaging to C

Steve Jobs/NeXT in 88

• added Obj-C compiler support to GCC in 88• uses it to create NeXTStep

Apple acquires NeXT in '96 and builds OSX

Page 11: Obj-C and iOS for .NET Developers

OBJECT ORIENTED

Just like C#

• Classes, Objects, Constructors• Class methods, instance methods

• No private methods, no class variables

• Brackets, brackets, brackets!

• Alloc/init vs Constructors

• “id” is a pointer to any Obj-C object

Demo

Page 12: Obj-C and iOS for .NET Developers

DYNAMIC LANGUAGE

Pointers always used to pass objects around.

Types is used to assist compiler/tools

Message Passing, not method invocation

• Think of every object as a Dictionary of methods• Extremely simple Reflection• Slower than C++, but still really fast

Messages can be executed in a different thread

Messages can be forwarded to other objects

Method swizzling – change implementations at runtime

Page 13: Obj-C and iOS for .NET Developers

MORE FEATURES

Categories == Extension methods

Protocols == kind of like interfaces

• @optional and @required

Properties

• every class becomes a dictionary• Convention allows dot notation - KVC

Blocks == lambda expressions

NSPredicates ~= LINQ, but ugly

Page 14: Obj-C and iOS for .NET Developers

MORE FEATURES

Key Value Coding

• Allows simple dot notation for properties:

• -(id) valueForUndefinedKey:(NSString *)key {}

Page 15: Obj-C and iOS for .NET Developers

KEY VALUE OBSERVING

Every object contains an observer pattern

Page 16: Obj-C and iOS for .NET Developers

MEMORY MANAGEMENT

GC, but only in OSX

Manual reference counting

• [obj retain]• [obj release]• [obj autorelease] - autorelease pools

ARC - Automatic Reference Counting

• Solution for GC envy• smart compiler can do exactly what you would do

manually• __block, __weak, __strong

Page 17: Obj-C and iOS for .NET Developers

COCOA TOUCH

Based on OSX Cocoa, but not the same

Frameworks to allow apps to run on iOS:

• UIKit, CoreAnimation, OpenAL, MediaLibrary• CoreAudio, Quartz2D, OpenGL, Address Book• Core Location, MapKit, StoreKit, Bonjour, WebKit• BSD Sockets, AV Foundation

Page 18: Obj-C and iOS for .NET Developers

UIKIT

Pretty much anything related to the screen:

• Displaying pixels• Handling user input• High level components, like tables, entry fields etc• Orientation, rotation

MVC-based framework to deal with UI

Demo

NIBs - WYSIWYG Editor

Demo

Page 19: Obj-C and iOS for .NET Developers

CORE DATA

Apple’s ORM

Managed object graph that can be persisted

• SQLite only for iOS4, Json for new versions

Manages object model versioning

Localization of names and properties

Demo

Page 20: Obj-C and iOS for .NET Developers

NOTES

XCode sucks

• Be prepared for a life of frustration• Use AppCode

ObjC is not bad, get used to it

iOS Frameworks are great

• They’re not simple, but they work really well

Page 21: Obj-C and iOS for .NET Developers

RESOURCES

http://developer.apple.com

• Apple developer Forums• irc.freenode.com #iPhoneDev

https://github.com/languages/Objective-C/most_watched

• Facebook three20• JSONKit• RestKit - great way of accessing RESTful services• QuickDialog – mine

Page 22: Obj-C and iOS for .NET Developers

THANKS!

Eduardo [email protected]

http://escoz.com

http://twitter.com/escoz