iPhone and Rails integration

3,263 views
3,193 views

Published on

ObjectiveResource is an Objective-C port of Ruby on Rails' ActiveResource. It provides a way to serialize objects to and from Rails' standard RESTful web-services (via XML or JSON) and handles much of the complexity involved with invoking web-services of any language from the iPhone.
This talk shows you how easy it is to create a 2-way communication channel between a very basic Rails application and an iPhone app.

Published in: Technology, News & Politics
2 Comments
4 Likes
Statistics
Notes
No Downloads
Views
Total views
3,263
On SlideShare
0
From Embeds
0
Number of Embeds
258
Actions
Shares
0
Downloads
57
Comments
2
Likes
4
Embeds 0
No embeds

No notes for slide
  • iPhone and Rails integration

    1. 1. iP[od|hone|ad] & the tubes Paul Ardeleanu
    2. 2. Why? 75m devices to date (iPhone + iPod touch) 140k iPhone apps available 3bn downloads in 18 months Average user spends $8/month There will be a second gold rush Your MD will love it
    3. 3. No really, why? Objects are everywhere (NSObject) MVC framework Extremely consistent API Extremely good documentation Easy to pick up
    4. 4. Challenges Methods syntax Selectors Memory management (no garbage collection) Autorelease Delegates
    5. 5. Exchange data NSURLRequest XML NSURLConnection JSON NSString *url = [NSString stringWithFormat:@"%@%@", @"https://websi.te/contacts.xml", self.path]; NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data - (void)connectionDidFinishLoading:(NSURLConnection *)connection - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
    6. 6. Objective Resource iphoneonrails.com Objective-C port of Ruby on Rails' ActiveResource
    7. 7. Demo
    8. 8. Configuration //Set the address of the rails site. The trailing slash is required [ObjectiveResourceConfig setSite:@"http://localhost:3000/"]; //Set the username and password to be used for the remote site [ObjectiveResourceConfig setUser:@"remoteResourceUserName"]; [ObjectiveResourceConfig setPassword:@"remoteResourcePassword"]; [ObjectiveResourceConfig setResponseType:XmlResponse];
    9. 9. Model @interface Conference : NSObject { NSString *conferenceId; NSString *name; NSString *location; NSString *startDate; } @property (nonatomic , copy) NSString *conferenceId; @property (nonatomic , copy) NSString *name; @property (nonatomic , copy) NSString *location; @property (nonatomic , copy) NSString *startDate; @end
    10. 10. Model @implementation Conference @synthesize conferenceId; @synthesize name; @synthesize location; @synthesize startDate; - (void)dealloc { [conferenceId release]; [name release]; [location release]; [startDate release]; [super dealloc]; } @end
    11. 11. Remote methods [Conference findAllRemote]; Conference *conf = [[Conference alloc] init]; [conf saveRemote]; [conf findRemote:45]; [conf updateRemote]; [conf destroyRemote];
    12. 12. Thank you! Paul Ardeleanu hello24.com twitter.com/hello24com demo projects available for download at hello24.com

    ×