【发布时间】:2008-12-20 08:36:18
【问题描述】:
我在使用 Xcode 时遇到了困难;出于某种原因,它只是不允许我将变量从一个视图控制器类传递给另一个。它应该可以工作,我基本上只是从我的其他课程中复制/粘贴(它适用于所有课程......除了这个)。我整晚都在做这件事,尝试了我能想到的一切,但它仍然存在。
这是我正在调用的视图控制器类:
ResultadosViewController.h:
#import <UIKit/UIKit.h>
#import "Filme.h"
#import "Festival.h"
#import "Top10Discos.h"
#import "Peca.h"
@class DetalhesViewController;
@interface ResultadosViewController : UIViewController
{
// Navegation
DetalhesViewController *dvc;
BOOL isViewPushed;
// What i'd really like to pass lol
NSArray *array_resultados;
}
@property (nonatomic, retain) NSArray *array_resultados;
@property (nonatomic, readwrite) BOOL isViewPushed;
@end*
ResultadosViewController.m:
#import "ResultadosViewController.h"
#import "DetalhesViewController.h"
#import "Filme.h"
#import "Peca.h"
#import "Top10Discos.h"
#import "Festival.h"
@implementation ResultadosViewController
@synthesize isViewPushed, array_resultados;
(...)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic -- create and push a new view controller
if (indexPath.row == 2)
{
if(dvc != nil)
[dvc dealloc];
NSString *ffs = [[array_resultados objectAtIndex:indexPath.row] TituloFilme];
dvc = [[DetalhesViewController alloc] initWithNibName:@"DetailedView" bundle:[NSBundle mainBundle]];
**resultadosControllerCell.array_resultados = [self array_resultados];**
*"Request for member 'array_resultados' in something not a structure or union"*
//Push the view controller to the top of the stack.
[self.navigationController pushViewController:dvc animated:YES];
}
}
这是我想将数组发送到的另一个类:
DetalhesViewController.h:
#import <UIKit/UIKit.h>
#import "Filme.h"
#import "Festival.h"
#import "Top10Discos.h"
#import "Peca.h"
@interface DetalhesViewController : UIViewController
{
// Navegacao
NSArray *array_resultados;
}
@property (nonatomic, retain) NSArray *array_resultados;
@end
我不确定你们中是否有人会看到这个类的 .m 文件;在这种情况下,请询问。
提前致谢, 哈尔
PS:尝试使用其他变量(也包括其他类型),清理/重建,重新创建 xib 文件,你可以命名它......我没有技巧:(
【问题讨论】:
-
如果您将标题更改为更具描述性,您可能会得到更好的回复。例如“无法在 iPhone 项目中的控制器之间传递变量”