gpt4 book ai didi

iphone - 将字符串值从 C 函数传递到 Xcode 中的目标代码

转载 作者:太空宇宙 更新时间:2023-11-04 02:16:19 25 4
gpt4 key购买 nike

我需要在 Objective-C ..

char *display()
{
char *b="Hi";
printf("%s",b);
return b;
}

此返回值应在 Objective-C 函数中调用和使用,即在同一项目中存在的 sampleObjC.m 中。任何人都可以帮助我了解如何执行此操作或任何替代方法(如果存在将字符串值从 c 文件传递​​到同一项目中的 objective-c 文件)吗?

最佳答案

// sampleObjC.m
#include sampleC.h

- (void)myMethod {
NSString *string = [NSString stringWithUTF8String:display()];
NSLog(@"%@", string);
}

关于iphone - 将字符串值从 C 函数传递到 Xcode 中的目标代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7253809/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com