views:

33

answers:

1

Hello everyone !

I know it is forbidden to use private API functions or classes, because they can change in a future version of iOS. So I wondering if it is allowed if a private function is now public in a new iOS.

My example is MPMoviePlayerController which has a private property called currentTime in iOS before 3.2. Starting version 3.2, it is called currentPlaybackTime and can be used. If it can be used in newer versions, can it be used in older ?

Thanks

+1  A: 

No, on older version of iOS the property is still private, we can only guess at reasons why.

In cases like this, you should take the same approach as you would when looking to support new features that aren't available in a previous OS: use them conditionally based on availability.

If you want to use the currentPlaybackTime property, you should weak-link against the framework in which it is declared and do a runtime check for its availability.

Something like this:

if ([playerController respondsToSelector:@selector(currentPlaybackTime)])
{
    // do something with currentPlaybackTime
}
else
{
    // fail-over to something supported and not private.
}

Remember: when compiling your iOS app, you should be compiling against the lastest-and-greatest iOS SDK version and setting your Deployment Target setting to the oldest version of iOS that you're willing to support.

Jasarien
+1 As a side note, when the property keeps its name, this is one of the rare cases where you actually need to check the os version.
Eiko
Yeah.... Ok so I can't use this private property and I understand it. Now how can I play a video and get it's current time in older iOS, that's the question !
sui