Cannot find an initializer for type 'String' that takes an argument list of type '(format: String, argument: UInt32

I created a playground in Xcode 6.3 (6D570) and entered the following code:

import UIKit
var randum_num = arc4random_uniform(13) + 1
String(format: "card%i", arguments: randum_num)

      

And I got this error:

cannot find an initializer for type 'String' that accepts an argument list of type '(format: String, argument: UInt32

      

Sorry for being completely new to Swift, thanks for any advice!

PS I am following this tutorial: link

+3


source to share


1 answer


You just need to omit the "arguments:". Try it like this:

let randum_num = arc4random_uniform(13) + 1
String(format: "card%i",  randum_num)

      



or simply

String(format: "card%i",  arc4random_uniform(13) + 1)

      

+13


source







All Articles