• 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: variable problem is driving me nuts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variable problem is driving me nuts


  • Subject: Re: variable problem is driving me nuts
  • From: gweston <email@hidden>
  • Date: Sun, 28 Oct 2012 19:19:26 +0000 (GMT)

H Miersch wrote: 

then why does Xcode complain about an unused result? this is just another example of a TOTALLY USELESS error message.
anyway, i fixed it, and now it works. thanks.

ok, it looks like i've sorted the original problem. but here's the next one:

i have this line:

for (i = 0; i++; i < count) {…}

in the app delegate. Xcode keeps giving me this warning: expression result unused. WTF? that is correct syntax for a for loop, isn't it? so then why do i keep getting this warning?
also, i have confirmed that the statements between { and } are NOT executed, no matter what. that's not right either. so WTF is going on here?
_______________________________________________

no it's not even vaguely the right syntax for a for loop. You have for( initialiser, iterator, condition ) it's supposed to be for( initialiser, condition, iterator )
that's just basic C
 

The problem is that while it's not, as the prior poster indicated, the right syntax for a working for loop it's not actually illegal syntax in general. for(a;b;c) {d} means precisely:

a; while(b != 0) { d; c; }

Your original code is perfectly legal if you consider it that way. It just wasn't doing what you wanted.

And why was your code never executing?

Because i++ evaluates to i and *then* increments i in place. Since i was zero on the first pass it bailed out immediately. If you had used ++i instead, it would've run through the entire space of whatever type i is.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Prev by Date: Re: Warning message using stringWithContentsOfFile:encoding:error:
  • Next by Date: Re: variable problem is driving me nuts
  • Previous by thread: Re: variable problem is driving me nuts
  • Next by thread: Keeping a menu enabled with a modal dialog running
  • Index(es):
    • Date
    • Thread