Monday, May 28, 2012

iOS - Performing Runtime Compatibility Checks


  • Check platform geometry   
      if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)




  • Check deployment platform  
      if ([[UIDevice currentDevice].model isEqualToString:@"iPad"]) 




  •   Check system prefix       
       if ([[[UIDevice currentDevice] systemVersion] hasPrefix:@"5."])    




  •  Check for properties using key-value coding    
       UILabel *label = (UILabel *)[cell valueForKey:@"textLabel"];
       if (label) [label setText:celltext]; 



  •   Check for class existence    
               if (NSClassFromString(@"NSAttributedString")) . . .



  •  Check for function existence       
       if(&UIGraphicsBeginImageContextWithOptions != NULL) . . .



  •   Check for selector compliance    
        if ([cell respondsToSelector:@selector(selectorName:)])    

No comments:

Post a Comment