I just have a simple code to practice Object C..
I am not sure why I can this "WARNING"?
My code is below
#import <Foundation/Foundation.h>
@interface MyClass : NSObject {
@private
NSDate *mdate;
}
@property (retain) NSDate *mdate;
@end
==================================
#import "MyClass.h"
@implementation MyClass
@synthesize mdate;
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
mdate = [[NSDate date] autorelease];
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
@end
=============================================
#import <Foundation/Foundation.h>
#import "MyClass.h"
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
MyClass *mclass = [[MyClass alloc]init];
NSDate *myBirthday;
NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
[dateFormat setDateFormat"yyyy/MM/dd"];
myBirthday=[dateFormat dateFromString"1990/09/02"];
[mclass setMdate:myBirthday];
NSLog(@"My Birthday is %@",[mclass mdate]);
// insert code here...
NSLog(@"Hello, World!");
[mclass release];
//[dateFormat release];
[pool drain];
return 0;
}
and in [pool drain] -> i got the message after I ran.
I am really newbie on Object C. Could someone please explain what I missed?
I think this cause my memory management(?)
I am not sure why I can this "WARNING"?
My code is below
#import <Foundation/Foundation.h>
@interface MyClass : NSObject {
@private
NSDate *mdate;
}
@property (retain) NSDate *mdate;
@end
==================================
#import "MyClass.h"
@implementation MyClass
@synthesize mdate;
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
mdate = [[NSDate date] autorelease];
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
@end
=============================================
#import <Foundation/Foundation.h>
#import "MyClass.h"
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
MyClass *mclass = [[MyClass alloc]init];
NSDate *myBirthday;
NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
[dateFormat setDateFormat"yyyy/MM/dd"];
myBirthday=[dateFormat dateFromString"1990/09/02"];
[mclass setMdate:myBirthday];
NSLog(@"My Birthday is %@",[mclass mdate]);
// insert code here...
NSLog(@"Hello, World!");
[mclass release];
//[dateFormat release];
[pool drain];
return 0;
}
and in [pool drain] -> i got the message after I ran.
I am really newbie on Object C. Could someone please explain what I missed?
I think this cause my memory management(?)