Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enumerator



There is an enumerator in JavaScript

for (var i in array/object)
{
}

and that works with sparse arrays too.

Michael

On 21.12.2005, at 18:21, Darin Adler wrote:

On Dec 20, 2005, at 10:58 AM, Michael Hanna wrote:

I've learned that Enumerator is not present in Safari's implementation of JavaScript. Is there a way to fake it?

I have to implement something like this:

for (var objEnum = new Enumerator(axmlRegExp); !objEnum.atEnd(); objEnum.moveNext())
{
// ...do stuff to objEnum
}


I was thinking adding a definition for a JS Object to the DOM, and in that function/JS class declaration call the objective-c world and make an NSEnumerator there, and 'shadow' objEnum.moveNext() and use (object != [enumerator nextObject]) for objEnum.atEnd().. Just ideas. Is this even possible at all? Any possible caveats?

To enumerate an array you can probably just use standard indexing from 0 to length. No need for something fancy like what you're talking about here.


    -- Darin

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webkitsdk-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webkitsdk-dev/email@hidden

This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webkitsdk-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webkitsdk-dev/email@hidden

This email sent to email@hidden
References: 
 >Enumerator (From: Michael Hanna <email@hidden>)
 >Re: Enumerator (From: Darin Adler <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.