I want to class that should be initialized only once and returns some value which was computed the first time. Is below the right approach ?
@property (nonatomic, retain) NSString *userAgent;
@implementation UserAgent
@synthesize userAgent = _userAgent;
+ (NSString *) userAgentString
{
UserAgent *thisClass;
if(self == nil)
{
thisClass = [[UserAgent alloc] init];
}
if (thisClass.userAgent == nil)
{
return @"not initialized";
}
return thisClass.userAgent;
}