• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Why doesn't this crash?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why doesn't this crash?


  • Subject: Why doesn't this crash?
  • From: Andreas Falkenhahn <email@hidden>
  • Date: Sat, 10 Sep 2016 13:39:50 +0200

I want my app to run on 10.6 but use 10.7 features where available. Thus I'm
compiling on 10.11 using -mmacosx-version-min=10.6. In particular, I want to
use AVFoundation to play videos on 10.7 and better.

To open a video, I do the following:

    AVPlayer *p = [[AVPlayer alloc] initWithURL:url];

I'd expect this code to crash on 10.6 because 10.6 doesn't have AVPlayer.
To my surprise, however, the code doesn't crash and it just returns NULL.
This is fine because then my app will just show a message box informing
the user that the file couldn't be opened and no other AVFoundation APIs
will be accessed.

However, I'm wondering whether it is ok to execute this code on 10.6 without
any safeguard. I thought I'd have to do something like this instead:

    if(floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_7) {

        AVPlayer *p = [[AVPlayer alloc] initWithURL:url];
        ...

    } else {

        return NULL;
    }

Do I have to do this or can I just rely on alloc/init returning NULL for
classes unknown on 10.6?

--
Best regards,
 Andreas Falkenhahn                          mailto:email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Why doesn't this crash?
      • From: Greg Parker <email@hidden>
    • Re: Why doesn't this crash?
      • From: Alastair Houghton <email@hidden>
    • Re: Why doesn't this crash?
      • From: Pascal Bourguignon <email@hidden>
  • Prev by Date: Re: C callbacks with NSNotificationCenter?
  • Next by Date: Linking against AVKit breaks app on 10.6
  • Previous by thread: Re: Can you have a helper scripts in a sandboxed app?
  • Next by thread: Re: Why doesn't this crash?
  • Index(es):
    • Date
    • Thread