It is my first app that I am trying to build in IOS and I have some problems. Although I have read similar threads here I was not able to find the answer.
Well here are my classes:
Homeview.h
@interface HomeView : UIViewController{
NSString *parsed_date;
}
@property (nonatomic,retain) NSString *parsed_date;
@end
Homeview.m
@synthesize parsed_date;
parsed_date=[res objectForKey:@"date"];
and I want date which prints out normally in my homeview to be passed in other view.
Here are my other class:
Otherclass.h
#import <UIKit/UIKit.h>
@interface OtherView : UIViewController{
NSString* tracks_date;
}
@property (nonatomic,retain) NSString* tracks_date;
@end
Otherclass.m
#import "OtherView.h"
#import "HomeView.h"
@interface OtherView ()
@end
@implementation OtherView
@synthesize tracks_date;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//preview value of other class
NSLog(@"Dated previed in OtherView: %@", HomeView.parsed_date); //HERE IS THE ERROR
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
And here is my error:
property parsed_date not found on object of type "HomeView"
The problem is that you are not using an instance of HomeView. You need to instantiate HomeView, and then you can access the property through the new instance.
It should look a bit like this: