Jerry
Jerry

Reputation: 1812

Swift String index advanceBy can't take int32

let s : Int32 = 4 + var // var is Int32 somewhere else    
msg.substringToIndex(msg.startIndex.advancedBy(s)

Error code: Cannot invoke 'advancedBy' with an argument list of type '(Int32)'

I have tried with UInt32, it has the same kind of error

Upvotes: 0

Views: 496

Answers (1)

Luke De Feo
Luke De Feo

Reputation: 2165

Change

let s : Int32 = 4 + var

to

let s = Int(4 + var)

Upvotes: 1

Related Questions