您可以简单地使用此代码并将其连接到任何 UIButton:
- (IBAction) sliderReaderMakeRequest {
SLIDERReader *slreader = [[SLIDERReader alloc] init];
[slreader startRequest];
}
或者如果您想在线程中执行此操作:
@property (nonatomic, strong) NSOperationQueue *operationQueue;
- (void)awakeFromNib {
self.operationQueue = [[NSOperationQueue alloc] init];
}
- (IBAction) sliderReaderMakeRequest {
NSInvocationOperation *op = [[ NSInvocationOperation alloc] initWithTarget:self
selector:@selector(makeSliderRequest)
object:nil];
[_operationQueue addOperation:op];
}
- (void) makeSliderRequest {
SLIDERReader *slreader = [[SLIDERReader alloc] init];
[slreader startRequest];
[self performSelectorOnMainThread:@selector(finishMakeSliderRequest) withObject:nil waitUntilDone:YES];
}
- (void) finishMakeSliderRequest {
//Whatever you want on main thread with data come from request
}