Sclalertview-swift: Swift 4

Created on 24 Sep 2017  路  29Comments  路  Source: vikmeup/SCLAlertView-Swift

I used #351 link for my project. However, the duration function is no longer work. Please kindly help to fix. Thanks.

Most helpful comment

        let alert = SCLAlertView(appearance: appearance)
        let showTimeout = SCLButton.ShowTimeoutConfiguration(prefix: "(", suffix: " " + "second".localize() + ")")
        _ = alert.addButton("cancel_order".localize(), backgroundColor: UIColor(hex:"FFBA00"), textColor: UIColor.white, showTimeout: showTimeout) {

}

 let timeoutValue: TimeInterval = 5.0
        let timeoutAction: SCLAlertView.SCLTimeoutConfiguration.ActionType = {


        }

        alert.showWait("", subTitle: "order_message_to_drivers".localize(), timeout: SCLAlertView.SCLTimeoutConfiguration(timeoutValue: timeoutValue, timeoutAction: timeoutAction), colorStyle: 0xFFBA00, colorTextButton: 0xFFFFFF)

All 29 comments

for now, click on the error. It should show automatically what the new code should look like. Then run the app again.

It doesn't support the duration now?
alertView.showError("Title", subTitle:"abc", duration: 3)
It shows
Incorrect argument label in call (have '_:subTitle:duration:', expected '_:subTitle:closeButtonTitle:') Replace 'duration' with 'closeButtonTitle'

hmm, i'm not with my macbook right now. I'll look into it this weekend. Hopefully someone else can do it sooner.

Please update. Have always loved this library. Looking forward to Swift4 update

I update the library for swift 4

    pod 'SCLAlertView', :git => 'https://github.com/ahmedsafadii/SCLAlertView-Swift.git'

Thanks @ahmedsafadii , but not fixing the duration issue.

@rayhk6 what issue , I used it and it's amazing oO

try replace both file with this :)

@ahmedsafadii I still facing same issue for duration!

@Piyush08 can you share your code or screen the problem ?

@Piyush08 Please replace duration with timeout. It works for me.
Ref: https://github.com/vikmeup/SCLAlertView-Swift/blob/master/Example/SCLAlertViewExample/ViewController.swift

        let alert = SCLAlertView(appearance: appearance)
        let showTimeout = SCLButton.ShowTimeoutConfiguration(prefix: "(", suffix: " " + "second".localize() + ")")
        _ = alert.addButton("cancel_order".localize(), backgroundColor: UIColor(hex:"FFBA00"), textColor: UIColor.white, showTimeout: showTimeout) {

}

 let timeoutValue: TimeInterval = 5.0
        let timeoutAction: SCLAlertView.SCLTimeoutConfiguration.ActionType = {


        }

        alert.showWait("", subTitle: "order_message_to_drivers".localize(), timeout: SCLAlertView.SCLTimeoutConfiguration(timeoutValue: timeoutValue, timeoutAction: timeoutAction), colorStyle: 0xFFBA00, colorTextButton: 0xFFFFFF)

Hello @ahmedsafadii ,

Can't I use same format like as duration now? Just specify second & after that dismiss automatically.

Rather than this adding button scenario.

Thank you,

@Piyush08

alertView.showInfo("", subTitle: "ABC", timeout: SCLAlertView.SCLTimeoutConfiguration(timeoutValue: 3, timeoutAction: SCLAlertView.SCLTimeoutConfiguration.ActionType = {
    print("")
}))

@ahmedsafadii

still getting error as "Cannot assign to immutable expression of type 'SCLAlertView.SCLTimeoutConfiguration.ActionType.Type' (aka '(() -> ()).Type')"

@ahmedsafadii I already replace this as you mentioned above

@Piyush08 can you share the alert code here ^^"

screen shot 2017-09-30 at 12 53 36 am

@Piyush08 the code please :3

@ahmedsafadii I already share as above image

@Piyush08 ok give me a sec

try this

@Piyush08

let timeoutAction: SCLAlertView.SCLTimeoutConfiguration.ActionType = {
        // action here
}

SCLAlertView().showError("test", subTitle: "test",timeout:SCLAlertView.SCLTimeoutConfiguration(timeoutValue: 3.0, timeoutAction:timeoutAction))

@ahmedsafadii

It works!

Thanks for your quick & great help!

Happy coding!

@Piyush08 np ;)

So whats the workflow for adding this to a new Swift4 project now?

@justdan0227 create PR with changes to support Swift4, I would be happy to merge it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ewan34500 picture ewan34500  路  3Comments

galileomd picture galileomd  路  3Comments

p0tvin29 picture p0tvin29  路  3Comments

jlaws picture jlaws  路  19Comments

ossmalpha picture ossmalpha  路  16Comments