Tôi gặp sự cố khi thêm C-struct vào NSDictionary.
C-struct là MKCoordinateRegion trên MapKit.h.obj-c thêm c-struct vào từ điển
khai Đó là
typedef struct {
CLLocationCoordinate2D center;
MKCoordinateSpan span;
} MKCoordinateRegion;
và khai CLLocationCoordinate2D là
typedef struct {
CLLocationDegrees latitude;
CLLocationDegrees longitude;
} CLLocationCoordinate2D;
MKCoordinateSpan là cùng.
Bây giờ, tôi muốn thêm MKCoordinateRegion vào NSDictionary.
CLLocationCoordinate2D center = CLLocationCoordinate2DMake(40.723128, -74.000694);
MKCoordinateSpan span = MKCoordinateSpanMake(1.0, 1.0);
MKCoordinateRegion region = MKCoordinateRegionMake(center, span);
NSMutableDictionary *param = [[NSMutableDictionary alloc] init];
[param setObject:region forKey:@"region"];
5 dòng có lỗi.
thông báo lỗi là "Gửi" MKCoordinateRegion 'đến thông số của loại không tương thích' id '"
Cảm ơn.
Xem câu trả lời không được chấp nhận [ở đây] (http://stackoverflow.com/questions/6538726/how-to-return-multiple-values-from-a-method/6539044 # 6539044). Ví dụ này dành cho các mảng nhưng vẫn áp dụng cho các từ điển. – Joe