Objective-C SDK
Install
Add the SDK files to your Xcode project — no external dependencies required:
Or compile from the command line:
Quick Start
#import "TNTimeNowClient.h"
#import "TNModels.h"
TNTimeNowClient *client = [[TNTimeNowClient alloc] initWithBaseURL:@"http://localhost:8090"];
// Solar time for London
[client getSolarWithLat:51.5074 lng:-0.1278 completion:^(TNSolarResult *result, NSError *error) {
if (error) {
NSLog(@"Error: %@", error.localizedDescription);
return;
}
NSLog(@"Solar noon: %@", result.solarNoon);
NSLog(@"Offset: %.1f min", result.civilSolarOffsetMin);
}];
// Social jetlag
[client getJetlagWithLat:39.47 lng:75.99 completion:^(TNJetlagResult *result, NSError *error) {
if (!error) {
NSLog(@"Risk: %@", result.riskLevel);
}
}];
Methods
| Method | Parameters | Completion Block | API endpoint |
|---|---|---|---|
getSolarWithLat:lng:completion: | lat, lng | TNSolarResult, NSError | GET /solar |
getJetlagWithLat:lng:completion: | lat, lng | TNJetlagResult, NSError | GET /solar/jetlag |
getPrayerWithLat:lng:date:completion: | lat, lng, date | NSDictionary, NSError | GET /solar/prayer |
getAlmanacWithLat:lng:year:completion: | lat, lng, year | NSDictionary, NSError | GET /solar/almanac |
getReformWithLat:lng:completion: | lat, lng | NSDictionary, NSError | GET /solar/reform |
getHealthWithCompletion: | — | NSDictionary, NSError | GET /health |
Types
@interface TNTimeNowClient : NSObject
@property (nonatomic, copy) NSString *baseURL;
- (instancetype)initWithBaseURL:(NSString *)baseURL;
@end
@interface TNSolarResult : NSObject
@property (nonatomic) double lat, lng;
@property (nonatomic, copy) NSString *localSolarTime, *solarNoon;
@property (nonatomic, copy, nullable) NSString *sunrise, *sunset;
@property (nonatomic) double solarElevationDeg, civilSolarOffsetMin;
+ (instancetype)fromDictionary:(NSDictionary *)dict;
@end
@interface TNJetlagResult : NSObject
@property (nonatomic, copy) NSString *riskLevel, *verdict, *equivalentFlight;
@property (nonatomic) double civilSolarOffsetMin, weeklySleepLossMin, annualSleepLossH;
+ (instancetype)fromDictionary:(NSDictionary *)dict;
@end
Error Handling
All methods use block-based completion with NSError:
[client getSolarWithLat:999 lng:0 completion:^(TNSolarResult *result, NSError *error) {
if (error) {
NSLog(@"HTTP %ld: %@", (long)error.code, error.localizedDescription);
}
}];
Uses NSURLSession (Foundation framework) — no third-party dependencies.