• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSDate And Super Class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDate And Super Class


  • Subject: NSDate And Super Class
  • From: Richard Good <email@hidden>
  • Date: Tue, 24 Feb 2009 17:25:10 -0800

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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSDate And Super Class
      • From: Andy Lee <email@hidden>
    • Re: NSDate And Super Class
      • From: Andy Lee <email@hidden>
  • Prev by Date: Core Data Relationships
  • Next by Date: Re: Editing a multi-line NSTextField as a single line
  • Previous by thread: Re: NSComboBox Bindings
  • Next by thread: Re: NSDate And Super Class
  • Index(es):
    • Date
    • Thread