在目标C代码中使用NSLOG在Swift Enum上使用NSLOG时exc_bad_access崩溃

发布于 2025-02-04 02:55:57 字数 628 浏览 1 评论 0原文

我正在崩溃线程21:exc_bad_access(代码= 1,地址= 0x101e)在尝试在我的目标C代码中记录Swift Enum时。

枚举通过OBJ C代码的Swift函数调用的完成处理程序传递,

 NSLog(@"Completed with operation: %@", operation);

枚举:

@objc public enum Operation: Int {
    case Unknown
    case Operation1
    case Operation2
    case Operation1And2
}

我疲倦了以下2个变体,并且该应用程序无法构建。 Xcode存在一个问题,可以防止我看到实际错误是什么。

 NSLog(@"Completed with operation: %@", [operation description]);

 NSLog(@"Completed with operation: %@", [operation value]);

我想在此枚举上进行基本操作,例如记录其值,做布尔比较。但是我对如何做这件事是对目标C的新手有些失落的。

I am getting a crash Thread 21: EXC_BAD_ACCESS (code=1, address=0x101e) when trying to log a Swift enum in my Objective C code.

Enum passed in as the result of a completion handler on Swift function call from Obj C code:

 NSLog(@"Completed with operation: %@", operation);

Enum:

@objc public enum Operation: Int {
    case Unknown
    case Operation1
    case Operation2
    case Operation1And2
}

I tired the following 2 variations and the app failed to build. There is an issue with Xcode that prevents me from being able to see what the actual error was.

 NSLog(@"Completed with operation: %@", [operation description]);

 NSLog(@"Completed with operation: %@", [operation value]);

I want to do basic operation on this enum like log its value, do boolean comparisons. But I am a little lost on how to do that as fairly new to Objective C.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文