2011-04-07 146 views

回答

3

你为什么从你的reverseGeocoder消息返回void?我会写这样的:

- (NSString*)reverseGeocoder:(Placemark*)myPlacemark 
{ 
    // assuming myPlacemark is holding a reference to the dictionary (so no need to retain) 
    NSString *city = [myPlacemark.addressDictionary objectForKey:kABPersonAddressCityKey]; 
    return city; 
} 

-(BOOL)fetchAndParseRss 
{ 
    // you need to get myPlacemark from somewhere, presumably from the geocode request? 
    Placemark * myPlacemark = [self getPlacemark]; 

    NSString * CurrentLocation = [self reverseGeocoder:myPlacemark]; 
} 

在这段代码中,我假设Placemark是一个类,它有一个addressDictionary NSDictionary定义为一个属性。

如果你真的需要这个消息来返回一个void *,那么你将从NSString *转换为void *然后再返回。

- (void*)reverseGeocoder:(Placemark*)myPlacemark 
{ 
    // assuming myPlacemark is holding a reference to the dictionary (so no need to retain) 
    NSString *city = [myPlacemark.addressDictionary objectForKey:kABPersonAddressCityKey]; 
    return (void*)city; 
} 

然后将它转换回一个NSString当你将它(不知道你为什么会这么做):

-(BOOL)fetchAndParseRss 
{ 
    // you need to get myPlacemark from somewhere, presumably from the geocode request? 
    Placemark * myPlacemark = [self getPlacemark]; 

    NSString * CurrentLocation = (NSString*)[self reverseGeocoder:myPlacemark]; 
} 
+0

@Himalay让我知道如果我能可以澄清我的答案。 – RedBlueThing 2011-04-07 02:46:14

相关问题