• 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: Loops in Objective C?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loops in Objective C?


  • Subject: Re: Loops in Objective C?
  • From: Nathan Kinsinger <email@hidden>
  • Date: Mon, 26 May 2008 13:31:15 -0600


On May 26, 2008, at 1:20 PM, Nathan wrote:

so I have a .m file, here's the contents.

#import "RotationHandler.h"

@implementation RotationHandler
int z=1;
float rot;
- (IBAction)buttonRelease:(id)sender {
	do
	{
		rot=rot-0.5;
		[sliderRotation setFrameCenterRotation: rot];
		[printRotation setFloatValue: rot];
	}
	while(z=1);
}

@end

I won't bother showing you the other files in the project I know they're all in order. So I want the object receiving sliderRotation to rotate, in the above code I want it to rotate forever. If I remove the loop, each time I press the button it rotates -.5 degrees. But with the loop in there, I get the horrible spinning beachball of eternity when I press the button and the object that is supposed to rotate never moves. Do I have to use some special Objective C loop?

The problem here is that looping forever will not let the rest of the program run. So the drawing code will never get called. Look into NSTimer to run a method that will do your rotation on some interval.


--Nathan
_______________________________________________

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


  • Follow-Ups:
    • Re: Loops in Objective C?
      • From: Nathan <email@hidden>
References: 
 >Loops in Objective C? (From: Nathan <email@hidden>)

  • Prev by Date: Re: how to get a double from an NSString
  • Next by Date: Re: Loops in Objective C?
  • Previous by thread: Re: Loops in Objective C?
  • Next by thread: Re: Loops in Objective C?
  • Index(es):
    • Date
    • Thread