I clearly don't understand how inheritance works for Objective C, at least not with the NSDate type. When I create a super class with an NSDate type as an instance variable and then instantiate a subclass of the superclass, I get an "out of Scope" error for the NSDate instance variable.
What am I doing wrong?

Here is an example of my class hierarchy:
Super Class:

DateTest.h
#import <Foundation/Foundation.h>
@interface DateTest : NSObject {
        NSDate*         aDate;
}
@property (nonatomic,retain)    NSDate*  aDate;
@end

DateTest.m
#import "DateTest.h"
@implementation DateTest
@synthesize aDate;
-(DateTest*)    init    {
        [super init];
        aDate =[NSDate date];
        return self;
}
@end

Sub Class:
 DatesubClass.h
#import <Foundation/Foundation.h>
#import "DateTest.h"

@interface DatesubClass : DateTest {
        NSString*               testStr;
        
}
@property (nonatomic,copy)      NSString* testStr;
@end
SubClass DatesubClass.m
#import "DatesubClass.h"
@implementation DatesubClass
@synthesize testStr;

-(DatesubClass*)        init    {
        [super init];
        testStr= @"Test";
        return self;
}
@end

Instance var creation
DatesubClass* datesubClass = [[DatesubClass alloc]init];
At this point the datesubClass.aDate Instance variable is "out of scope"



Richard Good

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to