Michel Fortin has written a macro for iterating over an NSIndexSet. It looks to be easier and faster than writing your own loop, and also more convenient than using block iteration.
Copy and paste this URL into your WordPress site to embed
Copy and paste this code into your site to embed