-2

I have an array in obj-c with this data and latitude and longitude is a NSNumber

[<RequestAddress> 
 [latitude]: 38.63180843974196
 [longitude]: 33.12896232001408
 [addressText]: address Name
 [isStartedPoint]: 1
</RequestAddress>]

and I am trying to print the two values and I'm getting it like this

if let value = parentNewCarRequestVC.request.address{

    print(value) // value = (
"<RequestAddress> \n   [latitude]: 39.6954240771316\n   [longitude]: 33.10735601860666\n   [addressText]: address Name\n   [isStartedPoint]: 1\n</RequestAddress>"
)

    let number = Double(value[0].latitude)
    print("Result:\(number)") //Result: 6.94109152851164e-310
}

while it should be 38.6318

So please where would be my issue?

Luai Kalkatawi
  • 1,492
  • 5
  • 25
  • 51
  • What is the value shown for `value[0].latitude`? Did you check this in Playground? – R P Dec 02 '15 at 22:49
  • I have updated my answer which show the content of value. No I didn't check in the playground @RP – Luai Kalkatawi Dec 02 '15 at 22:55
  • The example array makes no sense and would probably need to be a dictionary, not an array, Research the syntax for defining dictionaries and arrays. – zaph Dec 03 '15 at 00:06

1 Answers1

1

If the latitude and longitude are NSNumbers, use the doubleValue property:

let number = value[0].latitude.doubleValue
print("Result:\(number)")
Mr Beardsley
  • 3,743
  • 22
  • 28