****的重新声明无效 [英] Invalid redeclaration of ****

查看:151
本文介绍了****的重新声明无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:我经常搜索,例如



我也有下面是AppDelegate.swift文件中的代码。我得到以下错误。

 扩展数据{
var hexString:String {
return withUnsafeBytes {(bytes :UnsafePointer< UInt8>) - >
中的字符串let buffer = UnsafeBufferPointer(start:bytes,count:count)
return buffer.map {String(format:%02hhx,$ 0)}。reduce(,{$ 0 + $ 1 })
}
}
}



注意,我在我的项目中grep了重复的类或变量声明,并且有一次代码中的声明。

解决方案


  • 转到项目根目录 - >构建阶段。

  • 在合规资源下,检查AppDelegate文件是否添加两次。



如果添加两次,然后添加了一个文件。


Note: I've search a lot, such as Invalid redeclaration of UITableViewDataSource method? not apply to my case. For there is no duplicate file or class in my code.

I've only one AppDelegate.swift file in my project and only one class AppDelegate in the file. But I've got

I also have below code in the AppDelegate.swift file. I get below error.

extension Data {
    var hexString: String {
        return withUnsafeBytes {(bytes: UnsafePointer<UInt8>) -> String in
            let buffer = UnsafeBufferPointer(start: bytes, count: count)
            return buffer.map {String(format: "%02hhx", $0)}.reduce("", { $0 + $1 })
        }
    }
}

Note, I've grep the duplicate class or variable declaration in my project, and there is once declaration in the code.

解决方案

  • Go your project root directory->Build phases.
  • Under complied resources, check AppDelegate file is added twice or not.

If it is added twice, then added one file.

这篇关于****的重新声明无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