1
votes

I'm a c++ developer who is transitioning into the iPhone world, and I would love to get help around something.

Let's say for example, MPMoviePlayerController used to post the MPMoviePlayerContentPreloadDidFinishNotification notification in iOS 3.1 and earlier.

However, now this notification is deprecated.

I want my app to be able to run on every iPhone that has iOS 3 and above.

If I'm developing using base sdk 4.2, when I'm installing my app on an iphone with iOS 3.2 what will happen? Does the app comes with the sdk linked to it (like mfc static link for example)?

If I understand correctly, on iPhone with iOS 3.2 for example, that notification will still get called. (If i'm calling a function on an earlier sdk, assuming it's not statically linked like I asked above).

Does that mean that if I'm writing a new app now, I still have to take care of those deprecated notifications?

I can't get my head around this and would appreciate any explanation.

Thanks

1

1 Answers

2
votes

If you use a symbol that was included with iOS 4.2 on a device that is running 3.2 you will encounter a crash.

The way to get around this is to use new symbols conditionally based on whether or not they're available at runtime.

Eg.

if (&NewNotificationSymbol != NULL)
{
    // awesome, it's not NULL, we can use it
}
else
{
    // not so awesome, we'll use the old, deprecated one
    // but at least we won't crash
}

The same approach can be used for Classes that are new in 4.x when running on 3.x too:

if (NSClassFromString(@"MyAwesomeNewClass") != nil)
{
    // awesome, it's not NULL, we can use it
}
else
{
    // not so awesome, we'll use the old, deprecated one
    // but at least we won't crash
}

As a rule of thumb, you should always compile and link against the latest iOS SDK provided with the developer tools and then set your Deployment Target build setting to the oldest version of iOS that you wish to support. Then use these conditionals to make use of new features and gracefully fallback without crashing if they're not available.