Detect if app is running in Slide Over or Split View mode in iOS 9

Just check if your window occupies the whole screen: BOOL isRunningInFullScreen = CGRectEqualToRect([UIApplication sharedApplication].delegate.window.frame, [UIApplication sharedApplication].delegate.window.screen.bounds); If this is false, then you’re running in a split view or a slide over. Here is the code snipped which will automatically maintain this flag irrespective of rotation -(void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection { // simply create a property of ‘BOOL’ … Read more

How to pin the Public key of a certificate on iOS

In case you are in need of knowing how to extract this information from the certificate in your iOS code, here you have one way to do it. First of all add the security framework. #import <Security/Security.h> The add the openssl libraries. You can download them from https://github.com/st3fan/ios-openssl #import <openssl/x509.h> The NSURLConnectionDelegate Protocol allows you … Read more

get current date from [NSDate date] but set the time to 10:00 am

As with all date manipulation you have to use NSDateComponents and NSCalendar NSDate *now = [NSDate date]; NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSCalendarIdentifierGregorian]; NSDateComponents *components = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay fromDate:now]; [components setHour:10]; NSDate *today10am = [calendar dateFromComponents:components]; in iOS8 Apple introduced a convenience method that saves a few lines of code: NSDate *d = [calendar … Read more