• 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: unused variable warnings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unused variable warnings


  • Subject: Re: unused variable warnings
  • From: Lindsey Spratt <email@hidden>
  • Date: Wed, 12 Feb 2003 09:33:20 -0600

On Wednesday, February 12, 2003, at 09:05 AM, Phrygian wrote:

Hello Cocoa Programmers,

I'm at a loss as to why I keep getting an "unused variable" compiler error
in project builder under the following conditions,

NSString * somestring = @"this is a string";
or
NSCalendarDate * today = [NSCalendarDate calendarDate];

the compiler will give a warning that somestring and today are unused variables.
However, if I do the following,

NSString * somestring;
somestring = @"this is a string";

or

NSCalendarDate * today;
today = [NSCalendarDate calendarDate];

all is well.

It looks to me like the warning is correct in the first case, 'somestring' and 'today' *are* unused (and the compiler should have given you a warning in the second case, but it's not that sophisticated). Why create a variable that you never reference?

Lindsey Spratt
http://homepage.mac.com/lspratt
_______________________________________________
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.

  • Follow-Ups:
    • Re: unused variable warnings
      • From: Phrygian <email@hidden>
  • Prev by Date: RE: Disc Recording problem
  • Next by Date: RE: help needed with OO concepts when copying
  • Previous by thread: Re: unused variable warnings
  • Next by thread: Re: unused variable warnings
  • Index(es):
    • Date
    • Thread