Re: DataSource class of NSTableView - weird
Re: DataSource class of NSTableView - weird
- Subject: Re: DataSource class of NSTableView - weird
- From: "M. Uli Kusterer" <email@hidden>
- Date: Mon, 10 Nov 2003 18:42:33 +0100
At 16:20 Uhr +0100 10.11.2003, Kai wrote:
Do you have several objects of this class? If the array is really
global as you claim, each time you create a new object (=instance)
of this class (or Interface Builder creates one based on info from
a NIB file), that object's init method will overwrite the array you
stored in db_tables with the new one it created.
Ups, right! The array will be overwritten by a new object. I have
the creation of db_tables in "awakeFromNib"!
Moving it to awakeFromNib doesn't change the overwriting.
awakeFromNib is called once on each object. You'll probably want
something like
NSMutableArray* gMyDBTables = nil;
-(void) awakeFromNib
{
if( !gMyDBTables ) // Haven't created an array yet?
gMyDBTables = [[NSMutableArray alloc] init];
}
If you are declaring the global inside the @interface/@end part of
the header for your class, it isn't global. It's a per-instance
variable, which means each object gets its own copy, and you're
only filling one object's array, and the others remain empty.
I have the variable declaration between the #import and @interface
statements in the header file now. That is globally!?
Yes. Just wanted to make sure, since we had someone here recently
who had accidentally declared a global variable in the instance
variable area, and was surprised why it wasn't behaving like a global
should.
...but the table view shows nothing! :( I used NSTableView many
times successfully, only here these problems.
I don't explain me this! Any other ideas?
Maybe it would help if you tried to create a small (i.e. minimal)
sample application that reproduces your problem and posted the code?
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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.