views:

167

answers:

2

I'm using UIGestureRecognizer for the first time and I want my app to run on iOS 3.0 onwards. Since Apple clearly states that the library is available in iOS 3.2 and later I used the following code:

// Make sure that Gesture recognition technology is supportted by the device SDK version
if ([UIGestureRecognizer instancesRespondToSelector:@selector(initWithTarget:action:)])
{
    [self initGestureRecognizers];
}

Surprisingly, when I run the App on the only target I have, that run SDK3.0, it works fine.


I replaced the condition to the following:

if ([[[UIDevice currentDevice] systemVersion] compare:@"3.2"] != NSOrderedAscending) 
{ 
    [self initGestureRecognizers]; 
}

I would love to get comments about it.

Thanks

+4  A: 

That's probably because UIGestureRecognizer was considered private before 3.2. Don't be surprised if some things are buggy or don't quite work as expected if you use UIGestureRecognizer under 3.0.

Johan Kool
It's exactly like that. I also noticed that the UIGestureRecognizer and some of the concrete classes like `UITapGestureRecognizer` (IIRC) do exist on 3.0 but are considered to be Apple-private, i.e. not to be used by applications. They don't implement everything that is now documented, e. g. I think there was no `numberOfTapsRequired` property at `UITapGestureRecognizer`.
DarkDust
The following seems to be working OK. What do you think? if ([[[UIDevice currentDevice] systemVersion] compare:@"3.2"] != NSOrderedAscending) { [self initGestureRecognizers]; }
Tzur Gazit
+1  A: 

There are tons of undocumented APIs in every iOS release, and Apple does mention this. However use of these undocumented APIs is grounds for an App store rejection. There may well be a risk of rejection from using an API that in undocumented in one given release/revision of the OS, but documented in another, both of which your app supports.

hotpaw2