我想將NSCoding支持添加到c數組結構中。具體而言,這是爲了MKPolyline
一個子類,即這是我有工作:如何使用NSCoding構造一個c數組? (MKPolyline)
@property (nonatomic, readonly) MKMapPoint *points;
@property (nonatomic, readonly) NSUInteger pointCount;
+ (MKPolyline *)polylineWithPoints:(MKMapPoint *)points count:(NSUInteger)count;
I found a good answer on how to encode a individual struct。例如。
NSValue* point = [NSValue value:&aPoint withObjCType:@encode(MKMapPoint)];
[aCoder encodeObject:point forKey:@"point"];
....
NSValue* point = [aDecoder decodeObjectForKey:@"point"];
[endCoordinateValue getValue:&aPoint];
有沒有一種很好的方式將它應用到c數組 - 或者我只需要遍歷c數組?
怎麼樣'[NSValue值:aPointArray withObjCType:@encode(MKMapPoint [12])]'或者類似的? – 2013-02-16 18:49:03
@ H2CO3此方法在將來的版本中可能不推薦使用。您應該使用'valueWithBytes:objCType:'來代替。 – voromax 2013-02-16 18:54:21
@voromax沒有檢查文檔,只是重複了OP的內容,但是是真的。 – 2013-02-16 18:56:06