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 773583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:59:18+00:00 2026-05-14T18:59:18+00:00

I have a bunch of functions which returns commonly used UIViews in my application,

  • 0

I have a bunch of functions which returns commonly used UIViews in my application, e.g.

+ (UIView *) getLikeRow:(CGRect) frame ofType:(LikeType) type

So far I’ve been using static methods for that, but recently I also noticed the sharedManager concept. Now I’m wondering if I should rather use a sharedManager for that.

What are the differences and advantages/disadvantages of using static methods vs. instance methods of a sharedManager singleton?

  • 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-14T18:59:19+00:00Added an answer on May 14, 2026 at 6:59 pm

    You use the singleton/shared-managed pattern when it is important that only one instance of a class be alive at anyone time.

    For example, it is important that an app have one and only one instance of UIApplication. You would want two instances of the application object because it would be impossible to keep them both in the same state. NSFileManager uses the pattern to prevent the app from having two file operations that collide with each other.

    Enforcing a unique instance at runtime is the only valid reason to use the singleton/shared-managed pattern.

    In your case, you just need a convenient place to park some utility class methods that don’t require a live instance in order to function. The best way to handle that is to create a utility class that bundles all the class methods together. Then to use the methods, you just send to the class name like so:

    UIView *theView=[MyViewUtilityClass getLikeRow:aRect ofType:aType];
    

    This causes the MyViewUtilityClass to call the method from anywhere in the app without having to initialize an object. It’s easier and neater than keeping a unique instance alive. If you use the utility methods throughout your app, you can add the header to the .pch universal header and all your custom classes will get the utility class automatically.

    However, just like the singleton pattern, utility class methods can tempt you into becoming lazy and overusing them in places they don’t really belong. Overused, they begin to make the app look like an old school, non-object oriented C collection of independent functions. This breaks encapsulation and modularity and makes your program a tangle of procedural code.

    So, be careful that you are only putting the most generic and most universal functions into the utility class. If you have a lot of functions that deal with a specific class, such a UIView and subclasses, then you should put the functions in a category on that class.

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

Sidebar

Related Questions

I have a url which returns a bunch of options tags. Can I stick
I have a bunch of strings representing mathematical functions (which could be nested and
I have a bunch of functions with signatures like: FUNCTION func1 (par1 IN VARCHAR2,
I have a bunch of functions like: method1 , method2 , method3 . For
My case is as follows : I have a bunch of functions and declarations
So I have a generic question. I have a bunch of functions, some of
I have a bunch of generated functions from a supplier's tool are required to
I have a bunch of overloaded functions that operate on certain data types such
I have an mxml file with a bunch of functions in the script tag,
In a multithreaded application. I have a bunch of function that loop through a

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.