1

我准备把头撞在桌子上。或者我只是太累了。谁能借第二双眼睛告诉我为什么下面的最后一个 if 语句会产生错误?

非常感谢

#import "BAWelcomeViewController.h"

@interface BAWelcomeViewController ()

@end

@implementation BAWelcomeViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated {
    if (![PFUser currentUser]) {
        [self performSegueWithIdentifier:@"Show Login View" sender:self];
        return;
    }
    [self performSegueWithIdentifier:@"Show Main View" sender:self];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender {

    if ([[segue identifier] isequaltostring:@"Show Login View") {
        //do something here
    }

}
4

2 回答 2

1

上下文有点稀疏,很难确定你的意思是什么,但看起来你已经从其他地方复制并粘贴了代码;

- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender {

    if ([[segue identifier] isequaltostring:@"Show Login View") {

该方法已经使用标识符调用,而不是 segue,所以你需要的可能只是;

- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender {

    if ([identifier isequaltostring:@"Show Login View"]) {
于 2012-08-13T17:33:17.577 回答
0
- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender {

    if ([[segue identifier] isequaltostring:@"Show Login View") {
        //do something here
    }

}

是不正确的。尝试

- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender {

    if ([identifier isEqualToString:@"Show Login View"]) {
        //do something here
    }

}

你没有一个segue可以打电话identifier的。还修复了一些代码错误。

于 2012-08-13T17:32:49.870 回答