I have a webservice written in objective C. I want it access it from swift file. How do I achieve that? My attempt so far:
Webservice.h
#import <Foundation/Foundation.h>
typedef void(^WebServiceCompletionHandler)(id result,BOOL isError,NSString *strMsg);
@interface Webservice : NSObject
@property(strong,nonatomic) NSString *strURL;
-(void)registerWithFullName:(NSString*)strFullName ContactNumber:(NSString*)strContactNumber WithCompletionHandler:(WebServiceCompletionHandler)handler;
@end
Webservice.m
@implementation Webservice
-(id)init
{
if (self=[super init])
{
self.strURL=@"www.abc.com/registration";
}
return self;
}
-(void)registerWithFullName:(NSString*)strFullName ContactNumber:(NSString*)strContactNumber WithCompletionHandler:(WebServiceCompletionHandler)handler{
//Implementation
}
Now the swift file where I want to call the webservice.
Register.swift
override func viewDidLoad {
let service = Webservice.init()
heyWeb.registerWithfullName("Test", contactNumber: "+1039383838383", withCompletionHandler: { (result, isError, strMsg) -> Void in
})
}
But I am getting the following error while running the project.
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_Webservice", referenced from:
type metadata accessor for __ObjC.Webservice in Register.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Can anyone help me to figure out the problem?