Objective c 调用一个方法并将变量传递给另一个控制器

Objective c 调用一个方法并将变量传递给另一个控制器,objective-c,variables,methods,controller,Objective C,Variables,Methods,Controller,我是xcode新手,我有一个非常基本的问题。我已经搜索了几天,以找出我的代码不起作用的原因。我想将变量从一个Viewcontroller传递到另一个控制器 这是我的Viewcontroller: // // GameViewController.m // Cartas // // Created by Pedro Lopes on 10/5/13. // Copyright (c) 2013 Pedro Lopes. All rights reserved. // #import "G

我是xcode新手,我有一个非常基本的问题。我已经搜索了几天,以找出我的代码不起作用的原因。我想将变量从一个Viewcontroller传递到另一个控制器

这是我的Viewcontroller:

//
//  GameViewController.m
//  Cartas
//
//  Created by Pedro Lopes on 10/5/13.
//  Copyright (c) 2013 Pedro Lopes. All rights reserved.
//

#import "GameViewController.h"
#import "Baralho.h"

@interface GameViewController ()

@property (nonatomic,strong) Baralho *card;
@property (weak, nonatomic) IBOutlet UILabel *flipLabel;
@property (weak, nonatomic) IBOutlet UILabel *cartasRestantes;
@property (nonatomic) int flipsCount;
@property int contador;

@end

@implementation GameViewController

- (Baralho *)card
{
    if (_card == nil)
        _card = [[Baralho alloc] init];
    return _card;
}


- (IBAction)flipCard:(UIButton *)sender
{
    if (!sender.selected)
    {
       NSString *temp1 = [[self card] matchCard:@"Just a Test"];

       NSString *temp2 = self.card.drawRandomCard;
       [sender setTitle:temp2 forState:UIControlStateSelected];
       self.cartasRestantes.text = [NSString stringWithFormat:@"Cartas Restantes: %@",temp1]; 
    }
    sender.selected = !sender.isSelected;
    self.flipsCount++;
    self.flipLabel.text = [NSString stringWithFormat:@"Flips: %d",self.flipsCount];
}

@end
这是我的另一个控制器

//
//  Baralho.m
//  Cartas
//
//  Created by Pedro Lopes on 10/6/13.
//  Copyright (c) 2013 Pedro Lopes. All rights reserved.
//

#import "Baralho.h"

@interface Baralho()
@end

@implementation Baralho

- (NSString *)matchCard:(NSString *)teste
{
    _matchCard = teste;
    return _matchCard;
}


@end
问题发生在以下线路中:

NSString *temp1 = [[self card] matchCard:@"Just a Test"];
错误是: !没有“Baralho”的可见界面声明选择器“matchcard”

如何将变量传递给另一个控制器

谢谢


Pedro.

您需要确保Barahlo.h声明:

- (NSString *)matchCard:(NSString *)teste;