Created
September 10, 2014 07:47
-
-
Save lfaoro/c7fea170d6da0f1878fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have all these cases that assign a lengthy subview repetitive code: | |
case (1, 1), (1, 8): | |
var value = Piece(color: .w, shape: .R) | |
var pieceImg = NSImage(named: "wR") | |
var pieceView = NSImageView(frame: CGRect(x: squareX, y: squareY, width: cellLength, height: cellLength)) | |
pieceView.image = pieceImg | |
boardView.addSubview(pieceView, positioned: .Above, relativeTo: nil) | |
What if I assign just the: | |
var value = Piece(color: .w, shape: .P) | |
cellState[notation] = value | |
to every case: and then do an iteration for the subview assignment? | |
for n in notation | |
if cell != nil { | |
var pieceImg = "piece" | |
addView.image = pieceImg | |
boardView.addSubview addView | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment