IS2Weather Class Reference

Inherits from NSObject
Declared in IS2Weather.h

Overview

IS2Weather is used to access a wide variety of weather data directly sourced from Apple’s weather framework. It communicates with the daemon provided with InfoStats2 to update data in the background whenever a call to update occurs.

On each update, if the user has enabled Location Services then a new location will be found before updating data. This ensures that the most accurate data is returned.

If Location Services is not enabled, then the first city in the Weather app will be used as a basis for data retrieval.

Updating Data

+ registerForWeatherUpdatesWithIdentifier:andCallback:

Sets a block to be called whenever weather data changes. The identifier must be unique string; it is recommended to use reverse DNS notation, such as “com.foo.bar”.

+ (void)registerForWeatherUpdatesWithIdentifier:(NSString *)identifier andCallback:(void ( ^ ) ( void ))callbackBlock

Parameters

identifier

The identifier associated with your callback

callbackBlock

The block to call once data changes

Declared In

IS2Weather.h

+ unregisterForUpdatesWithIdentifier:

The inverse of registering for notifications. This must be called when your code is unloaded, else a thermonulcear detonation will occur on the palm of your hand.

+ (void)unregisterForUpdatesWithIdentifier:(NSString *)identifier

Parameters

identifier

The identifier associated with your callback

Declared In

IS2Weather.h

+ setWeatherUpdateTimeInterval:forRequester:

Sets the time interval after which weather data auto-updating is performed. By default, this is set to 30 minutes, though will be effectively off when no widgets are added.

If another client of the InfoStats2 API has requested a shorter time interval, that shorter interval will be used instead. You will be notified of new data being available via the callback specified with registerForWeatherUpdatesWithIdentifier:andCallback:

+ (void)setWeatherUpdateTimeInterval:(int)interval forRequester:(NSString *)requester

Parameters

interval

The interval to be requested for weather data auto-updates.

Available values:
10 - Update every 10 minutes
15 - Update every 15 minutes
20 - Update every 20 minutes
30 - Update every 30 minutes
40 - Update every 40 minutes
50 - Update every 50 minutes
60 - Update every 1 hour
120 - Update every 2 hours

requester

A unique identifier used to identify your code as requesting a particular interval. It is recommended to use reverse DNS notation, such as “com.foo.bar”.

Declared In

IS2Weather.h

+ removeRequesterForWeatherTimeInterval:

Removes your code as requesting a particular auto-update interval, as detailed in setWeatherUpdateTimeInterval:forRequester:. This should be called once your code is unloaded.

+ (void)removeRequesterForWeatherTimeInterval:(NSString *)requester

Parameters

requester

A unique identifier used to identify your code as requesting a particular interval. It is recommended to use reverse DNS notation, such as “com.foo.bar”.

Declared In

IS2Weather.h

+ updateWeather

Call this method to manually update the current weather data; your code will be notified when this update is completed via the callback block set in -registerForWeatherUpdatesWithIdentifier:.

+ (void)updateWeather

Declared In

IS2Weather.h

+ lastUpdateTime

The last time the currently selected city in Apple’s weather application was updated.

+ (NSString *)lastUpdateTime

Return Value

Last update time in the format: hours:minutes (00:00), automatically converted between 24hr and 12hr dependant on user’s settings

Declared In

IS2Weather.h

Locale-specific Preferences

+ isCelsius

A boolean specifying whether the returned weather data is in Celsius or Fahrenheit.

+ (BOOL)isCelsius

Return Value

Whether weather data is in Celsius or Fahrenheit

Declared In

IS2Weather.h

+ isWindSpeedMph

A boolean specifying whether the returned weather data gives wind speeds in mph or km/h.

+ (BOOL)isWindSpeedMph

Return Value

Whether wind data is measured in mph or km/h.

Declared In

IS2Weather.h

Current Data

+ currentLocation

Gives the current location used for weather data. This will be either the local city if Location Services is enabled, or the first city in Apple’s Weather app otherwise.

+ (NSString *)currentLocation

Return Value

The current location for weather data

Declared In

IS2Weather.h

+ currentTemperature

Gives the current temperature.

+ (int)currentTemperature

Return Value

The current temperature

Declared In

IS2Weather.h

+ currentCondition

Gives the appropriate Yahoo.com weather code for the current weather condition.

+ (int)currentCondition

Return Value

The current weather condition

Declared In

IS2Weather.h

+ currentConditionAsString

Gives the appropriate Yahoo.com weather code as a human-readable string. This is automatically translated for you.

+ (NSString *)currentConditionAsString

Return Value

The current (readable) weather condition

Declared In

IS2Weather.h

+ naturalLanguageDescription

Gives a longer string detailing general conditions for the current day; an example of this output can be seen in the Notification Center. Please note that this functionality is available for iOS 7+; for iOS 6, this will simply return the current condition.

+ (NSString *)naturalLanguageDescription

Return Value

A longer description of the day’s conditions.

Declared In

IS2Weather.h

+ highForCurrentDay

Gives the high temperature for the current day.

+ (int)highForCurrentDay

