I'm trying to find a matching object in a tree, so I'm using ObjC fast enumeration. The problem is my method finds the matching value, hits the return line, and then sets the value to nil and keeps on iterating. Here's my method:
+ (INONode *)findByUUID:(NSString*)uuid fromRootNode:(INONode*)node
{
for (INONode * childNode in [node children]) {
if ([[node uniqueID] isEqualToString:uuid]) {
break;
}
else {
[INONode findByUUID:uuid fromRootNode:childNode];
}
}
return node;
}
When I follow code execution by setting a breakpoint, the break is hit, then goes to the return line, then back up to the statement that continues the iteration. What am I missing here?