SlideShare a Scribd company logo
MY ADVENTURES IN
   OBJECTIVE-C
@abdels / @thesupertimes
Objective-C sucks!
Its just as crappy as Java!
I’m waiting for MacRuby!
OH NO!!
still no iOS support, Boll@@ks!
Objective-C Haters!
Solutions
PhoneGap
Titanium Appcelerator
But really, why all the hating?
That’s pride f**king with you. F**k pride.
Pride only hurts. It never helps. You fight
            through that sh*t!
My Adventures In Objective-C (A Rubyists Perspective)
So, here's what I Learnt,
SMALL TALK GUY (ALAN KAY)
Objective-C, is reflective, OO,
        Smalltalk-ish!
Sound a lot like Ruby
Unlike Ruby,
Objective-C is a strict superset of C
Object Message passing :
Obj-C
[world say:@"hello"];


Ruby
world.say("hello")
Object Message passing :

Obj-C
[world say:@"hello"];

[world performSelector:@selector(say:) withObject:@"hello"]

objc_sendMsg(id object, SEL selector)
Object Message passing :

Ruby
world.send(:say, "hello")
Non-strict typing (Duck Typing?)
Obj-C
id world = [[World alloc] init];
[world peace];


Here 'id' is a pointer to any object.
Non-strict typing (Duck Typing?)
Obj-C
World *world = [[World alloc] init];
[world peace];

This ensures method compiler checks!
Object declaration
Obj-C
MyClass * myObject = [[MyClass alloc] init];


Ruby (pseudo code)
class Object
	

 def self.new(*args)
	

 	

 self.alloc.initialize(*args)
	

 end
end
Interface/Implementation (the C thing)
world.h (header file)
#import <UIKit/UIKit.h>

@interface World : NSObject {
  NSString *foo;
}

@property (copy, retain) NSString *foo;

-(NSString *) say:(NSString *)something;
@end
Interface/Implementation (the C thing)
world.m (implementation file)
#import "world.h"

@implementation World
@synthesize foo;

-(NSString *) say:(NSString *)something{}

