A weather fetching library for jailbroken iOS devices
- Fetches weather using
Weather.framework
- Simple and easy to use
- Options to fit your needs
- Current condition string (48 conditions, not including severe weather alerts)
- Current condition image (supports day and night images)
- Current temperature (supports Celsius, Fahrenheit, and Kelvin, but defaults to the user's preferred unit)
- Feels like temperature (supports Celsius, Fahrenheit, and Kelvin, but defaults to the user's preferred unit)
- Wind speed (supports kilometers per hour and miles per hour, but defaults to the user's preferred unit)
- Wind direction
- Current city name
- Daily high and low temperatures
- Humidity
- Visibility
- Listen for weather update notifications
- Fetch weather data on demand
- Set the weather auto update interval (default is 5 minutes)
- Set the distance threshold to consider the location as changed (default is 1 mile)
- Choose whether to support severe weather alerts, which applies to both condition strings and images (default is NO)
- Set the temperature unit (default is the user's preferred unit)
- Set the speed unit (default is the user's preferred unit)
- Multilingual support
I should preface by saying that this library does not do anything on its own. It is meant to be used by developers in their projects.
With that being said, if you still wish to install this library, it can be downloaded from havoc at https://havoc.app/package/libdcweather.
If you wish to integrate this library into your project, you can follow the instructions below.
Run the following command to install the library to your Theos environment
./install_to_theos.sh
You will need to add it to the libraries in your project makefile
TWEAKNAME_LIBRARIES = dcweather
You must also add it to your project's control file, like so
Depends: mobilesubstrate, com.dcproducts.libdcweather
Then you can import the library into your tweak and start using it
#import <libDCWeather.h>
There are two ways to initialize the library. You can either use the shared instance or create a new instance, depending on your needs.
// Shared instance
DCWeather *weather = [DCWeather sharedInstance];
// New instance
DCWeather *weather = [[DCWeather alloc] init];
There are three ways to set the auto-update interval. The default is 5 minutes, but you can either set it to a specific number of seconds, minutes, or hours.
// Seconds
[weather setAutoUpdateInvervalInSeconds:30];
// Minutes
[weather setAutoUpdateInvervalInMinutes:5];
// Hours
[weather setAutoUpdateInvervalInHours:1];
You can set the distance threshold to consider the location as changed. The default is 1 mile, but you can change it to your liking.
// Meters
[weather setDistanceThresholdToConsiderLocationChangeInMeters:100];
// Kilometers
[weather setDistanceThresholdToConsiderLocationChangeInKilometers:1];
// Feet
[weather setDistanceThresholdToConsiderLocationChangeInFeet:500];
// Yards
[weather setDistanceThresholdToConsiderLocationChangeInYards:250];
// Miles
[weather setDistanceThresholdToConsiderLocationChangeInMiles:2];
You can choose whether to support severe weather alerts. This applies to both condition strings and images. The default is NO but you can change it to YES if you wish to support severe weather alerts.
[weather conditionIncludesSevereWeather:YES];
You can set the temperature unit to either Celsius, Fahrenheit, or Kelvin. The default is the user's preferred unit, but you can change it to your liking.
// To set it to Celsius
[weather setTemperatureUnit:Celsius];
// To set it to Fahrenheit
[weather setTemperatureUnit:Fahrenheit];
// To set it to Kelvin
[weather setTemperatureUnit:Kelvin];
You can set the speed unit to either kilometers per hour or miles per hour. The default is the user's preferred unit, but you can change it to your liking.
// To set it to kilometers per hour
[weather setSpeedUnit:KilometersPerHour];
// To set it to miles per hour
[weather setSpeedUnit:MilesPerHour];
Weather will automatically update based on the auto-update interval you set. However, if you wish to force a weather update, you can do so at any point by calling the following method.
[weather requestRefresh];
NSString *temperature = [weather temperatureString];
double temperature = [weather temperature];
NSString *feelsLikeTemperature = [weather feelsLikeTemperatureString];
double feelsLikeTemperature = [weather feelsLikeTemperature];
NSString *condition = [weather conditionString];
UIImage *conditionImage = [weather conditionImage];
NSString *windSpeed = [weather windSpeedString];
double windSpeed = [weather windSpeed];
NSString *windDirection = [weather windDirectionString];
NSString *city = [weather cityString];
You can listen for updates by adding an observer to the default notification center. Currently, you can listen for the temperature, feels like temperature, location, condition, wind speed, and wind direction changes.
// Assuming you wish to invoke the weatherChanged method when the weather changes
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(weatherChanged)
name:@"kDCWeatherChange"
object:nil];
// Assuming you wish to invoke the temperatureChanged method when the temperature changes
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(temperatureChanged)
name:@"kDCWeatherTemperatureChange"
object:nil];
// Assuming you wish to invoke the feelsLikeTemperatureChanged method when the feels like temperature changes
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(feelsLikeTemperatureChanged)
name:@"kDCWeatherFeelsLikeTemperatureChange"
object:nil];
// Assuming you wish to invoke the locationChanged method when the location changes
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(locationChanged)
name:@"kDCWeatherLocationChange"
object:nil];
// Assuming you wish to invoke the conditionChanged method when the condition changes
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(conditionChanged)
name:@"kDCWeatherConditionChange"
object:nil];
// Assuming you wish to invoke the windSpeedChanged method when the wind speed changes
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windSpeedChanged)
name:@"kDCWeatherWindSpeedChange"
object:nil];
// Assuming you wish to invoke the windDirectionChanged method when the wind direction changes
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windDirectionChanged)
name:@"kDCWeatherWindDirectionChange"
object:nil];
If you like the project and wish to support my work, please consider donating. Your support is greatly appreciated.
Developed and maintained by dtcalabro
- libDCWeather is available under the GPLv3 license. See the LICENSE file for more info.
- Please don't steal my work! I spent a lot of time making this come to life, so if you wish to use this library in your project, please give credit where credit is due.