Created
September 28, 2012 09:16
-
-
Save graouts/3798828 to your computer and use it in GitHub Desktop.
Launching the iOS Simulator and receiving a notification when it's ready (Node.js)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $ = require('NodObjC'); | |
$.framework('Foundation'); | |
// get the distributed notification center | |
var notificationCenter = $.NSDistributedNotificationCenter('defaultCenter'); | |
// this is the observer and the single method we register as the notification | |
var observer = { | |
receivedNotification : function (notification) { | |
console.log('received notification', notification); | |
} | |
}; | |
// create our selector | |
var selector = $.NSSelectorFromString($('receivedNotification:')); | |
// and the name of the notification we're interested in | |
var name = $('com.apple.iphonesimulator.ready'); | |
// add the observer | |
notificationCenter('addObserver', observer, 'selector', selector, 'name', name, 'object', null); | |
// launch the simulator | |
require('child_process').exec("open -a 'iPhone Simulator'"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@TooTallNate Thanks for the info. I'm having some trouble working out what the parameters to
.addMethod()
should be. Is the first parameter a selector, ie. should it bereceivedNotification:
? Here's what I'm doing right now:What about parameters, how do I let my method receive a parameter? Do I add a third
@
in the second parameter and then name that parameter in the function definition, say like this?