Re: SMySQL and @class
Re: SMySQL and @class
- Subject: Re: SMySQL and @class
- From: Thomas Deniau <email@hidden>
- Date: Thu, 10 Jul 2003 10:31:20 -0400
On Wednesday, July 9, 2003, at 04:02 PM, baron.s wrote:
How can i do to use the connection which is established in all other
window ???
Just use a singleton class which will only allocate a connection,
establish it, and return it to every object which asks.
Sample code
id sharedInstance = nil;
@implementation Connection
+(Connection *)sharedInstance;
{
return [[self alloc] init];
}
-(id) init
{
if (! sharedInstance)
{
if (self=[super init])
{
// allocate and establish the connection
theConnection=......
}
sharedInstance=self;
}
return sharedInstance;
}
-(SMySQLConnection*)connection
{
return theConnection;
}
HTH
--
Thomas Deniau
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.