Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (id)initWithConnectDevice:(ConnectDevice *)cDevice toPeripheral:(CBPeripheral*)peripheral oPerationIndex:(int) index{
- if (self = [super init]) {
- operationIndex = index;
- executing = NO;
- finished = NO;
- self.connectDevice = cDevice;
- [self.connectDevice setDelegate:self];
- self.connectedPeripheral = peripheral;
- }
- return self;
- -(BOOL)isConcurrent{
- return YES;
- }
- - (BOOL)isExecuting {
- return executing;
- }
- - (BOOL)isFinished {
- return finished;
- }
- -(void) terminateOperation {
- [self willChangeValueForKey:@"isFinished"];
- [self willChangeValueForKey:@"isExecuting"];
- finished = YES;
- executing = NO;
- [self didChangeValueForKey:@"isExecuting"];
- [self didChangeValueForKey:@"isFinished"];
- }
- - (void)start {
- @autoreleasepool {
- if (self.isCancelled){
- [timer invalidate];
- [self willChangeValueForKey:@"isFinished"];
- finished = YES;
- [self didChangeValueForKey:@"isFinished"];
- return;
- }
- timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerFired:) userInfo:nil repeats:YES];
- [[NSRunLoop currentRunLoop] run];
- }
- }
- -(void)timerFired:(id)sender{
- NSLog(@"timerFired");
- }
- OperationQueue *queue = [[OperationQueue alloc] initWithConnectDevice:connectDevices toPeripheral:peripheral oPerationIndex:operationIndex];
- queue.delegate = self;
- [[[AppDelegate app] mainQueue] addOperation:queue];
- operationIndex = operationIndex+1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement