ios - Cannot find an initializer for type 'CGSize' that accepts an argument list of type '(() -> _)' in Swift Project -


i working along stanford course , receiving error:

cannot find initializer type 'cgsize' accepts argument list of type '(() -> _)'  

this course taught couple months ago using xcode 6.2 instead of xcode 6.3. need differently correct error?

this lecture 12 - dynamic animation - http://web.stanford.edu/class/cs193p/cgi-bin/drupal/

enter image description here

import uikit  class dropitviewcontroller: uiviewcontroller {       @iboutlet weak var gameview: uiview!      var dropsperrow = 10      var dropsize = cgsize {         let size = gameview.bounds.size.width / cgfloat(dropsperrow)         return cgsize(width: size, height: size)     }      @ibaction func drop(sender: uitapgesturerecognizer) {         drop()     }      func drop() {         var frame = cgrect(origin: cgpointzero, size: dropsize)         frame.origin.x = cgfloat.random(dropsperrow) * dropsize.width          let dropview = uiview(frame: frame)         dropview.backgroundcolor = uicolor.random          gameview.addsubview(dropview)      }     }      private extension cgfloat {     static func random(max: int) -> cgfloat {         return cgfloat(arc4random() % uint32(max))      }     }      private extension uicolor {     class var random: uicolor {         switch arc4random()%5 {         case 0: return uicolor.greencolor()         case 1: return uicolor.bluecolor()         case 2: return uicolor.orangecolor()         case 3: return uicolor.redcolor()         case 4: return uicolor.purplecolor()         default: return uicolor.blackcolor()      } }  } 

first of all, typed cgfloat incorrectly. cgfloat not cgfloat.

for second part, change '=' ':' in dropsize:

var dropsize : cgsize {     let size = gameview.bounds.size.width / cgfloat(dropsperrow)     return cgsize(width: size, height: size) } 

also, first time have seen '=' used instead of ':' in swift, since release...


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -