Re: Return acting like break in XCode 3.2.2
Re: Return acting like break in XCode 3.2.2
- Subject: Re: Return acting like break in XCode 3.2.2
- From: Greg Guerin <email@hidden>
- Date: Tue, 25 May 2010 07:05:23 -0700
Andrei Freeman wrote:
Given the following code: (Please note there are some pseudocode
liberties taken)
NSArray *myArray = somePre-established array;
NSString *aString = nil;
NSEnumerator *anEnum = [myArray objectEnumerator];
while ((aString = [anEnum nextObject])) {
if ([aString isEqualToString:@StringThatMatchesObjectIndex(0)]) {
return aString;
}
return nil;
Maybe it's one of your pseudo-code liberties, or maybe it's a real
bug, but you have two open braces '{' in the code, yet only one close-
brace '}'. As a result, the return nil; statement is in the body of
the while loop and will always be executed when the body of the if
statement is not.
Your second code fragment has the same problem.
Consider posting real code instead of pseudo-code. One problem with
pseudo-code is no one knows if it will compile. Compilation would
probably show a syntax error with a missing brace. But without
knowing which parts of what you posted are real and which are pseudo,
all anyone can do is guess.
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden