2012-08-08 79 views
0

可能重复:
Passing Data between View Controllers无法查看控制器之间传递数据

我有时也使用没有问题的视图控制器之间传递数据,但不会这一次。请帮助

我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 *' 

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

+1

其与我的不同,请。程序是相同的,但我有一些错误。 – Piyo 2012-08-08 11:16:26

+0

这绝对是你的实际代码,因为它应该没问题。你是否得到任何其他编译器警告,或做任何其他进口?这是你的第二个控制器头文件的完整内容吗? – jrturton 2012-08-08 11:20:45

+0

我同意,这不是链接问题的重复。 OP正在尝试做正确的事情,但有其他错误导致的错误。 – jrturton 2012-08-08 11:21:31

回答

0

请验证您的第二个视图控制器实现文件中是否使用@sythesize作为您在界面中声明的两个属性。

这似乎是什么导致问题。

+0

我已经综合了。有点奇怪。是因为我使用标签栏吗? – Piyo 2012-08-08 11:21:30

+0

请添加您的SecondViewController实现代码。 – Daniel 2012-08-08 23:54:17

+0

对不起,我的不好,菲利普米尔斯是真的,因为我有超过1个版本的项目。我现在删除旧的和现在的工作。 – Piyo 2012-08-09 05:24:40

相关问题