1

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.

Byte
  • 2,920
  • 3
  • 33
  • 55
  • 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 Answers2

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:&currentSpan objCType:@encode(MKCoordinateSpan)];
...
MKCoordinateSpan currentSpanBack;
[spanVal getValue:&currentSpanBack];
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523