Objective c 使用MVC设计格式化数据

Objective c 使用MVC设计格式化数据,objective-c,ios,model-view-controller,core-location,Objective C,Ios,Model View Controller,Core Location,我有一个TableViewController和模型类TripInfo。点击cell附件视图时,我想将当前位置的地址返回到cell的文本字段。我很难想出如何按照MVC模式干净地完成这项工作 以下是我目前掌握的情况: 1.TableViewController实现:点击附件视图,locationManager开始更新 2.TableViewController实现:locationManagerdidUpdateLocation方法被调用,并将当前设置为模型对象属性self.tripInfo.lo

我有一个TableViewController和模型类
TripInfo
。点击cell附件视图时,我想将当前位置的地址返回到cell的文本字段。我很难想出如何按照MVC模式干净地完成这项工作

以下是我目前掌握的情况:

1.TableViewController实现:点击附件视图,
locationManager
开始更新 2.TableViewController实现:
locationManager
didUpdateLocation方法被调用,并将当前设置为模型对象属性
self.tripInfo.location

现在我需要将此位置转换为物理地址。我将把这段代码放在一个以字符串形式返回地址的模型类方法中,例如:

- (NSString *)createAddressStringFromLocation: (CLLocation *)location
{

    __block NSString *locationAddress = @"";

    CLGeocoder *gecoder = [[CLGeocoder alloc] init];
    [gecoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
        CLPlacemark *placemark = [placemarks lastObject];

        locationAddress = [NSString stringWithFormat:@"%@", ABCreateStringWithAddressDictionary(placemark.addressDictionary, NO)];
    }];

    return locationAddress;
}
然后在cellForRow:

cell.textField.text = [NSString stringWithFormat:@"%@", [self.tripInfo createAddressStringFromLocation:self.tripInfo.fromLocation]];

让cellForRow在我的模型类中基本上等待此方法完成,这是一个糟糕的设计吗?

reverseGeocodeLocation:completionHandler
会立即返回,因此此代码本来就不应该工作(它是异步运行的……如果结果已经被缓存,它可能会同步执行,但在一般情况下肯定不会,因为它是以异步方式发布的)。我不明白。你能进一步解释吗?好的,我现在明白了。我是否最好在tableViewController中推迟反向地理编码实现,并将输出的字符串设置为
tripInfo
属性?