• 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: What is the default type for an integer literal (as relates to its use in NSLog)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is the default type for an integer literal (as relates to its use in NSLog)?


  • Subject: Re: What is the default type for an integer literal (as relates to its use in NSLog)?
  • From: Nick Zitzmann <email@hidden>
  • Date: Mon, 15 Dec 2008 13:50:11 -0700


On Dec 15, 2008, at 1:39 PM, Stuart Malin wrote:

and define a method that takes the option as a parameter

- (void) someMethodWithOption:(MyOptionValue)optionVlaue;

Question: Should I force MyOptionValue to be an NSUInteger? If so, how would I achieve that? (Sorry, my C is weak).


It depends. On one hand, I see no reason not to just keep that 32-bit (unless you have a very good reason), but if you do so, and you pass in, say, menu tags, then you'll have to cast the return value or else that warning I mentioned earlier will sound. OTOH, you won't have to cast anything if you make it an NSInteger typedef, but you do lose the warning that would normally appear if not all cases are handled in a switch. So which is more important to you?

If you want to make an NS(U)Integer typedef, then you do what Apple does:

enum
{
	YOBlahBlah = 0,
	YOBlahBlah2
};
typedef NSUInteger YourOptions;

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

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: What is the default type for an integer literal (as relates to its use in NSLog)?
      • From: Stuart Malin <email@hidden>
References: 
 >What is the default type for an integer literal (as relates to its use in NSLog)? (From: Stuart Malin <email@hidden>)
 >Re: What is the default type for an integer literal (as relates to its use in NSLog)? (From: Nick Zitzmann <email@hidden>)
 >Re: What is the default type for an integer literal (as relates to its use in NSLog)? (From: Stuart Malin <email@hidden>)

  • Prev by Date: Re: - [NSBitmapImageRep tiffRepresentation] malloc error
  • Next by Date: Re: What is the default type for an integer literal (as relates to its use in NSLog)?
  • Previous by thread: Re: What is the default type for an integer literal (as relates to its use in NSLog)?
  • Next by thread: Re: What is the default type for an integer literal (as relates to its use in NSLog)?
  • Index(es):
    • Date
    • Thread