0

I have to get accelerometer and location updates and in separate threads but not on the main thread. Also, it should not interrupt one other or other UI tasks.

Location updates and acclerometer updates should be run separately. How to run these two separately?

After getting accelerometer updates I am performing some tasks and after location updates I am performing some other tasks. But I observed that these are interrupting one other.

For location updates I am using delegate method:

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    /// sending location details to server.
}

For accelerometer updates I am using delegate method:

[motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:^(CMAccelerometerData *accelerometerData, NSError *error)
{
    if (!error) {
       /// Calculating some values and sending those details to server.
    }
}];
Wain
  • 118,658
  • 15
  • 128
  • 151
  • Have you read the documentation about threading? https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/CreatingThreads.html#//apple_ref/doc/uid/10000057i-CH15-SW19 – Sebastian Wramba Feb 04 '14 at 11:05
  • Yes I have created thread using [NSThread detachNewThreadSelector:@selector(myThreadMainMethod:) toTarget:self withObject:nil];[motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) { if (!error) {detachNewThreadSelector:@selector(myThreadMainMethod:) toTarget:self withObject:nil];// application UI has become slow /// Calculating some values and sending those details to server. } }]; – user3129761 Feb 04 '14 at 11:30
  • And also how to access the methods that are not part of this thread through this thread. – user3129761 Feb 04 '14 at 11:33

0 Answers0