vla*_*f81 5 c objective-c swift
我总结了问题的步骤,我在Objective-C中定义了一个C函数:
ObjC.h
#import <Foundation/Foundation.h>
void cuslog(NSString *format, ...);
@interface ObjC : NSObject
@end
Run Code Online (Sandbox Code Playgroud)
ObjC.m
#import "ObjC.h"
@implementation ObjC
@end
void cuslog(NSString *format, ...)
{
// Implementation
}
Run Code Online (Sandbox Code Playgroud)
我在Bridging-Header.h中公开了它:
#import "ObjC.h"
// Also tried to put this line in bridging header
void cuslog(NSString *format, ...);
Run Code Online (Sandbox Code Playgroud)
在Swift中,我打算像这样调用函数:
cuslog("Some log")
Run Code Online (Sandbox Code Playgroud)
但错误说:
"Use of unresolved identifier 'cuslog'"
Run Code Online (Sandbox Code Playgroud)
在Swift中调用函数的正确方法是什么?