Reputation: 11
Following is my code in vievDidLoad
CMMotionManager *motionmanager = [[[CMMotionManager alloc]init]autorelease];
NSString string1 = [NSString stringwithFormat:@"%s", ([motionmanager.isGyroAvailable} ? @"Available" : @"Not Available"));
In Instruments i get memory leaks referring CMMotionManagerInternal in XCode 4.5 What's wrong with my code?
Upvotes: 1
Views: 796
Reputation: 3651
It seems to be a bug in the simulator. It's working properly on the device.
Upvotes: 1
Reputation: 4092
The CMMotionManager
line seems fine, however you should consider keeping the reference (make it instance variable and not autorelease it) and release the CMMotionManager
manually when you stop updating data from it.
The other line bothers me more. You have
NSString string1 = [NSString stringwithFormat:@"%s", ([motionmanager.isGyroAvailable} ? @"Available" : @"Not Available"));
While you should have:
NSString *string1 = [NSString stringwithFormat:@"%@", ([motionmanager.isGyroAvailable} ? @"Available" : @"Not Available"));
so string1
should be a pointer and format is @"%@"
not @"%s"
.
Upvotes: 1