Here is what i want to do..
I have a class called userInfo. I create an instance of this object in another class called LoginInfo. I want to keep this instace alive and accessible to all other classes and till the time the application is alive...
How do i achieve this? I read somewhere that i can do this with singleton classes. But i have no idea what they are...I am quite new to cocoa..Please guide..
Thanks in advance..
@interface UserInfo : NSObject {
NSString * firstName;
NSString * lastName;
NSString * uID;
NSString * password;
NSString * userType;
}
-(id)initWithFirstName:(NSString *)fname andLastName:(NSString *)lname andUID:(NSString *)userID andPassword:(NSString *)pwd andUserType:(NSString *)type;
@property (readwrite, copy) NSString * firstName;
@property (readwrite, copy) NSString * lastName;
@property (readwrite, copy) NSString * uID;
@property (readwrite, copy) NSString * password;
@property (readwrite, copy) NSString * userType;
@end
#import "UserInfo.h"
@implementation UserInfo
-(id)initWithFirstName:(NSString *)fname andLastName:(NSString *)lname andUID:(NSString *)usid andPassword:(NSString *)pwd andUserType:(NSString *)type{
self=[super init];
if (self) {
self.firstName=fname;
self.lastName=lname;
self.uID=usid;
self.password=pwd;
self.userType=type;
}
return self;
}
@synthesize firstName;
@synthesize lastName;
@synthesize uID;
@synthesize password;
@synthesize userType;
@end
This is the class i want to make singleton.... Please guide as to what changes i have to make..I want to use the custom constructor... M sorry to put this code as an answer. But i could not get it in a comment...