【发布时间】:2013-03-30 11:37:42
【问题描述】:
我是 Objective C 的新手,所以这可能是一个非常愚蠢的问题。我正在阅读 iOS 编程书,偶然发现了这段 sn-p 代码:
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
CLLocationCoordinate2D loc = [userLocation coordinate]; // returns CLLocationCoordinate2D
...
}
我还在学习 Objective C,但 loc 不应该是指针吗?据我了解,您只能直接分配简单的类型,例如 int 和 float。这里CLLocationCoordinate2D 是一个结构。然而这不起作用:
CLLocationCoordinate2D *loc = [userLocation coordinate];
// this throws error message
// Initializing 'CLLocationCoordinate2D *' with an expression of incompatible type 'CLLocationCoordinate2D'
那么这里发生了什么,我怎样才能了解更多关于指针的信息。谢谢!
【问题讨论】:
标签: objective-c