swift3

Swift 3: UITableViewRowActionStyle() “Missing Parameter” Error Msg

房东的猫 提交于 2019-12-19 07:49:16
问题 When I swipe a UITableView cell, the below code is called: func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { //Problem code let delBut = UITableViewRowAction(style: UITableViewRowActionStyle(), title: delete_InLocal) { action, index in //Setup Now that I've started migrating to Swift 3, I get an error message on the UITableViewRowActionStyle(): Missing argument for parameter 'rawValue' in call Anyone know what the syntax for Swift

Swift 3: UITableViewRowActionStyle() “Missing Parameter” Error Msg

亡梦爱人 提交于 2019-12-19 07:49:08
问题 When I swipe a UITableView cell, the below code is called: func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { //Problem code let delBut = UITableViewRowAction(style: UITableViewRowActionStyle(), title: delete_InLocal) { action, index in //Setup Now that I've started migrating to Swift 3, I get an error message on the UITableViewRowActionStyle(): Missing argument for parameter 'rawValue' in call Anyone know what the syntax for Swift

parsing json into an array in swift 3

☆樱花仙子☆ 提交于 2019-12-19 07:21:21
问题 I am new on swift and I am getting a json back from a request but I can not parse. I am trying to get the json info and create coordinates to use on mapkit with annotations as well Below is the json I get back { coord = [ { islocationactive = 1; latitude = "37.8037522"; locationid = 1; locationsubtitle = Danville; locationtitle = "Schreiner's Home"; longitude = "121.9871216"; }, { islocationactive = 1; latitude = "37.8191921"; locationid = 2; locationsubtitle = "Elementary School";

Swift Array extension with generic items

大兔子大兔子 提交于 2019-12-19 06:19:49
问题 I am using Swift 3.1 and have some generic struct: struct Section<InfoT: Equatable, ItemsT: Equatable> { let info: InfoT? let items: [ItemsT] } And want array extension with custom method for elements of this generic type: extension Array where Element == Section<Equatable, Equatable> { // Just dummy example function: func debugDummy() { for section in self { let info = section.info print("section info: \(info).") for item in section.items { print("item: \(item).") } } } } This gives me

Using NSUndoManager and .prepare(withInvocationTarget:) in Swift 3

老子叫甜甜 提交于 2019-12-19 06:17:08
问题 I am migrating an Xcode 7 / Swift 2.2 mac OS X project to Xcode 8 / Swift 3, and I have run into a problem using undoManager in my view controller class, MyViewController, which has a function undo. In Xcode 7 / Swift 2.2, this worked fine: undoManager?.prepareWithInvocationTarget(self).undo(data, moreData: moreData) undoManager?.setActionName("Change Data) In Xcode 8 / Swift 3, using the recommended pattern from https://developer.apple.com/library/content/documentation/Swift/Conceptual

Using NSUndoManager and .prepare(withInvocationTarget:) in Swift 3

别等时光非礼了梦想. 提交于 2019-12-19 06:17:03
问题 I am migrating an Xcode 7 / Swift 2.2 mac OS X project to Xcode 8 / Swift 3, and I have run into a problem using undoManager in my view controller class, MyViewController, which has a function undo. In Xcode 7 / Swift 2.2, this worked fine: undoManager?.prepareWithInvocationTarget(self).undo(data, moreData: moreData) undoManager?.setActionName("Change Data) In Xcode 8 / Swift 3, using the recommended pattern from https://developer.apple.com/library/content/documentation/Swift/Conceptual

Adding padding and border to an UIImageView

一个人想着一个人 提交于 2019-12-19 06:03:18
问题 How can I add padding between an UIImageView and its border? Img.layer.cornerRadius = Img.bounds.width / 2 Img.layer.borderWidth = 2 Img.layer.borderColor = UIColor.blue.cgColor Img.clipsToBounds = true Like this: 回答1: As per the this link class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let image = UIImage(named: "imagename")! let imageView = UIImageView(image: image.imageWithInsets(insets: UIEdgeInsetsMake(30, 30, 30, 30))) imageView.frame = CGRect

How to check contact source in CNContact swift?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 05:53:46
问题 In Contact apps there's group like "iCloud", "yahoo", "gmail". In swift, is it possible to fetch contact from gmail source only? 回答1: Tested code. Hope it will solve your problem... func getAppropriateName(for container: CNContainer?) -> String? { var name = "" if (container?.name == "Card") || container?.name == nil { name = "iCloud" } else if (container?.name == "Address Book") { name = "Google" } else if (container?.name == "Contacts") { name = "Yahoo" } else { name = "Facebook" } return

How to declare exponent/power operator with new precedencegroup in Swift 3?

狂风中的少年 提交于 2019-12-19 05:44:35
问题 There's been a change in Swift 3 for Xcode 8 beta 6 and now I'm not able to declare my operator for power as I did before: infix operator ^^ { } public func ^^ (radix: Double, power: Double) -> Double { return pow((radix), (power)) } I've read a bit about it and there's a new change been introduced in Xcode 8 beta 6 From this I'm guessing I have to declare a precedence group and use it for my operator like this: precedencegroup ExponentiativePrecedence {} infix operator ^^:

Get the height of the UIScrollView after layout in Swift

旧时模样 提交于 2019-12-19 05:06:29
问题 I have a situation where I'm using a UIScrollView to help users with smaller phones see the full text inside a window. And I was wanting to show an image icon if they needed to scroll (just so that they know there is more inside the window) but I'm having a problem finding the height of the scrollview using Swift. This is the hierarchy of my objects Basically, those 4 labels fit inside a 4.7" iPhone but not the 4" iPhone. I tried setting some logic to check if the UIScrollView content is