0

我刚刚开始使用工具来查找应用程序中的内存泄漏,任何人都可以建议我如何修复仪器中提到的泄漏。

实际上我得到如下屏幕所示

在此处输入图像描述

任何人都可以建议我修复的步骤..

我在这里提到过: 仪器和调试,但无法解决这个问题..

在这里,它建议创建假设来估计时间消耗..有人知道如何创建这个吗?

  -(void)ShowingDeals
  {
     @try {
    CLLocationManager *lm = [[CLLocationManager alloc] init];
    lm.delegate = self;
    lm.desiredAccuracy = kCLLocationAccuracyBest;
    lm.distanceFilter = kCLDistanceFilterNone;
    [lm startUpdatingLocation];

    CLLocation *location = [lm location];

    CLLocationCoordinate2D coord;
    coord.longitude = location.coordinate.longitude;
    coord.latitude = location.coordinate.latitude;

    NSString *strLat = [NSString stringWithFormat:@"%f",coord.latitude];
    NSString *strLong = [NSString stringWithFormat:@"%f",coord.longitude];
    [[SharedData userInfo]setObject:strLat forKey:@"lat"];
    [[SharedData userInfo]setObject:strLong forKey:@"long"];

    NSString *urlString = [NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&sensor=false",[strLat floatValue], [strLong floatValue]];
    NSError* error;
    NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSASCIIStringEncoding error:&error];

    NSData *data = [locationString dataUsingEncoding:NSUTF8StringEncoding];
    id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];

    NSArray *arrResults = [json objectForKey:@"results"];
    NSDictionary *dic =[NSDictionary dictionary];
    if (arrResults.count>0) {
       dic = [[json objectForKey:@"results"] objectAtIndex:0];
    }

    NSArray* arr = [dic objectForKey:@"address_components"];
    //Iterate each result of address components - find locality and country
    NSString *cityName;
    NSString *countryName;


   // NSString* locationFinal = [NSString stringWithFormat:@"%@,%@",cityName,countryName];
    [[SharedData userInfo]setObject:cityName forKey:@"City"];

    max=max+1;

    _collectionView.alpha=1.0;
    _activity.alpha=1.0;
    [_activity startAnimating];
    if (myTaskBool==YES) {
        myTaskBool=NO;
        [self performSelectorInBackground:@selector(myTask) withObject:self];
    }

     NSDictionary *userInfo = [SharedData userInfo];


    dispatch_async(dispatch_get_main_queue(), ^{
        [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    });





}
@catch (NSException *exception) {
    NSLog(@"%@",exception);
}
@finally {

  }
}
4

0 回答 0