if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// The device is an iPad running iOS 3.2 or later.
}
else {
// The device is an iPhone or iPod touch.
}
一.本地通知
- (void)applicationDidEnterBackground:(UIApplication *)application
{
dispatch_async(dispatch_get_main_queue(), ^{
UILocalNotification * localNotification = [[UILocalNotification alloc] init];
if (localNotification) {
localNotification.fireDate= [[[NSDate alloc] init] dateByAddingTimeInterval:5];
localNotification.timeZone=[NSTimeZone defaultTimeZone];
localNotification.alertBody = @"客户端有新的版本,点击到App Store升级。";
localNotification.alertAction = @"升级";
localNotification.soundName = @"";
[application scheduleLocalNotification:localNotification];
}
});
}
二.判断是pad还是phone
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
// open app store link
NSString * url = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@", @"10123"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
三.是否有类或者有该方法
if ([UIPrintInteractionController class]) {
// Create an instance of the class and use it.
}
else {
// The print interaction controller is not available.
}
To determine whether a method is available on an existing class, use the instancesRespondToSelector: class method or the respondsToSelector: instance method.