作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
下一个代码的 swift 等价物是什么:
[NSBundle bundleForClass:[self class]]
我需要从测试包中加载资源(JSON 数据)
最佳答案
没用过,不过我觉得应该是这样的:
swift <= 2.x
NSBundle(forClass: self.dynamicType)
swift 3.x
Bundle(for: type(of: self))
关于Swift 相当于 [NSBundle bundleForClass :[self class]],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25651403/
使用bundleForClass来检索我定义了类的框架包。 NSBundle *bundle = [NSBundle **bundleForClass**: [self class]]; // Cla
我正在准备 XCTest 并执行测试,我需要从测试包中加载资源。因此我使用: NSBundle *bundle = [NSBundle bundleForClass:[self class]]; NS
下一个代码的 swift 等价物是什么: [NSBundle bundleForClass:[self class]] 我需要从测试包中加载资源(JSON 数据) 最佳答案 没用过,不过我觉得应该是这
我正在使用 XCTest 和 OCMock 2.2.1 进行单元测试。我有一个类使用以下方法获取包标识符: NSString *bundleIdentifier = [[NSBundle bundle
我是一名优秀的程序员,十分优秀!