swift3

Migrating from Swift 2.3 to Swift 3 with dependencies

痴心易碎 提交于 2019-12-24 03:59:13
问题 I am working on migrating my project from Swift 2.3 to Swift 3 but am having issues with 3rd party frameworks that I use via Cocoapods. Many of them have already upgraded to Swift 3, yet some of them haven't. When I build my project, I get the error: Module compiled with Swift 2.3 cannot be imported in Swift 3.0: [...] I have read answers such as this one and this one, however they do not solve my problem. I cannot set SWIFT_VERSION to 2.3 if my project actually is using Swift 3, neither can

Linker command failed with exit code 1 (use -v to see invocation) with Swift 3

老子叫甜甜 提交于 2019-12-24 03:11:08
问题 I am working on building a Swift library and am hosting it on GitHub. All was going fine until I added BluetoothKit to the project. I then got an Apple Mach-O Linker Error: ld: warning: directory not found for option '-F/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk/Developer/Library/Frameworks' ld: /Users/calebklevetertest/Library/Developer/Xcode/DerivedData/Napalm-dblvhbjdwovurocsvzrzaxzkjjyw/Build/Products/Debug

Changing color of image embedded to a button (Swift3)

二次信任 提交于 2019-12-24 02:34:13
问题 I am able to change the color of an image of a UIButton from black to white with the following code: extension UIImage { func maskWith(color: UIColor) -> UIImage { UIGraphicsBeginImageContextWithOptions(size, false, scale) let context = UIGraphicsGetCurrentContext()! context.translateBy(x: 0, y: size.height) context.scaleBy(x: 1.0, y: -1.0) context.setBlendMode(.normal) let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) context.clip(to: rect, mask: cgImage!) color.setFill()

How to take PRINT of content from UIWebView?

坚强是说给别人听的谎言 提交于 2019-12-24 02:31:46
问题 I am using swift, i need to take print of a sheet which is opened in UIWebView. let url = webView.request?.url let stringurl = url?.absoluteString let pic = UIPrintInteractionController.shared let printInfo : UIPrintInfo = UIPrintInfo(dictionary: nil) printInfo.outputType = UIPrintInfoOutputType.general printInfo.jobName = stringurl! pic.printInfo = printInfo pic.printFormatter = webView.viewPrintFormatter() pic.showsPageRange = false pic.present(animated: true, completionHandler: nil) 回答1:

Binary operator '*' cannot be applied to operands of type 'int' and 'double [duplicate]

邮差的信 提交于 2019-12-24 02:21:40
问题 This question already has answers here : binary operator * cannot be applied to operands of type Int and Double (7 answers) Closed 2 years ago . I keep getting this binary operator error that "Binary operator '*' cannot be applied to operands of type 'int' and 'double' var listCount = imageNameList.count var roll: Double = SUPCalculator.degrees(motion.attitude.roll) if startDegree == 0.0 { self.startDegree = SUPCalculator.degrees(motion.attitude.roll) } var diff: Double = roll - startDegree

UICollectionView deselectItem when cell pre-fetching is enabled

有些话、适合烂在心里 提交于 2019-12-24 02:17:31
问题 On iOS 10.0, UICollectionView pre-fetches cells by default. This leads to cells that are prepared for being shown on screen, but are hidden. This question describes it really well. The following code will successfully deselect an index path when its cell is either visible or does not exist at all. If the cell exists and is hidden, the index path will be deselected, but the cell becomes stuck in the selected state until it is reused. collectionView!.deselectItem(at: indexPath, animated: false)

programmatically select all cells in tableview so next time they are pressed they call didDeselect

一曲冷凌霜 提交于 2019-12-24 01:54:55
问题 I have a table view with a bunch of different sections and dynamic number of rows in each section. In the very first section I have a cell to 'select all'. Is there a quick and easy way to manually select all the cells, so the code in their didSelect triggers and next time the user presses one of the cells it triggers their didDeselect ? The only way I can think of right now is to loop through all the sections, and in each section loop through 0 < indexPath.row < section's data array count

Swift: Prepare for segue not passing data

女生的网名这么多〃 提交于 2019-12-24 01:53:42
问题 I have got a collection view inside a table view (Netflix App Style). I followed this tutorial: https://www.thorntech.com/2016/01/scrolling-in-two-directions-like-netflix-part-2-making-api-calls/ Now I want to implement a function that whenever I click on a collection view, it will pass the employee's name to the next view controller. Here is my code: import UIKit class CategoryRow: UITableViewCell, UICollectionViewDataSource { @IBOutlet weak var collectionView: UICollectionView! var jobpost

Levenshtein distance in Swift3

余生颓废 提交于 2019-12-24 01:39:14
问题 I'm using a tutorial from Rosetta Code to calculate Levenshtein distance. It seems their code is in Swift2 so I get this error Binary operator '+' cannot be applied to operands of type '[Int]' and 'Repeated<String.CharacterView>' when doing this: var cur = [i + 2] + empty where let empty = repeatElement(s, count: 0) . How can I go about this? 回答1: There were a couple of changes to make. The construction of the Array empty. enumerate() is now enumerated() successor() doesn't exist anymore so I

Levenshtein distance in Swift3

天涯浪子 提交于 2019-12-24 01:39:12
问题 I'm using a tutorial from Rosetta Code to calculate Levenshtein distance. It seems their code is in Swift2 so I get this error Binary operator '+' cannot be applied to operands of type '[Int]' and 'Repeated<String.CharacterView>' when doing this: var cur = [i + 2] + empty where let empty = repeatElement(s, count: 0) . How can I go about this? 回答1: There were a couple of changes to make. The construction of the Array empty. enumerate() is now enumerated() successor() doesn't exist anymore so I