使用未声明的标识符' startClient'错误

时间:2016-12-21 22:30:31

标签: ios objective-c xcode undeclared-identifier

我正在使用Objective C编写一个应用程序,并且我继续使用未声明的标识符' startClient'错误。我附加了一个指向我的项目文件的链接,教程链接在这里:https://www.sinch.com/tutorials/building-one-button-app-conference-calling/ https://drive.google.com/file/d/0B5loU41SFmzDZ2RNbWJsR0xoSk0/view?usp=sharing

我的代码的相关部分在这里......

#import <QuartzCore/QuartzCore.h>
#import "ConferenceViewController.h"
#import "LoginViewController.h"
#import <SinchCallingUIKit/SinchCallingUIKit.h>

@class ConferenceViewController;

@interface UIView ()

@end

@implementation ConferenceViewController

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

- (void)viewDidAppear:(BOOL)animated
{
    - (void)startClient {}{
        NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
        [[CallingManager sharedManager] startClientWithKey:8b6893bf-41c6-4527-bc68-9d3703c13be3 secret:Ox18uwq7gkiAdeQYzntN6A== userName:[defaults stringForKey:@"userName"] sandbox:NO launchOptions:nil];
    NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults stringForKey:@"userName"] == nil)
    {
        [self performSegueWithIdentifier:@"login" sender:nil];
    }
    else
    {
        [self startClient];
    }
}

1 个答案:

答案 0 :(得分:0)

您无法在其他功能中添加功能。您可以在viewDidAppear中实现startClient。

我不知道你的viewDidAppear应该做什么,但这会编译:

- (void)viewDidAppear:(BOOL)animated
{
    if ([defaults stringForKey:@"userName"] == nil)
    {
        [self performSegueWithIdentifier:@"login" sender:nil];
    }
    else
    {
        [self startClient];
    }
}

- (void)startClient
{
    NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
    [[CallingManager sharedManager] startClientWithKey:8b6893bf-41c6-4527-bc68-9d3703c13be3 secret:Ox18uwq7gkiAdeQYzntN6A== userName:[defaults stringForKey:@"userName"] sandbox:NO launchOptions:nil];
}