Rays of wisdom


Stickies for an ageing brain

Simplify your code using Dictionaries

Published by Marian on Tuesday, November 11, 2008 7:12 PM

Too complicated conditions?

if ([[self stateName] isEqual:@"Square"])
{
if (self.clockwise)
{
return @"Animating around four points, clockwise";
}
else
{
return @"Animating around four points, anti-clockwise";
}
}
else if ([[self stateName] isEqual:@"Triangle"])
{
if (self.clockwise)
{
return @"Animating around three points, clockwise";
}
else
{
return @"Animating around three points, anti-clockwise";
}
}

or

if ([[stateController stateName] isEqual:@"Square"])
{
[path fill];
}
else if ([[stateController stateName] isEqual:@"Triangle"])
{
[path stroke];
}


Keep it simple!



return [self.selectedItem objectForKey:[self clockwiseKey]];

and

SEL drawSelector = NSSelectorFromString(
[stateController.selectedItem objectForKey:@"drawSelector"]);
[path performSelector:drawSelector withObject:nil];


Source

Back

Published by Marian on 3:06 AM

I'm back, with a new theme layout, and hopefully with more content.

 

Lipsum

Rays of wisdom
Notepad entries by Marian Mihailescu.

Followers