I’m getting the error on “float pos = [sender value];”…sender should be a UISlider that I set up in Interface Builder.
ButtonViewController.m
- (IBAction)slide: (id)sender {
float pos = [sender value];
loadValue.progress = pos;
}
ButtonViewController.h
@interface Button_Fun4ViewController : UIViewController {
IBOutlet UIProgressView *loadValue;
}
- (IBAction)slide: (id)sender;
THANKS.
While sender “should” be a UISlider, the compiler doesn’t know that. All it sees is
id, which it binds to the first matching method signature it can find; probably one that returns something other than a float (and as a final guess, the compiler will assume it returns anid).You’ll need to typecast this over to UISlider in this case:
Using
NSAssert()or anif()to double-check that this is fact aUISliderwouldn’t be a bad idea, but isn’t strictly necessary.