I have a NSEnumerator object with the text lines retrieved from a NSTextView, parsed with:
NSEnumerator *myLines = [[allTheText componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] objectEnumerator];
I'm processing the lines inside a for cycle like this:
for (NSString *current_line in myLines)
{
//doing something
}
This works fine, but now I need to watch the next object while processing the current one. What would be the best way to do this without disrupting the current cycle? If I do something like this (inside the current cycle), it won't work:
//inside the previous cycle
NSString *next_line;
if (next_line = [myLines nextObject])
{
//process next line
}
You can use standard for loop:
You'd be able to get previous and next lines be using iteration index:
Make sure to check for their existence first.
update
Use array above in the for loop.