Browse Source

Clean up code

Jonathan Kim 7 years ago
parent
commit
bf347ec95b
1 changed files with 6 additions and 11 deletions
  1. 6
    11
      permissions/RNPMotion.m

+ 6
- 11
permissions/RNPMotion.m View File

6
 #import "RNPMotion.h"
6
 #import "RNPMotion.h"
7
 #import <CoreMotion/CoreMotion.h>
7
 #import <CoreMotion/CoreMotion.h>
8
 
8
 
9
-@interface RNPMotion ()
10
-@property (nonatomic, strong) CMMotionActivityManager *activityManager;
11
-@property (nonatomic, strong) NSOperationQueue *motionActivityQueue;
12
-@end
13
-
14
 @implementation RNPMotion
9
 @implementation RNPMotion
15
 
10
 
16
 + (NSString *)getStatus
11
 + (NSString *)getStatus
41
 
36
 
42
 + (void)request:(void (^)(NSString *))completionHandler
37
 + (void)request:(void (^)(NSString *))completionHandler
43
 {
38
 {
44
-    __block NSString *status = [self getMotionPermissionStatus];
39
+    __block NSString *status = [RNPMotion getStatus];
45
     
40
     
46
     if ([status isEqual: RNPStatusUndetermined]) {
41
     if ([status isEqual: RNPStatusUndetermined]) {
47
-        self.activityManager = [[CMMotionActivityManager alloc] init];
48
-        self.motionActivityQueue = [[NSOperationQueue alloc] init];
49
-        [self.activityManager queryActivityStartingFromDate:[NSDate distantPast] toDate:[NSDate date] toQueue:self.motionActivityQueue withHandler:^(NSArray *activities, NSError *error) {
42
+        __block CMMotionActivityManager *activityManager = [[CMMotionActivityManager alloc] init];
43
+        __block NSOperationQueue *motionActivityQueue = [[NSOperationQueue alloc] init];
44
+        [activityManager queryActivityStartingFromDate:[NSDate distantPast] toDate:[NSDate date] toQueue:motionActivityQueue withHandler:^(NSArray *activities, NSError *error) {
50
             if (error) {
45
             if (error) {
51
                 status = RNPStatusDenied;
46
                 status = RNPStatusDenied;
52
             } else if (activities || !error) {
47
             } else if (activities || !error) {
57
                 completionHandler(status);
52
                 completionHandler(status);
58
             });
53
             });
59
             
54
             
60
-            [self setActivityManager:nil];
61
-            [self setMotionActivityQueue:nil];
55
+            activityManager = nil;
56
+            motionActivityQueue = nil;
62
         }];
57
         }];
63
     } else {
58
     } else {
64
         completionHandler(status);
59
         completionHandler(status);