Byte
Byte

Reputation: 2940

iOS: Objectifying MKCoordinateSpan to put in an array

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.

Upvotes: 1

Views: 241

Answers (2)

Jano
Jano

Reputation: 63707

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);

Upvotes: 1

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 727077

Try this:

MKCoordinateSpan currentSpan;
currentSpan = ...; // Set the span to somethinf
NSValue *spanVal = [NSValue valueWithBytes:&currentSpan objCType:@encode(MKCoordinateSpan)];
...
MKCoordinateSpan currentSpanBack;
[spanVal getValue:&currentSpanBack];

Upvotes: 0

Related Questions