Re: Dumb newbie question about objects and scalars
Re: Dumb newbie question about objects and scalars
- Subject: Re: Dumb newbie question about objects and scalars
- From: "Martin" <email@hidden>
- Date: Mon, 14 Mar 2005 15:36:37 -0800
I would leave your enum typedef intact and just box the values in NSNumbers when you need. So instead of the ugly:
>switch ( [theBehavior intValue] )
> case [GLFreeform intValue]: {...}
> case [GLSlugline intValue]: {...}
> case [GLAction intValue]: {...}
You do:
switch( [theBehavior intValue] )
case GLCharacter: { ... }
case GLParenthetical: { ... }
You could also make your code even prettier by adding a category to NSAttributedString that defines:
- (GLBehaviorStyle) behaviorStyleAtIndex:(unsigned)idx effectiveRange:(NSRange*)rngPtr
{
NSDictionary* attrs = [self attributesAtIndex:idx effectiveRange:rngPtr];
NSNumber* valueObj = [attrs objectForKey:GLBehaviorStyleAttributeName];
return (nil == valueObj) ? GLBehaviorStyle_DEFAULT : [valueObj intValue];
}
~Martin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden