Anders Lundsgard
Anders Lundsgard

Reputation: 797

Get the Current Temperature in iOS

I'm trying to create a small weather app.

What is the best practice to figure out what degree setting the user have? (Celcius or Fahrenheit) Is it possible to read that from the built in weather app?

Upvotes: 4

Views: 6027

Answers (3)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726479

To answer the original question about the display settings, I'd try this:

NSLocale *locale = [NSLocale currentLocale]; 
BOOL usesMetric = [[locale objectForKey:NSLocaleUsesMetricSystem] boolValue];

If usesMetric is YES, I would use Celsius; otherwise, I'd use Fahrenheit.

Upvotes: 15

Richard J. Ross III
Richard J. Ross III

Reputation: 55533

You would need to find a web API for this, here are a few:

  1. World Weather Online (free)
  2. The Weather Channel API (paid subscription)
  3. Weather Underground API (free)
  4. WeatherBug API
  5. yr.no API

Upvotes: 7

TommyG
TommyG

Reputation: 4155

There is no way to read the weather from anywhere on the phone, including other apps...the iPhone Weather app uses the Yahoo weather API. You can use that or the Google one: http://blog.programmableweb.com/2010/02/08/googles-secret-weather-api/

There is no way to get around it without a server call :)

(I am assuming you are interested in the weather and not just the temperature).

Upvotes: 1

Related Questions