Return Value

Today’s high temperature

Declared In

IS2Weather.h

+ lowForCurrentDay

Gives the low temperature for the current day.

+ (int)lowForCurrentDay

Return Value

Today’s low temperature

Declared In

IS2Weather.h

+ currentWindSpeed

The current wind speed, automatically converted between MPH and KM/h dependant on the user’s locale settings

+ (int)currentWindSpeed

Return Value

The current wind speed

Declared In

IS2Weather.h

+ currentWindDirection

The current wind direction, measured in degrees from 0-360, with 0 being North and 180 being South.

+ (int)currentWindDirection

Return Value

Wind direction in degrees

Declared In

IS2Weather.h

+ currentWindChill

The current wind chill for today

+ (int)currentWindChill

Return Value

Wind chill, in Celsius or Farenheit dependant on user settings

Declared In

IS2Weather.h

+ currentDewPoint

The temperature required for dew to form today.

+ (int)currentDewPoint

Return Value

Currrent dew point

Declared In

IS2Weather.h

+ currentHumidity

The current air humidity

+ (int)currentHumidity

Return Value

The current humidity as a percentage, 0-100.

Declared In

IS2Weather.h

+ currentVisibilityPercent

Percentage representing the quality visibility is on the current day

+ (int)currentVisibilityPercent

Return Value

Visibility, measured in percent 0-100

Declared In

IS2Weather.h

+ currentChanceOfRain

Current chance of rain, as a percentage between 0-100

+ (int)currentChanceOfRain

Return Value

Current chance of rain

Declared In

IS2Weather.h

+ currentlyFeelsLike

The temperature it feels like, taking into account wind chill etc.

+ (int)currentlyFeelsLike

Return Value

Current “feels like” temperature; this is automatically converted between Celsius and Farenheit

Declared In

IS2Weather.h

+ currentPressure

The current pressure in millibars (typically around 900-1100)

+ (CGFloat)currentPressure

Return Value

Current atmospheric pressure

Declared In

IS2Weather.h

+ sunsetTime

The time sunset will occur, in the format hours:minutes (eg 16:23). This is automatically converted between 24hr and 12hr dependant on user settings

+ (NSString *)sunsetTime

Return Value

Formatted sunset time

Declared In

IS2Weather.h

+ sunriseTime

The time sunrise will occur, in the format hours:minutes (eg 16:23). This is automatically converted between 24hr and 12hr dependant on user settings

+ (NSString *)sunriseTime

Return Value

Formatted sunrise time

Declared In

IS2Weather.h

+ currentLatitude

The current latitude of the location used for weather data; either the local area if Location Services are enabled, or the first city in Apple’s Weather app if not.

+ (CGFloat)currentLatitude

Return Value

Current latitude

Declared In

IS2Weather.h

+ currentLongitude

The current longitude of the location used for weather data; either the local area if Location Services are enabled, or the first city in Apple’s Weather app if not.

+ (CGFloat)currentLongitude

Return Value

Current longitude

Declared In

IS2Weather.h

Forecasts

+ hourlyForecastsForCurrentLocation

Gives an array of HourlyForecast objects ( https://github.com/nst/iOS-Runtime-Headers/blob/master/PrivateFrameworks/Weather.framework/HourlyForecast.h ) representing the forecast for the next few hours. It’s not recommendeded to use this method if you are iterfacing with this API via JavaScript.

+ (NSArray *)hourlyForecastsForCurrentLocation

Return Value

An array of hourly forecasts

Declared In

IS2Weather.h

+ hourlyForecastsForCurrentLocationJSON

Gives JSON representing hourly forecasts.

+ (NSString *)hourlyForecastsForCurrentLocationJSON

Return Value

JSON representation of the hourly forecast, in the form of:
[
 {
  “time”: “15:00”, (Time is formatted as per the user’s locale)
  “condition”: 30, (The Yahoo.com condition code for this day)
  “temperature”: 1,
  “percentPrecipitation”: 30
 },
 {
  …
 }
]

Declared In

IS2Weather.h

+ dayForecastsForCurrentLocation

Gives an array of daily forecasts. These are in the form of DayForecast objects ( https://github.com/nst/iOS-Runtime-Headers/blob/master/PrivateFrameworks/Weather.framework/DayForecast.h ) - It’s not recommendeded to use this method if you are iterfacing with this API via JavaScript.

+ (NSArray *)dayForecastsForCurrentLocation

Return Value

An array of daily forecasts

Declared In

IS2Weather.h

+ dayForecastsForCurrentLocationJSON

Gives JSON representing daily forecasts.

+ (NSString *)dayForecastsForCurrentLocationJSON

Return Value

JSON representation of the daily forecast, in the form of:
[
 {
  “dayNumber”: 1, (Index of the day in the data)
  “dayOfWeek”: 3, (Sunday is treated as day 1, with Saturday as day 7)
  “condition”: 30, (The Yahoo.com condition code for this day)
  “high”: 15,
  “low”: 10
 },
 {
  …
 }
]

Declared In

IS2Weather.h