NSDictionary and JSCocoa

18 views
Skip to first unread message

Corey

unread,
Nov 4, 2011, 7:59:38 PM11/4/11
to JSCocoa
If I open a plist via JSCocoa like this:

dict = OSX.NSDictionary.dictionaryWithContentsOfFile("some.plist")

I can access `dict` just fine. But if there is an NSArray of NSStrings
inside that dictionary I run into some problems.

result = dict.myArrayOfStrings.indexOf("myString")

The array of strings returned are boxed(unboxed?) NSString objects. So
I can't compare the javascript string to the strings in
dict.arrayOfString without create a new array and calling toValue() on
each element. This isn't that big of a deal, but I seem to be calling
toValue() a lot.

Is there a method that recessively boxes values in containers
(NSArray and NSDictionary)? If not, any tips on how I could go about
writing something like that?

Patrick Geiller

unread,
Nov 6, 2011, 5:50:22 AM11/6/11
to jsc...@googlegroups.com
> Is there a method that recessively boxes values in containers
> (NSArray and NSDictionary)? If not, any tips on how I could go about
> writing something like that?

I've added .toJS() to convert ObjC values to Javascript.

dict = OSX.NSDictionary.dictionaryWithContentsOfFile("some.plist")

var jsDict = __jsc__.toJS(dict)

-Patrick

Reply all
Reply to author
Forward
0 new messages