Re: What is the default type for an integer literal (as relates to its use in NSLog)?
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