无法在View Controllers之间传递数据

时间:2012-08-08 11:09:58

标签: objective-c ios

  

可能重复:
  Passing Data between View Controllers

我有时使用viewcontroller之间传递数据没有问题,但这一次它不会。请帮忙

我的FirstViewController.m

#import "SecondViewController.h"

- (IBAction)passBtn:(id)sender
{
    SecondViewController *second =[[SecondViewController alloc] initWithNibName:nil bundle:nil];
    second.stringData = dataString.text;
    second.stringNumber = numberString.text;
    second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:second animated:YES];
}

我的SecondViewController.h

#import <UIKit/UIKit.h>

@interface SecondViewController : UIViewController

@property(nonatomic, retain) NSString *stringData;
@property(nonatomic, retain) NSString *stringNumber;

@end

我收到此错误,指向我的FirstViewController.m行second.stringData和second.stringNumber

Property 'stringData' not found on object of type 'SecondViewController *'
Property 'stringNumber' not found on object of type 'SecondViewController *'

我也使用其他方法,但错误是一样的,总是说在类型的对象上找不到。但如果我在我的stringData或stringNumber中单击Command +,它确实将我带到了我的SecondViewController.h并指向我的stringData或stringNumber。请帮忙。

1 个答案:

答案 0 :(得分:0)

请在第二个视图控制器实现文件中验证您是否正在使用@sythesize处理接口中声明的两个属性。

这似乎是导致问题的原因。

相关问题