README.md in bubble-wrap-1.3.0 vs README.md in bubble-wrap-1.4.0
- old
+ new
@@ -79,10 +79,22 @@
```ruby
require 'bubble-wrap/media'
```
+If you wish to only include the `Mail` wrapper:
+
+```ruby
+require 'bubble-wrap/mail'
+```
+
+If you wish to only include the `SMS` wrapper:
+
+```ruby
+require 'bubble-wrap/sms'
+```
+
If you want to include everything (ie kitchen sink mode) you can save time and do:
```ruby
require 'bubble-wrap/all'
```
@@ -205,10 +217,12 @@
# true
> Device.camera.rear?
# true
> Device.orientation
# :portrait
+> Device.interface_orientation
+# :portrait
> Device.simulator?
# true
> Device.ios_version
# "6.0"
> Device.retina?
@@ -244,11 +258,11 @@
end
```
### JSON
-`BW::JSON` wraps `NSJSONSerialization` available in iOS5 and offers the same API as Ruby's JSON std lib.
+`BW::JSON` wraps `NSJSONSerialization` available in iOS5 and offers the same API as Ruby's JSON std lib. For apps building for iOS4, we suggest a different JSON alternative, like [AnyJSON](https://github.com/mattt/AnyJSON).
```ruby
BW::JSON.generate({'foo => 1, 'bar' => [1,2,3], 'baz => 'awesome'})
=> "{\"foo\":1,\"bar\":[1,2,3],\"baz\":\"awesome\"}"
BW::JSON.parse "{\"foo\":1,\"bar\":[1,2,3],\"baz\":\"awesome\"}"
@@ -269,22 +283,22 @@
def viewWillAppear(animated)
@foreground_observer = App.notification_center.observe UIApplicationWillEnterForegroundNotification do |notification|
loadAndRefresh
end
- @reload_observer = App.notification_center.observe ReloadNotification do |notification|
+ @reload_observer = App.notification_center.observe 'ReloadNotification' do |notification|
loadAndRefresh
end
end
def viewWillDisappear(animated)
App.notification_center.unobserve @foreground_observer
App.notification_center.unobserve @reload_observer
end
def reload
- App.notification_center.post ReloadNotification
+ App.notification_center.post 'ReloadNotification'
end
```
### NSUserDefaults
@@ -300,10 +314,12 @@
``` ruby
> App::Persistence['channels'] # application specific persistence storage
# ['NBC', 'ABC', 'Fox', 'CBS', 'PBS']
> App::Persistence['channels'] = ['TF1', 'France 2', 'France 3']
# ['TF1', 'France 2', 'France 3']
+> App::Persistence.delete('channels')
+# ['TF1', 'France 2', 'France 3']
> App::Persistence['something__new'] # something previously never stored
# nil
```
### Observers
@@ -384,10 +400,54 @@
# Plays in an independent modal controller
BW::Media.play_modal("http://www.hrupin.com/wp-content/uploads/mp3/testsong_20_sec.mp3")
```
+## Mail
+
+Wrapper for showing an in-app mail composer view.
+
+```ruby
+# Opens as a modal in the current UIViewController
+BW::Mail.compose {
+ delegate: self, # optional, defaults to rootViewController
+ to: [ "tom@example.com" ],
+ cc: [ "itchy@example.com", "scratchy@example.com" ],
+ bcc: [ "jerry@example.com" ],
+ html: false,
+ subject: "My Subject",
+ message: "This is my message. It isn't very long.",
+ animated: false
+} do |result, error|
+ result.sent? # => boolean
+ result.canceled? # => boolean
+ result.saved? # => boolean
+ result.failed? # => boolean
+ error # => NSError
+end
+```
+
+## SMS
+
+Wrapper for showing an in-app message (SMS) composer view.
+
+```ruby
+# Opens as a modal in the current UIViewController
+ BW::SMS.compose (
+ {
+ delegate: self, # optional, will use root view controller by default
+ to: [ "1(234)567-8910" ],
+ message: "This is my message. It isn't very long.",
+ animated: false
+ }) {|result, error|
+ result.sent? # => boolean
+ result.canceled? # => boolean
+ result.failed? # => boolean
+ error # => NSError
+ }
+```
+
## UI
### Gestures
Extra methods on `UIView` for working with gesture recognizers. A gesture recognizer can be added using a normal Ruby block, like so:
@@ -569,10 +629,24 @@
A `:download_progress` option can also be passed. The expected object
would be a Proc that takes two arguments: a float representing the
amount of data currently received and another float representing the
total amount of data expected.
+Connections can also be cancelled. Just keep a refrence,
+
+```ruby
+@conn = BW::HTTP.get("https://api.github.com/users/mattetti") do |response|
+ p response.body.to_str
+end
+```
+
+and send the `cancel` method to it asynchronously as desired. The block will not be executed.
+
+```ruby
+@conn.cancel
+```
+
### Gotchas
Because of how RubyMotion currently works, you sometimes need to assign objects as `@instance_variables` in order to retain their callbacks.
For example:
@@ -647,9 +721,15 @@
p "The parser started parsing the document"
end
def when_parser_is_done
p "The feed is entirely parsed, congratulations!"
+end
+
+def when_parser_errors
+ p "The parser encountered an error"
+ ns_error = feed_parser.parserError
+ p ns_error.localizedDescription
end
```
These delegate methods are optional, however, you might find the
`when_parser_is_done` callback useful if you collected all the items and