Thunderbird Extensions Documentation: Wielding the nsIEnumerator
This post deals with the two kinds of enumerators in Mozilla.
Basically,
Here's some code that you can pretend is a
nsISimpleEnumerator is really simple, and there's no reason to talk about that.nsIEnumerator is really bizarre, and although this may seem obvious to everyone else, this might be helpful to anyone who's a little stuck.Basically,
nsIEnumerator runs happily until it crashes.Here's some code that you can pretend is a
while(friendlyAndNice.hasNext()) loop:var keepGoing = 1;
blah
try{
nseSubFolders.first();
}catch(e1){
keepGoing = 0;
}
while(keepGoing == 1){
thing = blah.currentItem();
try{
nseSubFolders.next();
}catch(e2){
keepGoing = 0;
}
}

4 Comments:
At Thursday, August 11, 2005 9:43:00 PM,
Mike Krieger said…
Thank you, thank you, thank you, thank you! Just the thing I was looking for; stupid nsIABDirectory->childCards is a nsIEnumerator and I was tearing my hair out NS_ERROR failures.
Made my day (and saved me another hour of debugging) =)
-MK
At Monday, September 26, 2005 9:17:00 AM,
Anonymous said…
Why calling first()?
This shouldn't be required, if you do are not reprocessing the enumeration.
Something like
for(;;)
{
var next = enum.currentItem();
// do something, but don't miss to check next
try { enum.next(); } catch(ex) { break; }
}
should work fine.
(Sorry for spamming this this old post, but I think a lot of people will take it as a resource... ;))
(hmm... no code/blockquote/pre tags allowed :p)
At Saturday, October 29, 2005 11:05:00 PM,
providian credit card2 said…
This comment has been removed by a blog administrator.
At Friday, November 18, 2005 9:36:00 PM,
job opportunitya said…
Hot blog. When I get to seraching on the web for
blogs, its got to be like yours! And the site is off
the hook! I just kept coming back!
Hey son, you need to check out my cash till payday loan in atlanta ga blog!
Post a Comment
<< Home