Created
December 12, 2011 07:49
-
-
Save nolili/1465746 to your computer and use it in GitHub Desktop.
ARC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ViewController.h" | |
#import <CoreMotion/CoreMotion.h> | |
@implementation ViewController | |
{ | |
CMMotionManager *motionManager; | |
} | |
- (void)hoge | |
{ | |
NSLog(@"hoge"); | |
} | |
- (id)initWithCoder:(NSCoder *)coder { | |
self = [super initWithCoder:coder]; | |
if (self) { | |
motionManager = [[CMMotionManager alloc] init]; | |
__weak ViewController *weakSelf = self; | |
[motionManager startGyroUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMGyroData *gyroData, NSError *error){ | |
__strong ViewController *strongSelf = weakSelf; | |
if (strongSelf){ | |
[strongSelf hoge]; | |
} | |
}]; | |
} | |
return self; | |
} | |
- (void)dealloc | |
{ | |
[motionManager stopGyroUpdates]; | |
NSLog(@"Dealloc"); | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ViewController.h" | |
#import <CoreMotion/CoreMotion.h> | |
@implementation ViewController | |
{ | |
CMMotionManager *motionManager; | |
} | |
- (void)hoge | |
{ | |
NSLog(@"hoge"); | |
} | |
- (id)initWithCoder:(NSCoder *)coder { | |
self = [super initWithCoder:coder]; | |
if (self) { | |
motionManager = [[CMMotionManager alloc] init]; | |
[motionManager startGyroUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMGyroData *gyroData, NSError *error){ | |
[self hoge]; | |
}]; | |
} | |
return self; | |
} | |
- (void)dealloc | |
{ | |
[motionManager stopGyroUpdates]; | |
NSLog(@"Dealloc"); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment