你爲什麼從你的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];
}
@Himalay讓我知道如果我能可以澄清我的答案。 – RedBlueThing 2011-04-07 02:46:14