Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the Current Temperature in iOS

Tags:

ios

iphone

ipad

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?

like image 529
Anders Lundsgard Avatar asked Nov 28 '22 17:11

Anders Lundsgard


2 Answers

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.

like image 101
Sergey Kalinichenko Avatar answered Dec 07 '22 01:12

Sergey Kalinichenko


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
like image 36
Richard J. Ross III Avatar answered Dec 07 '22 01:12

Richard J. Ross III