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: Quincey Morris <email@hidden>
- Date: Mon, 24 May 2010 21:19:12 -0700
On May 24, 2010, at 20:16, Andrei Freeman wrote:
> while ((aString = [anEnum nextObject])) {
> if ([aString isEqualToString:@StringThatMatchesObjectIndex(0)]) {
> return aString;
> }
> return nil;
>
> This was working fine before I changed some random code elsewhere in the program. Afterwards the "return aString " turned into a 'break'
>
> The program counter definitely was doing a successful compare and hitting the return. But then the program counter was simply breaking from the loop and then hitting the return nil;
Were you trying to step through this code when you saw the problem? The compiler often generates code generation for return statements, even when optimizations are turned off, that branches to a common exit point. In earlier versions of Xcode, this generally puts you at the method's closing brace, but I've noticed that in the latest version, it typically puts you at some other return statement (and occasionally at the last non-return statement, when the method doesn't end with an explicit return).
This means there are cases where it's hard to follow *which* return statement is really getting used, and putting a breakpoint on one return statement can cause a break on them all.
Did you check to see whether the return value was actually nil?
_______________________________________________
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