Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated readme and license

  • Loading branch information...
commit 082ccc9fe43102ab4a633051f935d3fd7a9c69a2 1 parent 3f20602
@soffes soffes authored
Showing with 41 additions and 31 deletions.
  1. +1 −1  LICENSE
  2. +40 −30 Readme.markdown
View
2  LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2010 Sam Soffes
+Copyright (c) 2010-2011 Sam Soffes
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
70 Readme.markdown
@@ -8,54 +8,64 @@ Rails plugin for easily adding a binary plist format. The binary plist format is
Add the following line to your bundle and run `bundle install`.
- gem "binary_plist"
+```ruby
+gem "binary_plist"
+```
## Usage
All you have to do is add the `plist` format to your `respond_to` block:
- def index
- @posts = Post.all
- respond_to do |format|
- format.html
- format.plist { render :plist => @posts }
- end
- end
+```ruby
+def index
+ @posts = Post.all
+ respond_to do |format|
+ format.html
+ format.plist { render :plist => @posts }
+ end
+end
+```
You can do the combined style if you're support multiple formats like `json` or `xml`.
- def index
- @posts = Post.all
- respond_to do |format|
- format.html
- format.any(:json, :plist) { render request.format.to_sym => @posts }
- end
- end
+```ruby
+def index
+ @posts = Post.all
+ respond_to do |format|
+ format.html
+ format.any(:json, :plist) { render request.format.to_sym => @posts }
+ end
+end
+```
## Consuming
On the Objective-C side, it's ridiculously easy to consume the plist data.
- NSURL *url = [NSURL URLWithString:@"http://localhost:3000/posts.plist"];
- NSArray *posts = [NSArray arrayWithContentsOfURL:url];
+```objective-c
+NSURL *url = [NSURL URLWithString:@"http://localhost:3000/posts.plist"];
+NSArray *posts = [NSArray arrayWithContentsOfURL:url];
+```
You can also use the more flexible syntax:
- NSURL *url = [NSURL URLWithString:@"http://localhost:3000/posts.plist"];
- NSDate *date = [NSData dataWithContentsOfURL:url];
- id result = [NSPropertyListSerialization propertyListFromData:data
- mutabilityOption:NSPropertyListImmutable format:NULL errorDescription:nil];
-
- if ([result isKindOfClass:[NSArray class]]) {
- // Handle array response
- } else if ([result isKindOfClass:[NSDictionary class]]) {
- // Handle dictionary response
- } else {
- // Etc...
- }
+```objective-c
+NSURL *url = [NSURL URLWithString:@"http://localhost:3000/posts.plist"];
+NSDate *date = [NSData dataWithContentsOfURL:url];
+id result = [NSPropertyListSerialization propertyListFromData:data
+ mutabilityOption:NSPropertyListImmutable format:NULL errorDescription:nil];
+
+if ([result isKindOfClass:[NSArray class]]) {
+ // Handle array response
+} else if ([result isKindOfClass:[NSDictionary class]]) {
+ // Handle dictionary response
+} else {
+ // Etc...
+}
+```
## Thanks
The encoder is largely based on [Apple Binary Property List serializer](http://gist.github.com/303378).
-Copyright (c) 2010 Sam Soffes, released under the MIT license
+Copyright (c) 2010-2011 Sam Soffes, released under the MIT license
Please sign in to comment.
Something went wrong with that request. Please try again.