मुझे समझ में नहीं आता कि मैं CGPoint
structs संग्रह क्यों कर सकता हूं लेकिन CLLocationCoordinate2D
structs नहीं। संग्रहकर्ता के लिए क्या अंतर है?NSKeyedArchiver CLLocationCoordinate2D structs के साथ विफल रहता है। क्यूं कर?
प्लेटफार्म आईओएस है। मैं सिम्युलेटर में दौड़ रहा हूं और डिवाइस पर कोशिश नहीं की है।
// why does this work:
NSMutableArray *points = [[[NSMutableArray alloc] init] autorelease];
CGPoint p = CGPointMake(10, 11);
[points addObject:[NSValue valueWithBytes: &p objCType: @encode(CGPoint)]];
[NSKeyedArchiver archiveRootObject:points toFile: @"/Volumes/Macintosh HD 2/points.bin" ];
// and this doesnt work:
NSMutableArray *coords = [[[NSMutableArray alloc] init] autorelease];
CLLocationCoordinate2D c = CLLocationCoordinate2DMake(121, 41);
[coords addObject:[NSValue valueWithBytes: &c objCType: @encode(CLLocationCoordinate2D)]];
[NSKeyedArchiver archiveRootObject:coords toFile: @"/Volumes/Macintosh HD 2/coords.bin" ];
मैं 2 archiveRootObject
पर एक दुर्घटना हो और इस संदेश को कंसोल में छपा है:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSKeyedArchiver encodeValueOfObjCType:at:]: this archiver cannot encode structs'
धन्यवाद; यह सही स्पष्टीकरण है! मैं इसे अपने रडार रिपोर्ट में संदर्भित करूंगा :) – TomSwift