【问题标题】:"Ambiguous Reference To" Error in Swift 3Swift 3 中的“模糊引用”错误
【发布时间】:2016-09-07 12:39:07
【问题描述】:

下午好,

我试图编写一个音乐播放应用程序,我试图在其中实现一些名为“STK 音频播放器”的开源代码,它是用 Objective C 编码的。

尝试从导入的源调用方法时,我收到以下编译错误。

“对会员游戏的模糊引用”

import UIKit

class ViewController: UIViewController {

var audioPlayer = STKAudioPlayer()


override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    let songToPlay:String = "http://themarketshop.com/beats/fatbeat.mp3"

    STKAudioPlayer.play(songToPlay)
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

}

来自开源

/// Plays an item from the given URL string (all pending queued items are removed).
/// The NSString is used as the queue item ID
-(void) play:(NSString*)urlString;

【问题讨论】:

    标签: ios swift


    【解决方案1】:

    play是一个实例(-)方法,所以使用实例:

    audioPlayer.play(songToPlay)
    

    并且不要将文字字符串注释为String。包括编译器在内的每个人都可以看到它是什么。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-15
      • 1970-01-01
      • 2020-02-22
      • 1970-01-01
      • 2017-08-09
      • 2017-02-12
      • 2016-05-01
      相关资源
      最近更新 更多