27
votes

i had type Int. please help me fix that?

enter image description here

2
Why float variable and int variable unable to multiple? why not result value failed to typeCast here! You comments help! let price : Float = 10.5 let quantity : Int = 20 var total : Float. total = price * quantity.KkMIW

2 Answers

56
votes

Instead of i * self.view.frame.size.width, use CGFloat(i) * self.view.frame.size.width

2
votes

You need to type cast i into CGFloat, write your line of code as

var frame: CGRect = CGRectMake(CGFloat(i) * self.view.fram.size.width, self.tutorialHolderView.frame.origin.y, 0, self.tutorialHolderView.frame.size.height)