Re: CriticalAlert
Re: CriticalAlert
- Subject: Re: CriticalAlert
- From: David Remahl <email@hidden>
- Date: Thu, 20 Dec 2001 23:10:41 +0100
>
On Thursday, December 20, 2001, at 01:36 PM, David Remahl wrote:
>
>
> On the other hand, the following construct is one I use very often in
>
> Cocoa:
>
>
>
> while( myStr = [myEnum nextObject] )
>
> {
>
> // do whatever
>
> }
>
>
>
> That would generate a warning, would it not? And I would have to
>
> manually
>
> disable that warning.
>
>
Out of the box, gcc with Project Builder used to warn about this, if I
>
remember correctly. Now that I check, it doesn't seem to do it anymore,
>
which is unfortunate. (If you add -Wall to your compiler flags, you
>
will get a warning: "suggest parentheses around assignment used as truth
>
value".)
>
>
To avoid the warning, put an extra pair of parens around the
>
expression. That is:
>
>
while ((myStr = [myEnum nextObject]))
>
>
This is a pretty well known idiom. (Like all idioms, it doesn't
>
necessarily make much sense all by itself, though.)
>
I stand corrected. Not sure I will pick up on that idiom, though...
/ rgds, David