• 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
Strange cast for CFURLRef
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Strange cast for CFURLRef


  • Subject: Strange cast for CFURLRef
  • From: Patrick Burleson <email@hidden>
  • Date: Tue, 31 Mar 2009 12:32:28 -0500

Hello all,

I've been going through the SpeakHere sample code from the iPhone SDK
and trying to repurpose some of the code for what I'm working on.

I ran into something I don't quite understand and was hoping to get
some enlightenment. There's a method defined on AudioPlayer that goes
like this:

- (id) initWithURL: (CFURLRef) fileURL;

In the code I'm using to call it I have the following:

NSString *thePath = [[NSBundle mainBundle] pathForResource:@"MySound"
ofType:@"aiff"];
CFURLRef fileURL = CFURLCreateWithFileSystemPath (
												   NULL,
												   (CFStringRef) thePath,
												   kCFURLPOSIXPathStyle,
												   false
										   );
AudioPlayer *thePlayer = [[AudioPlayer alloc] initWithURL: (NSURL *)fileURL];

The question I have is on the line:

AudioPlayer *thePlayer = [[AudioPlayer alloc] initWithURL: (NSURL *)fileURL];

Why does fileURL have to be cast to NSURL * when initWithURL wants a
CFURLRef? Without that cast, I get a compile error about incompatible
types.

It appears the reason for the CFURLRef is that's what the lower level
Sound Toolbox calls need, but why all the casting at the higher levels
when it could just be a NSURL until the time when the toll free bridge
cast to CFURLRef is needed for those calls?

Any insight would be greatly appreciated.

Thanks,
Patrick
_______________________________________________

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: Strange cast for CFURLRef
      • From: Jim Correia <email@hidden>
  • Prev by Date: How to animate the drawing of UIImages inside a drawRect: method of a UIView?
  • Next by Date: [BUG] Cursor Flicker
  • Previous by thread: CABasicAnimation causes crash on close/order out of window
  • Next by thread: Re: Strange cast for CFURLRef
  • Index(es):
    • Date
    • Thread