TooTallNate / NodObjC

The Node.js ⇆ Objective-C bridge

Home Page:http://tootallnate.github.io/NodObjC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NodObjC with systemConfiguration Framework

tahasiddiqui123 opened this issue · comments

I want to use the native systemConfiguration Objective C framework but its not working

var $ = require('nodobjc');
$.framework('systemConfiguration');
var pool = $.NSAutoreleasePool('alloc')('init');
var string = $.SCPreferencesRef('SCPreferencesCreate', 'NULL','NULL','NULL');
console.log(string);
pool('drain');

it gives the following error.

var string = $.SCPreferencesRef('SCPreferencesCreate', 'NULL','NULL','NULL');
               ^

TypeError: $.SCPreferencesRef is not a function
    at Object.<anonymous> (/Users/tahasiddiqui/Desktop/untitled3/NodOBj.js:4:16)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.runMain [as _onTimeout] (module.js:447:10)
    at Timer.listOnTimeout (timers.js:92:15)

Try something like this:

var $ = require('nodobjc');
$.framework('CoreFoundation');
$.framework('systemConfiguration');

var pool = $.NSAutoreleasePool('alloc')('init');

var name = $.CFStringCreateWithCString(null, process.title, $.kCFStringEncodingUTF8);
var prefs = $.SCPreferencesCreate(null, name, null);
console.log(prefs);

pool('drain');