Re: NSEnumerator doesn't support NSCopying - why?
Re: NSEnumerator doesn't support NSCopying - why?
- Subject: Re: NSEnumerator doesn't support NSCopying - why?
- From: Manfred Lippert <email@hidden>
- Date: Tue, 17 Feb 2004 14:03:33 +0100
I'm trying to iterate through an array in the following way:
outerEnumerator = [objects objectEnumerator];
while (a = [outerEnumerator nextObject]) {
innerEnumerator = [outerEnumerator copy];
while (b = [innerEnumerator nextObject]) {
// do stuff here
}
}
Now, that'd be fantastic if NSEnumerator supported NSCopying. As is
it raises an NSInvalidArgumentException (originating in
copyWithZone:).
You could try the following, if the order of working on the elements is
not important:
outerEnumerator = [objects objectEnumerator];
while (a = [outerEnumerator nextObject]) {
innerEnumerator = [objects reverseObjectEnumerator];
while (b = [innerEnumerator nextObject]) {
// do stuff here
if (a == b) {
break;
}
}
}
(untested)
Regards,
Mani
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.