這是我嘗試在IOS中建立我的第一個應用程序,我有一些問題。雖然我在這裏看過類似的線索,但我無法找到答案。財產未找到類型的對象
那麼這裏有我的課:
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"];
,我想通常打印出在我homeview其他傳遞日期視圖。
這裏是我的其他類:
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
這裏是我的錯誤:
property parsed_date not found on object of type "HomeView"
我必須釋放它嗎? – ghostrider
好吧,現在我可以在homeView中看到它的值,但在我的otherView中看不到它的值。 – ghostrider
是否需要釋放它取決於您是否啓用了(ARC)自動引用計數。對於iOS,我認爲它在iOS4及更高版本中默認啓用。如果啓用ARC,則不需要手動釋放它。 http://developer.apple.com/library/mac/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html – user1610694