TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Trying to convert int to SubsonicController.RepeatCount so I can use in Picker

Forums > SwiftUI

I am using Paul Hudson's Subsonic audio library in a SwiftUI app and I would like to use a Picker to allow the user to select how many times to play a sound. I was thinking that I could use an Int variable for the picker then convert that Int to a SubsonicController.RepeatCount type. I created a function to do this and I got the error "Missing argument label 'integerLiteral:' in call." I will post some code.

@State var repeatCount=20

    func convertFromInt(repeatCount:Int) -> SubsonicController.RepeatCount {
        return SubsonicController.RepeatCount(repeatCount)

    }

2      

The error tells you exactly what is wrong.

Subsonic.RepeatCount has this initializer:

public init(integerLiteral value: Int)

So you need to call it like this:

SubsonicController.RepeatCount(integerLiteral: repeatCount)

2      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.