Enabling various features depending on the version of iOS

In the application we are creating, we want to use the UILocalNotifications, which are available only with 4.0.

Verifying that the object responds to the selector is pretty simple, but how can I define delegate methods for a class depending on the OS? The problem is that my application delegate implements

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification 

which causes the application to crash when launched on an iOS 3.2 (ipad) device.

It was not necessary to release several assemblies.

+3
source share
4 answers

" ", iOS 3.1 . , 4.2 " " ( " " ).

!

+6

:

#ifdef __IPHONE_4_0 // if iPhoneOS is 4.0 or greater then __IPHONE_4_0 will be defined

    //code
#endif

4.0, - .

+3
0

, id , 3.2, :

-(void)application:(UIApplication *)application didReceiveLocalNotification:(id)notification 

UILocalNotification . notification UILocalNotification.

I am surprised that this leads to a failure, since the method should not be called. If changing the type in the method definition does not help, the method may be called for some reason. In this case, try setting a breakpoint in the method to find out why.

-1
source

Source: https://habr.com/ru/post/1778133/


All Articles