Skip to content
This repository has been archived by the owner on Jan 2, 2018. It is now read-only.

Commit

Permalink
Merge pull request rubymotion-community#112 from colinta/master
Browse files Browse the repository at this point in the history
accessing UIApplication.sharedApplication
  • Loading branch information
James Harton committed Jul 22, 2012
2 parents 890df6c + fcc562d commit 34aa9dc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
15 changes: 8 additions & 7 deletions README.md
Expand Up @@ -162,6 +162,7 @@ Other available methods:
* `App.states`
* `App.frame`
* `App.delegate`
* `App.shared`
* `App.current_locale`


Expand Down Expand Up @@ -243,7 +244,7 @@ def viewWillAppear(animated)
@foreground_observer = App.notification_center.observe UIApplicationWillEnterForegroundNotification do |notification|
loadAndRefresh
end

@reload_observer = App.notification_center.observe ReloadNotification do |notification|
loadAndRefresh
end
Expand Down Expand Up @@ -290,7 +291,7 @@ class ExampleViewController < UIViewController
@label = UILabel.alloc.initWithFrame [[20,20],[280,44]]
@label.text = ""
view.addSubview @label

observe(@label, :text) do |old_value, new_value|
puts "Hello from viewDidLoad!"
end
Expand Down Expand Up @@ -498,7 +499,7 @@ feed_parser = BW::RSSParser.new(feed, true)
**Since: > version 1.0.0**

`BubbleWrap::Reactor` is a simplified, mostly complete implementation of
the [Event Machine](http://rubyeventmachine.com/) API. In fact
the [Event Machine](http://rubyeventmachine.com/) API. In fact
`BubbleWrap::Reactor` is aliased to `EM` in the runtime environment.

### Deferables
Expand Down Expand Up @@ -588,11 +589,11 @@ Great scott!

### Scheduling operations

You can use `EM.schedule` to schedule blocks to be executed
You can use `EM.schedule` to schedule blocks to be executed
asynchronously. BubbleWrap deviates from the EventMachine
API here in that it also provides `EM.schedule_on_main` which
makes sure that the task is run asynchronously, but on the
application's main thread - this is necessary if you are
makes sure that the task is run asynchronously, but on the
application's main thread - this is necessary if you are
updating the user interface.

```ruby
Expand All @@ -607,7 +608,7 @@ updating the user interface.
### Deferrable operations

You can also use `EM.defer` in much the same way as `EM.schedule`
with one important difference, you can pass in a second `proc`
with one important difference, you can pass in a second `proc`
which will be called when the first has completed, and be passed
it's result as an argument. Just like `EM.schedule`, `EM.defer`
also has an `EM.defer_on_main` version.
Expand Down
5 changes: 5 additions & 0 deletions motion/core/app.rb
Expand Up @@ -105,6 +105,11 @@ def delegate
UIApplication.sharedApplication.delegate
end

# the Application object.
def shared
UIApplication.sharedApplication
end

# @return [NSLocale] locale of user settings
def current_locale
languages = NSLocale.preferredLanguages
Expand Down
6 changes: 6 additions & 0 deletions spec/motion/core/app_spec.rb
Expand Up @@ -176,6 +176,12 @@
end
end

describe '.app' do
it 'returns UIApplication.sharedApplication' do
BW::App.shared.should == UIApplication.sharedApplication
end
end

describe '.run_after' do
class DelayedRunAfterTest; attr_accessor :test_value end

Expand Down

0 comments on commit 34aa9dc

Please sign in to comment.