better description
This commit is contained in:
parent
d18fa7d38e
commit
9363d5fdb5
1 changed files with 21 additions and 7 deletions
28
README
28
README
|
@ -1,12 +1,17 @@
|
||||||
Plistifier
|
Plistifier
|
||||||
==========
|
==========
|
||||||
|
|
||||||
Adds the ActiveRecord#to_plist and Array#to_plist methods similar to ActiveRecord#to_xml.
|
Adds the possibility to talk to a rails app via (Binary) Property Lists
|
||||||
The :only, :except, :methods, and :include options are supported. Additionally you can use
|
http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man5/plist.5.html
|
||||||
the :plist_filename option to change the default name for download.
|
|
||||||
|
It is designed to work as the JSON format but on the iPhone it is easier to use,
|
||||||
|
much faster, because Plist is smaller, therefore it doesn't need any third party
|
||||||
|
libraries for parsing like JSON, or difficult SAX-style parsing like XML.
|
||||||
|
|
||||||
|
It adds the ActiveRecord#to_plist, Array#to_plist and Hash#to_plist methods similar to
|
||||||
|
ActiveRecord#to_json. The :only, :except, :methods, and :include options are supported
|
||||||
|
on ActiveRecord and Array with ActiveRecord items.
|
||||||
|
|
||||||
It too ads the :plist option to the ActiveRecord::Base#render method. With help of that
|
|
||||||
you get binary plist files which you can easy use in your iPhone.
|
|
||||||
|
|
||||||
Install
|
Install
|
||||||
=======
|
=======
|
||||||
|
@ -17,6 +22,9 @@ script/plugin install git://github.com/jeena/plistifier.git
|
||||||
Example
|
Example
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
Getting data from rails
|
||||||
|
-----------------------
|
||||||
|
|
||||||
In your PostController use for example:
|
In your PostController use for example:
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -54,14 +62,15 @@ On the iPhone use for example:
|
||||||
NSLog(@"Title: %@", [[posts objectAtIndex:0] objectForKey:@"title"]);
|
NSLog(@"Title: %@", [[posts objectAtIndex:0] objectForKey:@"title"]);
|
||||||
|
|
||||||
|
|
||||||
|
Sending data to rails
|
||||||
|
---------------------
|
||||||
|
|
||||||
It is possible to send a plist back into rails. On the iPhone you have to do for example:
|
It is possible to send a plist back into rails. On the iPhone you have to do for example:
|
||||||
|
|
||||||
NSDictionary *aPost = [[NSDictionary alloc] initWithObjectsAndKeys:
|
NSDictionary *aPost = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||||
@"A title", @"title",
|
@"A title", @"title",
|
||||||
@"Some text for body", @"body", nil];
|
@"Some text for body", @"body", nil];
|
||||||
|
|
||||||
NSDictionary *aDict = [[NSDictionary alloc] initWithObjectsAndKeys:aPost, @"post", nil];
|
NSDictionary *aDict = [[NSDictionary alloc] initWithObjectsAndKeys:aPost, @"post", nil];
|
||||||
|
|
||||||
NSData *data = [NSPropertyListSerialization dataFromPropertyList:aDict
|
NSData *data = [NSPropertyListSerialization dataFromPropertyList:aDict
|
||||||
format:NSPropertyListBinaryFormat_v1_0
|
format:NSPropertyListBinaryFormat_v1_0
|
||||||
errorDescription:nil];
|
errorDescription:nil];
|
||||||
|
@ -73,6 +82,11 @@ It is possible to send a plist back into rails. On the iPhone you have to do for
|
||||||
[request setHTTPBody:data];
|
[request setHTTPBody:data];
|
||||||
|
|
||||||
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
|
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
|
||||||
|
[connection release];
|
||||||
|
[request release];
|
||||||
|
[data release];
|
||||||
|
[aDict release];
|
||||||
|
[aPost release];
|
||||||
|
|
||||||
And on the rails side:
|
And on the rails side:
|
||||||
|
|
||||||
|
|
Reference in a new issue