• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Singleton or class methods?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Singleton or class methods?


  • Subject: Singleton or class methods?
  • From: Trygve Inda <email@hidden>
  • Date: Sat, 13 Sep 2014 05:45:06 -0700
  • Thread-topic: Singleton or class methods?

I have a project that involves several different targets.

Included in all this is a set of related utility methods that need to be
used by different sections of the code. I am wondering how is the best way
to do this so that I don't have the same utility methods written in
different places.

1. I could make a class MyUtilities that consisted of the 10 or so methods
as class methods and the class would have no instance methods or instance
variables.

2. I could make a singleton that put the methods as instance methods, but
also had no instance variables.

Thoughts?

I can't really make these methods a category on anything else.

These methods are used to convert between an NSScreen, CGDirectDisplayID,
io_service_t, and a few other ways of dealing with screen identification. So
a category on NSScreen is not going to work since in some cases an NSScreen
is not known/used.

Trygve




_______________________________________________

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


  • Follow-Ups:
    • Re: Singleton or class methods?
      • From: Jens Alfke <email@hidden>
    • Re: Singleton or class methods?
      • From: Alex Zavatone <email@hidden>
    • Re: Singleton or class methods?
      • From: Ken Thomases <email@hidden>
    • Re: Singleton or class methods?
      • From: ChanMaxthon <email@hidden>
  • Prev by Date: Re: Apple event for "open contents": re-entry and multiple qualifying services
  • Next by Date: Re: Singleton or class methods?
  • Previous by thread: Re: Disable document save alert when closing inspector panel
  • Next by thread: Re: Singleton or class methods?
  • Index(es):
    • Date
    • Thread