0

I know you can have @private member variables but is there someway to prevent code from calling the default init: method of your class and forcing code that creates and uses your objects to only use another initializer such as initWithOptions:

I have had a flick through some Objective-C books and didn't immediately see anything.

I have seen the stack overflow topic suggesting to throw exception, or assert/abort/whatever in how to prevent usage of other init methods other than my custom method in objective-c

and the use of the depreciated keyword How do I flag a function as being deprecated in an iPhone Objective C header file?

Both of these seem somewhat less than elegant solutions, there is really no language orientated elegant way to say doesNotImplmentSelector in Objective-C...?

I come from a C++ background and just kind of expected something like the ability to hide the default constructor...

R.

Community
  • 1
  • 1
Regan
  • 41
  • 7

1 Answers1

0

I think the standard thing to do is to have an implementation of init which calls initWithOptions: with a default set of options.

Devin Ceartas
  • 4,743
  • 1
  • 20
  • 33