Domanda

Quite surprised to get the following error :

undefined method `[]' for #<CLLocation:0x9a95cd0> (NoMethodError)

when trying to reproduce the simplest example given :

  BW::Location.get_once do |result|
    p "From Lat #{result[:from].latitude}, Long #{result[:from].longitude}"
    p "To Lat #{result[:to].latitude}, Long #{result[:to].longitude}"
  end

CLLocation is imported (even if not sure it is required while using bubbblewrap) using the following :

app.frameworks += ["CoreLocation"]

as bubblewrap location is :

require 'bubble-wrap/location'

Any obviousness appreciated (:

È stato utile?

Soluzione

BW::Location.get_once yields a CLLocation object, not an array of CLLocation.

Try something like this:

BW::Location.get_once do |location|
    p "Lat #{location.latitude}, Long #{location.longitude}"
end
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top