In Notes.h :
#import <Foundation/Foundation.h>
@interface Notes : NSObject
@property(nonatomic, copy) NSString *Title;
@property(nonatomic, copy) NSString *Text;
@property(nonatomic, copy) NSString *Date;
-(void)setTitle:(NSString *)Title andText:(NSString *)Text andDate:(NSString *)Date;
@end
in Notes.m :
#import "Notes.h"
@implementation Notes
@synthesize Title = _Title;
@synthesize Text = _Text;
@synthesize Date = _Date;
-(NSString *)description {
return [NSString stringWithFormat:@"Title: %@ Text: %@ Date: %@", self.Title, self.Text, self.Date];
}
-(void)setTitle:(NSString *)Title andText:(NSString *)Text andDate:(NSString *)Date{
self.Title = Title;
self.Text = Text;
self.Date = Date;
}
I have two View controllers:
in SecondViewController in a button I have:
Notes *newNote = [[Notes alloc]init];
[newNote setTitle:self.navigationItem.title andText:noteField.text andDate:dateLabel.text];
Which works fine to set the values but how do i "get" these values in FirstViewController?