Question

I'm new to Xcode.

I need a If Statement that asks IF the UIProgressView progress (float) goes bigger or smaller then do something.

Thanks for any help.

if (myProgV is moving) {

//Do something

}
Was it helpful?

Solution

As the others have hinted, you've got this backwards. A progress view is a view object. It displays things. It is not supposed to save state information.

You should read up on the MVC design pattern. View objects should not be used to store things.

I would suggest adding a property to your view controller. Let's call it progress. Say it has a value that ranges from 0 to 1.

Implement a custom setter for your progress property that sets a progress view, and also saves the value to the property's instance variable:

- (void) setProgress: (CGFloat) progress;
{
   _progress = progress;
   [myProgressView setProgress: progress animated: yes];
   //Do anything else here that you need to to respond to a change in progress.
}

Now, since you have a property, you can also query the value of progress at any point:

if (self.progreess > .5) 
  NSLog(@"More than halfway done!");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top