- (void)dealloc {
  [foo release];
  [super dealloc];
}
@end
Properties aka attr_accessor
@interface World : NSObject {
 NSString *foo;
 ...
 @property (copy, retain) NSString *foo;
 ...
@end

@implementation World
@synthesize foo;
...
@end
Properties aka attr_accessor
@synthesize: creates dynamic setters and getters and
performs the necessary memory allocation.

-(void)setFoo:(Foo *)s {
	

 if(foo != s) {
	

 	

 [foo release];
	

 	

 foo = [s retain];
	

 }
}

-(Foo *)foo { return foo; }
Interfaces with Protocols
@protocol Shopper
- (void)recession;
- (void)boom;
@end

@interface World : NSObject <Shopper>
@end
Monkey Patching with Categories
UIImage+RoundedCorner.h
@interface UIImage (RoundedCorner)
- (UIImage *)roundedCornerImage;
@end

UIImage+RoundedCorner.m
@implementation UIImage
(RoundedCorner)
- (UIImage *)roundedCornerImage {
  //Make rounded corners
}
@end
We Have Blocks!
NSArray *films = [NSArray arrayWithObjects:@"Reservoir
Dogs", @"Pulp Fiction", @"Kill Bill", nil];

[films enumerateObjectsUsingBlock:^(id object, NSUInteger
index, BOOL *stop) {
    NSLog(@"%@ film at index %d", object, index);
}];
We Have Blocks!
int (^negative)(int) = ^(int number) {
   return number * -1;
};

int result = negative(2);
Basics over
You panicked, but don’t
iOS is a powerful platform that
        controls phones
Your brain & eyes hurting is a small
 price to pay for the privelage :P
REFERENCES
  HTTP://EN.WIKIPEDIA.ORG/WIKI/OBJECTIVE-C


  HTTP://EN.WIKIPEDIA.ORG/WIKI/MACRUBY


  HTTP://OFPS.OREILLY.COM/TITLES/9781449380373/INDEX.HTML


  HTTP://BLOG.PHUSION.NL/2010/03/24/OBJECTIVE-C-FOR-RUBY-DEVELOPERS-
  UN-NOT-SO-PETIT-INTERLUDE-1/


  HTTP://GOSHAKKK.NAME/BLOG/2011/08/19/OBJECTIVE-C-RUBYISTS-INSIGHT/


  HTTP://GOOGLE-STYLEGUIDE.GOOGLECODE.COM/SVN/TRUNK/
  OBJCGUIDE.XML
@abdels / @thesupertimes

More Related Content

PDF
Simple ETL in Python 3.5+ - PolyConf Paris 2017 - Lightning Talk (10 minutes)
KEY
ISUCONアプリを Pythonで書いてみた
ZIP
Ruby Kaigi 2008 LT
PDF
Jakub Kulhán - ReactPHP + Symfony = PROFIT (1. sraz přátel Symfony v Praze)
PDF
Ruby 2.0
PDF
Go初心者がGoでコマンドラインツールの作成に挑戦した話
PDF
My Robot Poops - In JavaScript (with web sockets)
PDF
The Perl API for the Mortally Terrified (beta)
Simple ETL in Python 3.5+ - PolyConf Paris 2017 - Lightning Talk (10 minutes)
ISUCONアプリを Pythonで書いてみた
Ruby Kaigi 2008 LT
Jakub Kulhán - ReactPHP + Symfony = PROFIT (1. sraz přátel Symfony v Praze)
Ruby 2.0
Go初心者がGoでコマンドラインツールの作成に挑戦した話
My Robot Poops - In JavaScript (with web sockets)
The Perl API for the Mortally Terrified (beta)

What's hot (19)

PDF
구름 이야기(Feat. gcp) - 구글클라우드(GCP) 활용 사례
PDF
Make Your Own Perl with Moops
PPT
Introduction to Ruby, Rails, and Ruby on Rails
PDF
EuroPython 2017 - Bonono - Simple ETL in python 3.5+
PPTX
Non-Relational Databases
KEY
Node.js
KEY
Mojo as a_client
PDF
Interceptors: Into the Core of Pedestal
KEY
Keeping it small: Getting to know the Slim micro framework
PPTX
iSoligorsk #3 2013
PDF
Voyage by example
KEY
UPenn on Rails pt 2
PDF
Ruby is an Acceptable Lisp
PDF
Trading with opensource tools, two years later
PDF
Converting your JS library to a jQuery plugin
KEY
Your Library Sucks, and why you should use it.
PDF
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
PDF
"Lego Programming" with Lorzy
PDF
구름 이야기(Feat. gcp) - 구글클라우드(GCP) 활용 사례
Make Your Own Perl with Moops
Introduction to Ruby, Rails, and Ruby on Rails
EuroPython 2017 - Bonono - Simple ETL in python 3.5+
Non-Relational Databases
Node.js
Mojo as a_client
Interceptors: Into the Core of Pedestal
Keeping it small: Getting to know the Slim micro framework
iSoligorsk #3 2013
Voyage by example
UPenn on Rails pt 2
Ruby is an Acceptable Lisp
Trading with opensource tools, two years later
Converting your JS library to a jQuery plugin
Your Library Sucks, and why you should use it.
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
"Lego Programming" with Lorzy
Ad

Similar to My Adventures In Objective-C (A Rubyists Perspective) (20)

KEY
Objective-C & iPhone for .NET Developers
PDF
Origins of Elixir programming language
KEY
RubyMotion
PDF
MacRuby & RubyMotion - Madridrb May 2012
KEY
iOS Einführung am Beispiel von play NEXT TEE
PPTX
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
PPTX
Corinna-2023.pptx
PDF
Swift, functional programming, and the future of Objective-C
PDF
Iphone course 1
PDF
Three Objectionable Things
PPTX
CoreOS in a Nutshell
KEY
Onsg11 iphone
PDF
Having Fun Programming!
KEY
Mac ruby to the max - Brendan G. Lim
ZIP
MacRuby to The Max
PDF
Ruby seen from a C# developer
PDF
Ruby seen by a C# developer
PDF
iOS 2 - The practical Stuff
PDF
JavaScript for PHP developers
PDF
ESWHO, ESWHAT, ESWOW -- FEDucation -- IBM Design
Objective-C & iPhone for .NET Developers
Origins of Elixir programming language
RubyMotion
MacRuby & RubyMotion - Madridrb May 2012
iOS Einführung am Beispiel von play NEXT TEE
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Corinna-2023.pptx
Swift, functional programming, and the future of Objective-C
Iphone course 1
Three Objectionable Things
CoreOS in a Nutshell
Onsg11 iphone
Having Fun Programming!
Mac ruby to the max - Brendan G. Lim
MacRuby to The Max
Ruby seen from a C# developer
Ruby seen by a C# developer
iOS 2 - The practical Stuff
JavaScript for PHP developers
ESWHO, ESWHAT, ESWOW -- FEDucation -- IBM Design
Ad

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPT
Teaching material agriculture food technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Modernizing your data center with Dell and AMD
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
KodekX | Application Modernization Development
PPTX
Big Data Technologies - Introduction.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
A Presentation on Artificial Intelligence
Unlocking AI with Model Context Protocol (MCP)
Agricultural_Statistics_at_a_Glance_2022_0.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Spectral efficient network and resource selection model in 5G networks
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Teaching material agriculture food technology
Review of recent advances in non-invasive hemoglobin estimation
Modernizing your data center with Dell and AMD
NewMind AI Monthly Chronicles - July 2025
Understanding_Digital_Forensics_Presentation.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Digital-Transformation-Roadmap-for-Companies.pptx
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
KodekX | Application Modernization Development
Big Data Technologies - Introduction.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
A Presentation on Artificial Intelligence

My Adventures In Objective-C (A Rubyists Perspective)

Editor's Notes