小编Pat*_*lot的帖子

无法转换'Meme'类型的值!期待参数类型'@noescape(Meme)抛出 - > Bool'

这是代码:

    @IBAction func deleteMeme(sender: UIBarButtonItem) {
       if let foundIndex = MemeRepository.sharedInstance.memes.indexOf(selectedMeme) {     
        //remove the item at the found index
        MemeRepository.sharedInstance.memes.removeAtIndex(foundIndex)
        navigationController?.popViewControllerAnimated(true)
Run Code Online (Sandbox Code Playgroud)

错误发生在.indexOf方法处(selectedMeme).

无法将类型的值转换Meme!为预期的参数类型@noescape (Meme) throws -> Bool

米姆!是我的应用程序的结构.我如何解决这个问题?

struct Meme {

var topText : String!
var bottomText: String!
var image: UIImage!
var memedImage: UIImage!

init(topText: String, bottomText: String, image: UIImage, memedImage: UIImage) {
    self.topText = topText
    self.bottomText = bottomText
    self.image = image
    self.memedImage = memedImage
Run Code Online (Sandbox Code Playgroud)

arrays indexof swift

27
推荐指数
2
解决办法
9404
查看次数

标签 统计

arrays ×1

indexof ×1

swift ×1