Swift 3: UITableViewRowActionStyle() "Missing Parameter" Error Msg
Asked Answered
D

2

5

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 3 is in this situation?

Discomposure answered 5/9, 2016 at 22:44 Comment(0)
D
12

Default initializers are removed from some imported enum types in Swift 3.

Use UITableViewRowActionStyle.default (or in your case simply .default) instead of UITableViewRowActionStyle().

    let delBut = UITableViewRowAction(style: .default, title: delete_InLocal) { action, index in
Diffuser answered 5/9, 2016 at 23:6 Comment(0)
D
2

Use UITableViewRowActionStyle as if its an enum. If you type it you will see multiple options:

UITableViewRowActionStyle.Default
UITableViewRowActionStyle.Destructive
UITableViewRowActionStyle.Normal 

let delBut = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: delete_InLocal) { action, index in
}

Some times only "special" cases are provided in this manner ... and you have to use rawValue: 0 in order to denote default behavior

Droughty answered 5/9, 2016 at 22:53 Comment(1)
as of Xcode 8 beta 6 enumeration cases should start with lowercase letters UITableViewRowActionStyle.destructiveTirade

© 2022 - 2024 — McMap. All rights reserved.