• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Thoughts on CodeWarrior 8 for Cocoa programming?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thoughts on CodeWarrior 8 for Cocoa programming?


  • Subject: Re: Thoughts on CodeWarrior 8 for Cocoa programming?
  • From: Jim Correia <email@hidden>
  • Date: Wed, 12 Jun 2002 05:29:45 -0400

On Wednesday, June 12, 2002, at 03:24 AM, Thomas Deniau wrote:

- You get a warning on, in -init, if (self = [super init]) . Very
frustrating (of course you can suppress it, but it's enabled by default).

The possible unwanted assignment warning has saved my bacon several times. I think leaving the warning on (and explicitly turning it on in Project Builder/gcc) is a wise idea.

One habit you can get into is to write

if (result = noErr)
{
// do work
}

as

if (noErr = result)
{
// do work
}

then the assignment cannot take place accidently. You'll get a not an lvalue error. If you write the first form, you'll get the possible unwanted assignment warning.

You can write your code in such a way that you can be explicit about the assignment and avoid the warning.

if (noErr == (result = CallSomeFunction()))
{

}

or

if ( (result = noErr) )
{

}

Jim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Thoughts on CodeWarrior 8 for Cocoa programming? (From: Thomas Deniau <email@hidden>)

  • Prev by Date: Re: newbie : init ?
  • Next by Date: Re: Sending mail with message.framework
  • Previous by thread: Re: Thoughts on CodeWarrior 8 for Cocoa programming?
  • Next by thread: Re: Thoughts on CodeWarrior 8 for Cocoa programming?
  • Index(es):
    • Date
    • Thread