You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/10/28 23:11:43 UTC

[06/19] git commit: [CB-4825] avoid retain cycle in update block

[CB-4825] avoid retain cycle in update block


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/commit/b2e17a78
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/tree/b2e17a78
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/diff/b2e17a78

Branch: refs/heads/master
Commit: b2e17a784a6d69a89410e661f3f9d76f0fcb4bc5
Parents: ea30406
Author: James Jong <wj...@gmail.com>
Authored: Wed Oct 2 16:21:49 2013 -0400
Committer: James Jong <wj...@gmail.com>
Committed: Wed Oct 2 16:21:49 2013 -0400

----------------------------------------------------------------------
 src/ios/CDVAccelerometer.m | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/b2e17a78/src/ios/CDVAccelerometer.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVAccelerometer.m b/src/ios/CDVAccelerometer.m
index b338245..20bcbc6 100755
--- a/src/ios/CDVAccelerometer.m
+++ b/src/ios/CDVAccelerometer.m
@@ -66,12 +66,13 @@
     if ([self.motionManager isAccelerometerAvailable] == YES) {
         // Assign the update interval to the motion manager and start updates
         [self.motionManager setAccelerometerUpdateInterval:kAccelerometerInterval/1000];  // expected in seconds
+        __weak CDVAccelerometer* weakSelf = self;
         [self.motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
             x = accelerometerData.acceleration.x;
             y = accelerometerData.acceleration.y;
             z = accelerometerData.acceleration.z;
             timestamp = ([[NSDate date] timeIntervalSince1970] * 1000);
-            [self returnAccelInfo];
+            [weakSelf returnAccelInfo];
         }];
 
         if (!self.isRunning) {