3
votes

In iOS5 Apple has deprecated the use of [UIDevice uniqueIdentifier] (see here http://techcrunch.com/2011/08/19/apple-ios-5-phasing-out-udid/)

It currently still works, but obviously we want to migrate our app from using it. We can't quit cold turkey, but we are rolling out a migration strategy to persist user data without tying it to the actual physical device (our sole reason for abusing the device UDID).

This Stack Question gives a great alternative to using the UDID. So I have a new UDID to use.

I'm concerned about users who do not bother to upgrade our app, and end up updating their iOS version such that the deprecated call no longer works. Our code assumes the uniqueIdentfier call is guaranteed to always "work."

How can I check that the uniqueIdentifier call was successful, and if it wasn't use the alternative UDID presented in the question referenced above?

Can I check if the UIDevice responds to the selector? Can I check for a nil UDID?

1
[Putting Devil's advocate hat on] If you are worried that if your users don't update to the latest version of your app that it will break with a newer version of iOS, why would they update to a newer version of your app that degrades "gracefully" when a deprecated function is not present? :DPeter M
@PeterM: That is a good point, but unfortunately I can't control that. But I can control the fact that I've identified the issue, and we're having a new release shortly, so I can address that, and at least feel good aboot that. Also I'm not sure when the next-next release will be out, which will have the migration implemented, so this next version should be as robust as possible.Alan
I agree that you need to produce code as robust as possible. But as you know you can't control your users, so there is not point worrying about them and taking a "screw you" (in the nicest way) attitude over old versions can really free your development effort!Peter M
True enough. I suppose the bigger issue is, I may not get another release vehicle for sometime, so if we can't migrate users off of the UDID, the latest release shouldn't break if/when UDID support is removed.Alan

1 Answers

7
votes

You can check it with respondsToSelector: as usual. I've verified it with a selector that was removed in iOS 3.1:

#import <MediaPlayer/MediaPlayer.h>
...
MPMoviePlayerController *mc = [[MPMoviePlayerController alloc] initWithContentURL:nil];
if ([mc respondsToSelector:@selector(backgroundColor)]) {
    NSLog(@"YES");
} else {
    NSLog(@"NO"); /* under iOS 5 it goes here */
}
...