Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Thread 1: Program received signal: “EXC_BAD_ACCESS”

Status
Not open for further replies.

redpotato

Programmer
Feb 15, 2010
24
CA
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:mad:"yyyy/MM/dd"];
myBirthday=[dateFormat dateFromString:mad:"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(?)
 
sorry, I thought there is no object-c forum.

thanks for the tip!
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top