Creating and employing color constants
Creating and employing color constants
- Subject: Creating and employing color constants
- From: Helen Cooper <email@hidden>
- Date: Mon, 1 Dec 2008 13:04:24 -0800 (PST)
I have defined a color palette I want to access routinely as UIColor objects, but I am not convinced I am taking the right approach, particularly in regard to managing memory and minimizing memory used. I have defined a bunch of colors as follows, and am wondering if there is a better way to do this ? Newbie question for sure.
//
// ConstantsColors.h
#import <UIKit/UIKit.h>
@interface ConstantsColors : NSObject {
}
+(UIColor *)myColorGrayA;
+(UIColor *)myColorGrayB;
....etc...
@end
//
// ConstantsColors.m
#import "ConstantsColors.h"
@implementation ConstantsColors
+(UIColor *)myColorGrayA
{
UIColor* myColorGrayA;
myColorGrayA = [UIColor colorWithRed:150.0/255.0 green:150.0/255.0 blue:150.0/255.0 alpha:1.0];
return myColorGrayA;
}
+(UIColor *)myColorGrayB
{
UIColor* myColorGrayB;
myColorGrayB = [UIColor colorWithRed:200.0/255.0 green:200.0/255.0 blue:200.0/255.0 alpha:1.0];
return myColorGrayB;
}
-(void) dealloc
{
[super dealloc];
}
@end
// then, in a consumer class...
//
#import "ConstantsColors.h"
....
aViewA.backgroundColor = [ConstantsColors myColorGrayA];
....
aViewB.backgroundColor = [ConstantsColors myColorGrayB];
thanks for any help...
_______________________________________________
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