I have a class HelloWorldViewController that has the following
-(void) addDate method
NSDate *myDate = [myDatePIcker dateValue];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"YYYYMMdd"];
NSLog(@"addDate date is:%@",[dateFormat stringFromDate:myDate]);
When I call the above method from and IBAction like this...
- (IBAction)myAddDate:(id)sender {
[self addDate];
}
It works as intended (see NSLog below)
2013-03-14 09:05:33.149 APPNAME[3531:303] AWAKENED in Hello 2013-03-14 16:05:33 +0000
2013-03-14 09:05:33.150 APPNAME[3531:303] AWAKENED in Hello (null)
2013-03-14 09:05:35.898 APPNAME[3531:303] addDate date is:20130314
2013-03-14 09:05:35.899 APPNAME[3531:303] addDate completed with date 20130314
But, if I call that -(void) function from a method (datePickerAction) in another class (TableViewController), which is subclassed, see below...
@implementation TableViewController:HelloWorldViewController
-(IBAction)datePickerAction:(id)sender{
[self addDate];
}
This is the output from NSLog
2013-03-14 09:08:01.719 APPNAME[3549:303] AWAKENED in Hello 2013-03-14 16:08:01 +0000
2013-03-14 09:08:01.720 APPNAME[3549:303] AWAKENED in Hello (null)
2013-03-14 09:08:03.321 APPNAME[3549:303] addDate date is:(null)
2013-03-14 09:08:03.322 APPNAME[3549:303] addDate completed with date (null)
2013-03-14 09:08:03.323 APPNAME[3549:303] addDate date is:(null)
2013-03-14 09:08:03.323 APPNAME[3549:303] addDate completed with date (null)
I'm green, go easy :-) Any suggestions appreciated!
UPDATE: I attempted to implement the solution below. Here's the updated & additional code. The app won't launch now...any suggestions.
@implementation HelloWorldViewController;
-(id) init{
HelloWorldViewController *myHelloWorldController = [[HelloWorldViewController alloc] init];
return self;
}
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import "HelloWorldViewController.h"
#import "Date.h"
>
@interface TableViewController : NSTableView <NSTableViewDataSource> {
IBOutlet NSTableView *tableview;
NSMutableArray *list;}
#import "TableViewController.h"
#import "HelloWorldViewController.h"
@implementation TableViewController{
HelloWorldViewController *myHelloWorldViewController;}
- (id) init{
self = [super init];
if (self) {
list = [[NSMutableArray alloc] init];
}
return self;}
- (IBAction)datePickerAction:(id)sender{
[myHelloWorldViewController addDate];
//NSLog(@"Action Finished with date %@", myRename);}