我想将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