如何从“(void)”中获取 NSString 值方法转换成“(BOOL)” Objective-C 中的方法?
我想将“city”的值获取到“CurrentLocation”中。
- (void)reverseGeocoder:(MKPlacemark *)placemark {
NSString *city = [myPlacemark.addressDictionary objectForKey:(NSString*) kABPersonAddressCityKey];
}
- (BOOL)fetchAndParseRSS {
NSString *currentLocation; // I want 'city' here.
return YES;
}
I want to get the value of "city" into "CurrentLocation".
- (void)reverseGeocoder:(MKPlacemark *)placemark {
NSString *city = [myPlacemark.addressDictionary objectForKey:(NSString*) kABPersonAddressCityKey];
}
- (BOOL)fetchAndParseRSS {
NSString *currentLocation; // I want 'city' here.
return YES;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么您的反向地理编码器消息返回无效?我会这样写:
在这段代码中,我假设 Placemark 是一个类,其中一个 addressDictionary NSDictionary 定义为属性。
如果您确实需要该消息返回 void*,那么您可以从 NSString* 转换为 void*,然后再返回。
然后在分配它时将其转换回 NSString (不知道为什么要这样做):
Why are your returning void from your reverseGeocoder message? I would have written this like this:
In this code I am assuming Placemark is a class with a addressDictionary NSDictionary defined as a property.
If you really need that message to return a void* then you would cast from a NSString* to void* and then back again.
Then cast it back to an NSString when you assign it (not sure why you would do this):