objective-c - 在 Objective-C 中使用 Swift 中的 JSQSystemSoundPlayer 时,我没有看到可见的 @interface

标签 objective-c xcode swift jsqmessagesviewcontroller

我收到此错误:

/: No visible @interface for 'JSQSystemSoundPlayer' declares the selector 'playAlertSoundWithFilename:fileExtension:'

我正在使用 JSQMessagesViewController 创建一个聊天应用程序。 这是代码:

if (asAlert) {
    [[JSQSystemSoundPlayer sharedPlayer] playAlertSoundWithFilename:fileName fileExtension:kJSQSystemSoundTypeAIFF];
}
else {
    [[JSQSystemSoundPlayer sharedPlayer] playSoundWithFilename:fileName fileExtension:kJSQSystemSoundTypeAIFF];
}

if 和 else 语句均出现错误。 我该如何解决?

最佳答案

嘿,不确定您是否已经正常工作,但您只需添加一个完成处理程序,如下所示:

if (asAlert) {
    [[JSQSystemSoundPlayer sharedPlayer] playAlertSoundWithFilename:fileName fileExtension:kJSQSystemSoundTypeAIFF completion:nil];

} else {
    [[JSQSystemSoundPlayer sharedPlayer] playSoundWithFilename:fileName fileExtension:kJSQSystemSoundTypeAIFF completion:nil];
}

如果你不想深入研究代码,我在 github 上修补了它:

https://github.com/FridayDevGroup/JSQMessagesViewController

关于objective-c - 在 Objective-C 中使用 Swift 中的 JSQSystemSoundPlayer 时,我没有看到可见的 @interface,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34261948/

相关文章:

swift - 使用 mapkit Swift 3 绘制折线

swift 为什么这样做?需要 AnyObject 与 Any

ios - 什么是 UITabBarItem *item = [self.tabBar.items objectAtIndex :1]; in swift?

网络服务

objective-c - 在 Objective-C 中实现目标- Action 设计模式

objective-c - 在 iOS 中创建您自己的自定义库?

iphone - ARC 警告 - "Not safe to remove an unused autorelease"

swift - UIButton 动画忽略 Swift 中的目标选择器

swift - 如何在 SwiftUI 中设置 ScrollView 的 contentInset

objective-c - 当委托(delegate)不再被引用时,在 `[NSApp run]` 处崩溃