I have singleton class with ivar named formatter. There is some code:
@interface SettingsController : NSObject {
NSDateFormatter *formatter;
}
@property (nonatomic,retain,readwrite) NSDateFormatter *formatter;
@implementation SettingsController
@synthesize formatter,;
SYNTHESIZE_SINGLETON_FOR_CLASS(SettingsController);
-(id)init
{
if ( (self = [super init]) )
{
...
self.formatter = [[[NSDateFormatter alloc] init] autorelease];
...
}
Problem is that sometime when I try to get this formatter that how:
[[SettingsController sharedSettingsController] formatter]
The value is missed. There NSDate,NSString or even my own class instance at address that formatter points.
I've try use [[NSDateFormatter alloc] init] but only [[[NSDateFormatter alloc] init] retain] make problem disappear.
How could it be, when I use @property (nonatomic,retain,readwrite) and never reset this ivar to another value?
EDITE: After I made subclass for NSDateFormatter, I've clearly and easy seen the release that make fall app. Thanks a lot to progrmr!