Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6214633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:54:43+00:00 2026-05-24T06:54:43+00:00

My singleton global class has all these categeories in same class , in header

  • 0

My singleton global class has all these categeories in same class, in header file their interfaces and in implemantation file their implementations as below,

This works, but I am not quite sure what I am doing is good practise here because it is a singleton class already and I am calling these methods as categories and doing some allocates, releases..and stuff. or they are alreday outside of the global class cause they are different implemantations?

Can you tell me if everything is correct here?

#import "GlobalConfig.h"
#import "SynthesizeSingleton.h"
@implementation GlobalConfig
SYNTHESIZE_SINGLETON_FOR_CLASS(GlobalConfig);
@end

@implementation UIColor (APP)
+(UIColor *) APP_NAV_COLOR { return [UIColor colorWithRed:00/256.0 green:111/256.0    
                                                 blue:59/256.0 alpha:1.0]; }
+(UIColor *) APP_BUTTON_COLOR { return [UIColor colorWithRed:00/256.0 green:00/256.0    
@end

@implementation UIImage(APP)
+(UIImage *) APP_IMAGE_BCKGROUND {

NSString *path = [[NSBundle mainBundle] pathForResource:@"bckPhone" ofType:@"png"];
return [UIImage imageWithContentsOfResolutionIndependentFile:path]; 
}
@end

@implementation CALayer(APP)
+(CALayer *) APP_SELECTION_VIEW:(UITableViewCell *)cell {
UIView *cellView = [[UIView alloc] initWithFrame:cell.frame];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = cellView.bounds;   
gradient.startPoint = CGPointMake(0.5, 0);
gradient.endPoint = CGPointMake(0.5, 1);
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor APP_WHITE_COLOR] CGColor],    (id)[[UIColor APP_BLACK_COLOR] CGColor], nil];  
[cellView release];
return gradient;
}
@end

@implementation UIView(APP)
+(UIView *) APP_BACKGROUND_VIEW:(UITableViewCell *)cell {
UIView *cellView2 = [[UIView alloc] initWithFrame:cell.frame];
CAGradientLayer *gradient2 = [CAGradientLayer layer];
gradient2.frame = cellView2.bounds;
gradient2.startPoint = CGPointMake(0, 0.5);
gradient2.endPoint = CGPointMake(1, 0.5);
gradient2.colors = [NSArray arrayWithObjects:(id)[[UIColor APP_WHITE_COLOR] CGColor], (id)[[UIColor APP_COLOR] CGColor], nil];
[cell.layer insertSublayer:gradient2 atIndex:0];
[cellView2 release];
UIView *myBackView = [[UIView alloc] initWithFrame:cell.frame];
 myBackView.backgroundColor=[[UIColor APP_COLOR] colorWithAlphaComponent:0.1];
[myBackView autorelease];
return myBackView;
}
@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:54:44+00:00Added an answer on May 24, 2026 at 6:54 am

    If you want to extend existing classes (i.e., CALayer, UIImage, and UIColor) through categories, you don’t need a singleton.

    A singleton is a class that you use to instantiate a single object (and have a guarantee at that is unique). A category is a way to extend an existing interface, without adding any ivars (only methods) and due to this you don’t need to instantiate a category before using it. So categories and singletons responds to different requirements and there is no need to mix them.

    You can simply define your categories like you do, and then use them with your UIView, UIColor and CALAyer objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the benefit of using singleton instead of global for database connections in
The singleton is explained here: http://en.wikipedia.org/wiki/Singleton_pattern#PHP_5 . I want to use the singleton class
I have a C# singleton class that multiple classes use. Is access through Instance
I created a class which allows access to global access to a variable while
I am trying to use the singleton method to access a global object (in
Having the code below in my Global.asax.cs and two controller (one based on a
I have a singleton that holds a lot of information on my App (ACCU.class).
Is there any possibility to create a configuration file with global variables that are
I'm currently overriding the default ModelMetadataProvider in the Global.asax file using this ModelMetadataProviders.Current =
What's the best way to save the data stored in the Application Class (singleton)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.