• 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
Re: Returning a nil float?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Returning a nil float?


  • Subject: Re: Returning a nil float?
  • From: Andrew Merenbach <email@hidden>
  • Date: Fri, 29 Jan 2010 16:49:06 -0800

On Jan 29, 2010, at 4:44 PM, Chunk 1978 wrote:

> i'm almost 100% sure it's not possible to return a nil on basic data
> types, but just incase i'll post the question.
>
> ------------------------------------------------------
> - (float)panForSoundWithName:(NSString *)soundName
> 	{
> 	OpenALSound *sound = [soundDictionary objectForKey:soundName];
> 	if (!sound) return 0.0f;
> 	return sound.pan;
> 	}
> ------------------------------------------------------
>
> so above i'd like to write "if (!sound) return nil;".  my reasoning is
> because some attributes to a sound object (like pan) are created only
> when the sound is initialized.  if there is no sound object than there
> should also be no pan value to return.  unfortunately, the float
> default 0.0f is also the default value for pan (range from -1.0 to
> 1.0).

If you look at the definition for nil, it's typedef'd to NULL and cast as (void *)0 in stddef.h.  Thus you'd be returning the middle of your range regardless.  You'll probably have to refactor your code somehow.

Best,
	Andrew_______________________________________________

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

References: 
 >Returning a nil float? (From: Chunk 1978 <email@hidden>)

  • Prev by Date: Working with external drives with Cocoa.
  • Next by Date: Re: mouseEntered/-mouseExited not firing on drag (NSTrackingEnabledDuringMouseDrag on)
  • Previous by thread: Re: Returning a nil float?
  • Next by thread: Re: Returning a nil float?
  • Index(es):
    • Date
    • Thread