Skip to content

Instantly share code, notes, and snippets.

@himaratsu
Created October 14, 2014 02:47
Show Gist options
  • Save himaratsu/c528f217a6ee13962967 to your computer and use it in GitHub Desktop.
Save himaratsu/c528f217a6ee13962967 to your computer and use it in GitHub Desktop.
swift_cast

CGFloat convert int みたいなエラーが出るとき

stampNineView.frame = CGRectMake(self.frame.size.width * CGFloat(i), 0, self.frame.size.width, self.frame.size.width)

Swiftは型に厳しいので、 self.frame.size.width * i とかしてたら怒られる。
Objective-C時代は暗黙的にキャストしてくれてたので。

self.frame.size.width * CGFloat(i)

とCGFloatキャストをかませばOK。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment