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,11 +6,6 @@
6 6
 #import "RNPMotion.h"
7 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 9
 @implementation RNPMotion
15 10
 
16 11
 + (NSString *)getStatus
@@ -41,12 +36,12 @@
41 36
 
42 37
 + (void)request:(void (^)(NSString *))completionHandler
43 38
 {
44
-    __block NSString *status = [self getMotionPermissionStatus];
39
+    __block NSString *status = [RNPMotion getStatus];
45 40
     
46 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 45
             if (error) {
51 46
                 status = RNPStatusDenied;
52 47
             } else if (activities || !error) {
@@ -57,8 +52,8 @@
57 52
                 completionHandler(status);
58 53
             });
59 54
             
60
-            [self setActivityManager:nil];
61
-            [self setMotionActivityQueue:nil];
55
+            activityManager = nil;
56
+            motionActivityQueue = nil;
62 57
         }];
63 58
     } else {
64 59
         completionHandler(status);