Search code examples
iosobjective-ciphoneswiftskmaps

How would I translate this Swift to Obj-C?


This is probably simple enough, but Im not a regular iOS dev but have a decent understanding of Obj-C and Xcode however not so much with Swift yet.

I am playing around with a mapping SDK called Skobbler and downloaded both Swift and iOS examples. The Swift example gives me some useful text/console logs of directions turn by turn however the Obj-C doesn't and having a tough time exposing them.

The Swift example looks like this

let advices: Array<SKRouteAdvice> =  SKRoutingService.sharedInstance().routeAdviceListWithDistanceFormat(SKDistanceFormat.Metric) as! Array<SKRouteAdvice>
    for advice: SKRouteAdvice in advices
    {
       let instructions = advice.adviceInstruction
       print(instructions)
    }

Solution

  • NSArray<SKRouteAdvice *> *advices = [[SKRoutingService sharedInstance] routeAdviceListWIthDistanceFormat:SKDistanceFormat.Metric];
    
    for (SKRouteAdvice *advice in advices)
    {
        NSLog(@"%@", instructions);
    }