将斯威夫特的“强迫贬低(as!)”转换为目标c

时间:2017-10-08 04:08:10

标签: objective-c swift struct

我想将此快速线转换为Objective-C

let location = CLLocationCoordinate2D(latitude: (marker.userData as! location).lat, longitude: (marker.userData as! location).lon)

userData属于id类型,它被强制转发为location但是当我尝试在Objective-C中强制转换userData时,我得到了这个:

  

找到名为'location'的多个方法,结果不匹配,   参数类型或属性

这是我的代码:

struct CLLocationCoordinate2D markerLocation;
    markerLocation.longitude=[(CLLocation *)[marker.userData location] coordinate].longitude;

1 个答案:

答案 0 :(得分:2)

您想要投射ec2,而不是userData消息的结果。

location

......应该......

markerLocation.longitude=[(CLLocation *)[marker.userData location] coordinate].longitude;