Re: Public, private and protected variables
Re: Public, private and protected variables
- Subject: Re: Public, private and protected variables
- From: Dylan Adams <email@hidden>
- Date: Sun, 27 Jul 2003 17:33:28 -0500
John MacMullin wrote:
I have an NSDocument Object that I have subclassed and then I
subclassed the subclass. I have instance variables declared as public
and protected in the first subclass following Cocoa In a Nutshell, page
8, on scoping, as follows:
@public
NSMutableArray *companyRecords;
@protected
NSDictionary *ocAccountsFile;
In my first use in the subclass of the subclass, I am just trying to
get the variables referenced to print using NSLog. I do this by
sending a notification to the subclass. The notification works just
fine. Accessing the variables does not.
- (void)companyInfoTabSelected:(NSNotification *)notification
{
NSLog(@"Notification Action");
NSLog(@"%@-companyRecords", companyRecords);
NSLog(@"%@-ocCategoryFile", ocCategoryFile);
}
The result is:
2003-07-27 14:49:24.453 GLASS[6655] 2 tab view item
2003-07-27 14:49:24.454 GLASS[6655] Notification Action
2003-07-27 14:49:24.454 GLASS[6655] (null)-companyRecords
2003-07-27 14:49:24.454 GLASS[6655] (null)-ocCategoryFile
I have not been able to get the protected and public variables to
print, or be visible in any way, with a number of combinations
including accessor methods. I must be doing something wrong in a
simple way.
This has nothing to do with private or protected variables. That is
enforced at compile time. The variables ``companyRecords'' and
``ocCategoryFile'' are nil (null) at the time you are printing to them.
Either they've never had any values assigned to them, or you've assigned
nil to them.
dylan
_______________________________________________
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.