I want to create a singleton which disallows these methods in the .h file (more details here):
+ (instancetype) alloc __attribute__((unavailable("alloc not available, call sharedInstance instead")));
- (instancetype) init __attribute__((unavailable("init not available, call sharedInstance instead")));
+ (instancetype) new __attribute__((unavailable("new not available, call sharedInstance instead")));
Can I redefine them in the @interface MyClass () section of the .m file in order to be able to use init internally?
I'm looking for something similar to when you create a readonly property on the header and you redefine it as readwrite on the implementation (but for __attribute__).
Like so:
// MyClass.h
@interface MyClass
@property (readonly) OtherClass *myThing;
@end
and
// MyClass.m
@interface MyClass ()
@property (readwrite) OtherClass *myThing;
@end