Better support for recursing in CPDictionaryWithJSObject:

This commit is contained in:
Ross Boucher committed 2009-12-20 20:32:17 -05:00
1 parent 5bbf893a37
commit cb1cfa4d94
1 file changed
+25 -4
+25 -4
View File
@@ -148,11 +148,32 @@
for (var key in object)
{
if (!object.hasOwnProperty(key))
continue;
var value = object[key];
if (recursively && value.constructor === Object)
value = [CPDictionary dictionaryWithJSObject:value recursively:YES];
if (recursively)
{
if (value.constructor === Object)
value = [CPDictionary dictionaryWithJSObject:value recursively:YES];
else if ([value isKindOfClass:CPArray])
{
var newValue = [];
for (var i = 0, count = value.length; i < count; i++)
{
var thisValue = value[i];
if (thisValue.constructor === Object)
newValue.push([CPDictionary dictionaryWithJSObject:thisValue recursively:YES]);
else
newValue.push(thisValue);
}
value = newValue;
}
}
[dictionary setObject:value forKey:key];
}
@@ -609,7 +630,7 @@
@end
objj_dictionary.prototype.isa = CPDictionary;
objj_bundle.prototype.toString = function()
objj_dictionary.prototype.toString = function()
{
return [this description];
}