Im trying to find a direct way to put MKCoordinateSpan into an array without breaking it down to lat and long and store it in an NSArray. Not sure if there is such way.
Asked
Active
Viewed 241 times
1
-
possible duplicate of [Add and extract struct from NSMutableArray](http://stackoverflow.com/questions/5704722/add-and-extract-struct-from-nsmutablearray) – Vladimir Jul 24 '12 at 14:40
2 Answers
1
MKCoordinateSpan span = MKCoordinateSpanMake(1.0, 1.0);
NSData *data = [NSData dataWithBytes:&span length:sizeof(span)];
MKCoordinateSpan back;
[data getBytes:&back length:sizeof(back)];
NSLog(@"%f",back.latitudeDelta);

Jano
- 62,815
- 21
- 164
- 192
0
Try this:
MKCoordinateSpan currentSpan;
currentSpan = ...; // Set the span to somethinf
NSValue *spanVal = [NSValue valueWithBytes:¤tSpan objCType:@encode(MKCoordinateSpan)];
...
MKCoordinateSpan currentSpanBack;
[spanVal getValue:¤tSpanBack];

Sergey Kalinichenko
- 714,442
- 84
- 1,110
- 1,523
-
I never tried this myself, but I've seen examples that suggest that it might work. – Sergey Kalinichenko Jul 24 '12 at 14:43