View Single Post
Quote:
But I can't figure out how to set text placement. This shows as an enum.
I need to make that an object so that it can be added to the dictionary which I'm using as properties to initialize the shape (initWithProperties)...
OK... Finally figured it out. I know enums are supposed to be simple, but I sure had a hard time figuring out how to use them.
It is easiest just to show a code snippet. I've broken it down to several steps...
1. properties are passed using an NSDictionary. In this example: graffleProperties
2. As I understand now, emun is just an integer. So, I get the integer value using int textPlacementInt = (OmniGraffleOGva)OmniGraffleOGvaTop; // Not sure if there is a better way, but this works.
3. NSDictionary needs an object, not scalar value. So, turn the int into an NSNumber.
4. Now you are set to add the key / value pair to the dictionary using the key @"textPlacement" and the NSNumber representation of (OmniGraffleOGva)OmniGraffleOGvaTop

I hope this helps somebody other than me. :)

Code:
NSMutableDictionary *graffleProperties = [NSMutableDictionary dictionaryWithCapacity:10];
int textPlacementInt = (OmniGraffleOGva)OmniGraffleOGvaTop;
NSNumber *textPlacementNumber = [NSNumber numberWithInt:textPlacementInt];
NSLog(@"JBHDiagramController - omniGrafflePropertiesForPolygonShape: textPlacementInt: %d", textPlacementInt);
[graffleProperties setObject:textPlacementNumber forKey:@"textPlacement"];