Here's a script that gives an exception with the latest CocoaScript source, but works fine with the latest JSTalk source. Tested on both 10.8.5 and 10.9.1 (I get the exception much later in 10.8, but it's still there). I get:
./build/Debug/coscript loadStoriesList3.js
2014-01-07 16:23:17.717 coscript[54599:507] inited a global class object NSDictionary - going to keep it protected 0x15121fe10
2014-01-07 16:23:17.721 coscript[54599:507] +[__NSCFString _fastCStringContents:]: unrecognized selector sent to class 0x7fff7b9cf3a0
2014-01-07 16:23:17.721 coscript[54599:507] Exception: (null)
+[__NSCFString _fastCStringContents:]: unrecognized selector sent to class 0x7fff7b9cf3a0
var toClass = {}.toString;
var itemDictPath = "/Applications/Xcode.app/Contents/Info.plist";
var itemDict = NSDictionary.dictionaryWithContentsOfFile_(itemDictPath);
var itemList = itemDict["CFBundleDocumentTypes"];
function createStory(item) {
var name = item["CFBundleTypeName"];
var role = item["CFBundleTypeRole"];
NSLog("name class " + name.class() + " length " + name.length());
NSLog("role class " + role.class() + " length " + role.length());
}
for (var i = 0; i < itemList.count(); i++) {
createStory(itemList[i]);
}
Here's a script that gives an exception with the latest CocoaScript source, but works fine with the latest JSTalk source. Tested on both 10.8.5 and 10.9.1 (I get the exception much later in 10.8, but it's still there). I get:
var toClass = {}.toString; var itemDictPath = "/Applications/Xcode.app/Contents/Info.plist"; var itemDict = NSDictionary.dictionaryWithContentsOfFile_(itemDictPath); var itemList = itemDict["CFBundleDocumentTypes"];
function createStory(item) { var name = item["CFBundleTypeName"]; var role = item["CFBundleTypeRole"]; NSLog("name class " + name.class() + " length " + name.length()); NSLog("role class " + role.class() + " length " + role.length()); }
for (var i = 0; i < itemList.count(); i++) { createStory(itemList[i]); }