UIAlertController if iOS 8, otherwise UIAlertView

后端 未结 11 2008
清酒与你
清酒与你 2020-12-16 10:19

I want to conform to the UIAlertController used in iOS 8 since UIAlertView is now deprecated. Is there a way that I can use this without breaking support for iOS 7? Is there

11条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 10:48

    I think a much better way to check if a class exists (since iOS 4.2) is:

    if([ClassToBeChecked class]) {
    
       // use it
    
    } else {
    
      // use alternative
    
    }
    

    In your case, that would be:

    if ([UIAlertController class]) {
       // use UIAlertController
    
    } else {
      // use UIAlertView
    
    }
    

提交回复
热议问题