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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to