OCPrayerTimes Reference
Objective-C Library for Muslim Prayer Times
OCPrayerTimes is an Objective-C library for calculating Muslim Prayer Times. Modified version of the original source code written by Hamid Zarrabi-Zadeh and Hussain Ali from PrayTimes.org. The source code was modified by Sumardi Shukor for taking advantage of modern Objective-C language such as ARC, object literals, etc.
Requirements
OCPrayerTimes 0.1.0 and higher requires Xcode 5, targeting either iOS 6.0 and above, or Mac OS 10.8 Mountain Lion (64-bit with modern Cocoa runtime) and above.
The following Cocoa frameworks must be linked into the application target for proper compilation:
- CoreLocation.framework
Installation
CocoaPods (Recommended)
CocoaPods is the recommended way to add OCPrayerTimes to your Xcode project.
Here’s an example Podfile
that installs OCPrayerTimes.
Podfile
platform :osx, '10.8'
pod 'OCPrayerTimes', '~> 0.1.0'
Then run pod install
.
Manual
Just add PrayTime.h
and PrayTime.m
to your Xcode project.
Examples
Depending on how you configure your project you may need to #import
either <OCPrayerTimes/PrayTime.h>
or "PrayTime.h"
.
Getting prayer times for a given longitude and latitude
PrayTime *prayerTime = [[PrayTime alloc] initWithJuristic:JuristicMethodShafii
andCalculation:CalculationMethodMWL];
NSMutableArray *prayerTimes = [prayerTime prayerTimesDate:[NSDate date]
latitude:3.1667
longitude:101.7000
andTimezone:[prayerTime getTimeZone]];
NSLog(@"%@", prayerTimes);
Getting prayer times from current user location
- (void)viewDidLoad
{
[super viewDidLoad];
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.distanceFilter = kCLDistanceFilterNone;
self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
self.locationManager.delegate = self;
[self.locationManager startUpdatingLocation];
prayTime = [[PrayTime alloc] initWithJuristic:JuristicMethodShafii
andCalculation:CalculationMethodMWL];
[prayTime setTimeFormat:TimeFormat12Hour];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *location = [locations lastObject];
praytime = [prayTime prayerTimesFromLocation:location
forDate:[NSDate date]];
}
License
OCPrayerTimes is available under the MIT license (see LICENSE file).
PrayTimes is free software; it is released under a GNU LGPL v3.0 license that allows you to do as you wish with it as long as you don’t attempt to claim it as your own work.
Reference
Support
Bugs and feature request are tracked on Github
Credit
The code on which this package is based, is principally developed and maintained by Sumardi Shukor.