Use of undeclared identifier 'startClient' ERROR

532 views Asked by At

I am writing an application in Objective C and I keep getting a Use of Undeclared Identifier 'startClient' error. I have attached a link to my project file and the tutorial link is here: https://www.sinch.com/tutorials/building-one-button-app-conference-calling/ https://drive.google.com/file/d/0B5loU41SFmzDZ2RNbWJsR0xoSk0/view?usp=sharing

The relevant portion of my code is here...

#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

There are 1 answers

0
John A. Vink On

You can't stick a function inside another function. You have the implementation of startClient inside of viewDidAppear.

I don't know what your viewDidAppear is supposed to do, but this will compile:

- (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];
}