我的目标是在标签中显示名为 Files 的自定义类的对象的文本。这是 Files.h :
#import <Foundation/Foundation.h>
@interface Files : NSObject
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *text;
@end
这是 Files.m :
#import "Files.h"
@implementation Files
@dynamic title;
@dynamic text;
@end
这是我的应用程序的 .h 文件。标签称为 trackName:
#import <UIKit/UIKit.h>
#import "Files.h"
@interface FirstViewController : UIViewController
{
Files *plainpalais;
}
@property (weak, nonatomic) IBOutlet UILabel *trackName;
-(Files*) chooseFile;
@end
这是应用程序的 .m 文件:
#import "FirstViewController.h"
@interface FirstViewController ()
@end
@implementation FirstViewController
@synthesize trackName;
-(Files*)chooseFile
{
return plainpalais;
}
- (void)viewDidLoad
{
[super viewDidLoad];
plainpalais.text=@"hello";
plainpalais.title=@"plainpalais";
trackName.text=plainpalais.title;
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[self setTrackName:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
@end
问题是标签 trackName 没有显示 plainpalais ......
感谢帮助 !
PS:我是初学者,所以这可能是一个基本错误。