README.md in afmotion-0.1 vs README.md in afmotion-0.2
- old
+ new
@@ -50,10 +50,18 @@
placeholder = UIImage.imageNamed "placeholder-avatar"
image_view.url = {url: "http://i.imgur.com/r4uwx.jpg", placeholder: placeholder}
```
+You can also request arbitrary images:
+
+```ruby
+ AFMotion::Image.get("https://www.google.com/images/srpr/logo3w.png") do |result|
+ image_view = UIImageView.alloc.initWithImage(result.object)
+ end
+```
+
## Install
1. `gem install afmotion`
2. `require 'afmotion'` or add to your `Gemfile`
@@ -84,10 +92,11 @@
if result.success?
# result.object depends on the type of operation.
# For JSON and PLIST, this is usually a Hash.
# For XML, this is an NSXMLParser
# For HTTP, this is an NSURLResponse
+ # For Image, this is a UIImage
p result.object
elsif result.failure?
# result.error is an NSError
p result.error.localizedDescription
@@ -107,10 +116,11 @@
- `AFMotion::Operation::HTTP.for_request...`
- `AFMotion::Operation::JSON.for_request...`
- `AFMotion::Operation::XML.for_request...`
- `AFMotion::Operation::PLIST.for_request...`
+- `AFMotion::Operation::Image.for_request...`
### One-off Requests
There are wrappers which automatically run a URL request for a given URL and HTTP method, of the form:
@@ -122,17 +132,18 @@
Example:
```ruby
AFMotion::HTTP.get("http://google.com", q: "rubymotion") do |result|
- # sends request to http://google.com?q=1
+ # sends request to http://google.com?q=rubymotion
end
```
- `AFMotion::HTTP.get/post/put/patch/delete(url)...`
- `AFMotion::JSON.get/post/put/patch/delete(url)...`
- `AFMotion::XML.get/post/put/patch/delete(url)...`
- `AFMotion::PLIST.get/post/put/patch/delete(url)...`
+- `AFMotion::Image.get/post/put/patch/delete(url)...`
### HTTP Client
If you're constantly accesing a web service, it's a good idea to use an `AFHTTPClient`. Things lets you add a common base URL and request headers to all the requests issued through it, like so:
\ No newline at end of file