Tag: swift3

无法从软件包加载Info.plist

无法运行应用程序。 发生捆绑错误时无法加载Info.plist。 当我CMD+K清理项目,它运行良好。 但每次我进行更改并运行应用程序时,我都必须清理该项目。 以下是我的podfile的截图:

C ++中swift3的特性值

我是快速发展的初学者。 我正在研究基于BLE的应用程序。 今天我更新了Xcode 8,iOS 10并将我的代码转换为swift3。 然后我的一些语法都需要转换。 解决这个问题之后,我发现了一个关于CBC特性的问题。 问题 在didUpdateValueforCharacteristic里面,我可以得到更新的CBCharacteristic对象。 如果我打印出整个对象,则显示正确。 – > value = <3a02>当我从CBCharacteristic中检索到值时,特征值 – > 2字节(这个值的大小) func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) { if (characteristic.uuid.description == LED_WAVELENGTH_CHARACTERISTIC_UUID) { print("Characteristic – \(characteristic)") print("Data for characteristic Wavelength – \ (characteristic.value)") } } 日志结果: Characteristic – <CBCharacteristic: 0x1742a50a0, UUID = 2C14, properties = […]

UITableViewCellbutton与行动

您好我有一个自定义UITableViewCell与三个button来处理购物车function,加号,减号和删除button,我需要知道哪个单元格已被触摸。 我已经尝试使用“标签解决scheme”,但由于单元的生命周期而不工作。 任何人都可以请帮我find一个解决scheme? 提前致谢

Swift 3和Xcode8 – 对init的模糊使用

在我安装Xcode 8并将项目转换为Swift 3之前,下面的代码行很好。 现在转换后看起来像这样: let valueData:Data = Data(bytes: UnsafePointer<UInt8>(&intVal), count: sizeof(NSInteger)) 它显示错误 模糊使用'init' 它在Swift 3中有什么问题? 如何解决它?

Swift不支持SDK'iPhoneSimulator9.3.sdk'?

我刚刚安装了xcode 8.0,并将我的项目升级到swift 3.我使用的是swift 2.2和xcode 7.3.1。 但得到以下错误: Swift不支持SDK'iPhoneSimulator9.3.sdk' 命令/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc失败,退出代码1

Alamofire 4.0上传MultipartFormData标题

我们如何添加一个身份validation头到Alamofire 4.0的上传function? 下面是示例代码,但是我看不出为函数添加标题。 Alamofire.upload( multipartFormData: { multipartFormData in multipartFormData.append(unicornImageURL, withName: "unicorn") multipartFormData.append(rainbowImageURL, withName: "rainbow") }, to: "https://httpbin.org/post", encodingCompletion: { encodingResult in switch encodingResult { case .success(let upload, _, _): upload.responseJSON { response in debugPrint(response) } case .failure(let encodingError): print(encodingError) } } ) 之前的alamofire版本支持直接添加标题,但不支持添加标题。 有任何想法吗?

在Swift 3中启用核心数据轻量级迁移

根据文章我已阅读正确的方式来启用核心数据轻量级迁移是通过传递选项addPersistentStoreWithType : let mOptions = [NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true] try coordinator!.addPersistentStoreWithType( NSSQLiteStoreType, configuration: nil, URL: url, options: mOptions) 但是在我的Xcode 8 Swift 3项目中我找不到addPersistentStoreWithType被调用的地方。 这是我创build项目时生成的唯一core data代码: // MARK: – Core Data stack lazy var persistentContainer: NSPersistentContainer = { /* The persistent container for the application. This implementation creates and returns a container, having loaded the store for […]

Swift中的generics – “通用参数”T“无法推断

我想从一个方法返回符合MyProtocol的UIViewController ,所以我使用方法签名: func myMethod<T where T : UIViewController, T : MyProtocol>() -> T { 首先,我不明白:如果myMethod返回例如一个MyViewController必须签名,我必须强制转换它: class MyViewController: UIViewController, MyProtocol 我不能简单地return MyViewController()但我需要像这样return MyViewController() as! T : return MyViewController() as! T return MyViewController() as! T – 为什么这是必要的? 第二件事:我怎样才能在某个地方使用这个方法? 我不能简单地说 let x = myMethod() as? UIViewController 因为我得到的错误 Generic parameter 'T' could not be inferred 我怎么能做到这样的事情? 如果我把它投到MyViewController它的作品,但我想避免,当然。 编辑:例子 class […]

Swift 3 UIViewanimation

由于升级我的项目swift 3我的自动布局约束animation不工作; 更具体的说,他们正在攫取新的职位,而不是animation。 UIView.animate(withDuration: 0.1, delay: 0.1, options: UIViewAnimationOptions.curveEaseIn, animations: { () -> Void in constraint.constant = ButtonAnimationValues.YPosition.DefaultOut() self.layoutIfNeeded() }, completion: { (finished) -> Void in // …. }) 我知道他们添加了UIViewPropertyAnimator类,但还没有尝试。

在Swift 3上运行一个后台线程

我有一个这样的function: fileprivate func setupImageViewWithURL(url: URL) { var image: UIImage? = nil do { try image = UIImage(data: Data(contentsOf: url))! } catch is NSError { print("Failed") } image = self.imageWithImage(sourceImage: image!, scaledToWidth: UIScreen.main.bounds.size.width) self.imageImageView.image = image self.imageImageView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: (image?.size.height)!) } 我想在Background thread上运行它。 我已经尝试了Swift2的GDC方法,但没有奏效。 Swift3的线程主题有什么改变? 谢谢!