40652

Is defining a property & synthesize for a variable in a singleton class allowed?

Question:

Defining a property & synthesize for a variable in a singleton class allowed?,like below in interface,

@property(nonatomic,assign)NSInteger value;

and in implementation file,

@synthesize value;

or we just have to declare a variable like below,

@interface SingletonDataClass : NSObject { NSInteger value; }

Answer1:

Anything that you can do with your regular classes you can do with singletons.

There is no language concept called "singleton", it is just a common usage pattern of regular Objective C classes. What makes a class a singleton is the way you ensure its instantiation happens only once, i.e. your own supporting code.

Recommend

  • How to Integrate CCAvenue with .Net Core API and angular 5 app?
  • python object attributes and methods
  • Retrieve date from Firebase, angularJS
  • sqrtf undefined reference to `sqrtf' in c
  • Sonarlint issues shown in eclipse not in bind Sonarqube project
  • Stored Procedure If / Then Statement
  • Sharepoint 2010 migration to sharepoint online using sharegate
  • How to upload audio file to s3 via api gateway?
  • do I have to release the NSDate in this code below?
  • Direction of target annotation when outside of visible area
  • Badge value on “More” tab
  • access an alertView's calling view
  • playing video in iOS 5
  • Change color of row programmatically in WatchKit
  • mapping between two ontologies
  • Using extern @class in order to add a category?
  • Comparing user's facebook/twitter friends to site's users in Python/Django
  • Mocha throws unexpected token error for ES6 object spread operator
  • Why can't UI components be accessed from a backgroundworker?
  • Criterion causing memory consumption to explode, no CAFs in sight
  • Need code translation from VB to C#
  • Best practice to eliminate magic numbers within a member function
  • abstracting over a collection
  • Can't remove headers after they are sent
  • C++ pointer value changes with static_cast
  • Eliminate partial duplicate rows from result set
  • WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?
  • Firefox Extension - Monitor refresh and change of tab
  • how to save the state in userdefaults of accessory checkmark-iphone
  • Assign variable to the value in HTML
  • C# - Serializing and deserializing static member
  • Redux, normalised entities and lodash merge
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Circular dependency while pushing http interceptor
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Linker errors when using intrinsic function via function pointer
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • coudnt use logback because of log4j
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET