1
label.position = CGPointMake(self.size.width*0.125, self.size.height-CGFloat(0.15)*self.size.height*_activeEnemiesArray.count)

I get an error pointing to self.size.width that says

'CGFloat' is not convertible to 'Double'.

This makes sense, since a CGFloat value and a Double value cannot be multiplied, but then when I convert the 0.125 to CGFloat:

label.position = CGPointMake(self.size.width*CGFloat(0.125), self.size.height-0.15*self.size.height*_activeEnemiesArray.count)

I get an error pointing to self.size.width that says

'CGFloat' is not convertible to 'UInt8'

This does not make any sense. Has anyone else been experiencing this and what could be the cause?

jscs
  • 63,694
  • 13
  • 151
  • 195
Christian Ayscue
  • 641
  • 1
  • 7
  • 22
  • possible duplicate of [‘CGFloat’ is not convertible to ‘UInt8' and other CGFloat issues with Swift and Xcode 6 beta 4](http://stackoverflow.com/questions/24873219/cgfloat-is-not-convertible-to-uint8-and-other-cgfloat-issues-with-swift-and) – Sunny Shah Nov 28 '14 at 05:11
  • Both of above are working for me, check it once again(i have tried it in playground) – Mehul Thakkar Nov 28 '14 at 05:18

2 Answers2

1

just try

self.frame.size.width 
Kampai
  • 22,848
  • 21
  • 95
  • 95
Shanmugasundharam
  • 2,082
  • 23
  • 32
1

Xcode is leading you astray -- literals shouldn't really ever cause problems, as they'll get converted into Double or CGFloat as needed once everything else is the same type. Instead, what's going on is that you have an Int at the very end of your line:

... * self.size.height * _activeEnemiesArray.count)

That count property needs to be converted to CGFloat so it can be used with the rest:

... * self.size.height * CGFloat(_activeEnemiesArray.count))
Nate Cook
  • 92,417
  • 32
  • 217
  • 178