I am new to objective-C, here I develop an iPhone application which contains both C++ and Objective-C files using xcode 5.1. When I try to use the populated value of mytoken
from CommunicationHandler.m
to CallViewController.mm
. I get an error "linker command failed with exit code 1 (use -v to see invocation)". I also try to initialize mytoken
with extern
but value cannot display at UserToken
(CallViewController.mm)*. Please help me to solve my this problem, your help will be highly appreciated.
The following are CommunicationHandler.m and CallViewController.mm files with its .h files.
CommunicationHandler.m
// CommunicationHandler.m
#import "CommunicationHandler.h"
...
@implementation CommunicationHandler
NSString* mytoken;
...
-(NSString*) getToken
{
mytoken=try;
return mytoken;
}
CommunicationHandler.h
//CommuniationHandler.h
#import <Foundation/Foundation.h>
#import "SecKeyWrapper.h"
@interface CommunicationHandler : NSObject {
}
...
- (NSString *) getToken;
@end
CallViewController.mm
// CallViewController.mm
#import "CallViewController.h"
...
@implementation CallViewController
...
+(BOOL) makeAudioCallWithRemoteParty:(NSString *)remoteUri andSipStack:(NgnSipStack *)sipStack andtoken:(NSString *)UserToken{
[sipStack addHeaderName:@"UserToken:" andValue:getToken];
if(![NgnStringUtils isNullOrEmpty:remoteUri]){
NgnAVSession* audioSession = [[NgnAVSession makeAudioCallWithRemoteParty: remoteUri
andSipStack: [[NgnEngine sharedInstance].sipService getSipStack]] retain];
if(audioSession){
[idoubs2AppDelegate sharedInstance].audioCallController.sessionId = audioSession.id;
[[idoubs2AppDelegate sharedInstance].tabBarController presentModalViewController: [idoubs2AppDelegate sharedInstance].audioCallController animated: YES];
[audioSession release];
return YES;
}
}
return NO;
}
CallViewController.h
#import <UIKit/UIKit.h>
#import "iOSNgnStack.h"
#import "CommunicationHandler.h"
extern NSString* mytoken;
...