//FirstViewController.m
#import "EighthViewController.h"
EighthViewController *able = [[EighthViewController alloc] initWithNibName:@"EighthViewController" bundle:nil];
able.extra = @"dd"; //ERROR HERE----------------
[self presentViewController:able animated:YES completion:NULL];
//EighthViewController.h
@interface EighthViewController : UIViewController{
NSString *extra;
}
@property (nonatomic) NSString *extra;
每当我尝试使用此代码(来自here)时,我在FirstViewController中收到错误消息:Property 'extra' not found on object of type 'EighthViewController *'
答案 0 :(得分:0)
您应该添加:
@property (nonatomic, retain) NSString *extra;
到您的EighthViewController.h
文件。并添加以下内容:
@synthesize extra;
在EighthViewController.m
文件中。通常它应该工作
希望有所帮助