这可能有一个简单的答案,但我找不到我已经完成的工作,所以我只是发表评论的全部内容。这是卡片游戏的主要文件,我使用多维数组制作卡片组。
class GameViewController: UIViewController
{
var royal = false
var HandMe: [[String]] = [[" ", " ", " ", " ", " "]]
var turn = "Computer"
var turns = 1
var Pot: [[String]] = [[" ", " ", " ", " ", " "]]
var Cards = [
["Queen", "Spades", "2", "yes", "Queen_Spades.jpg"],
["King", "Spades", "3", "yes", "King_Spades.jpg"],
["Jack", "Spades", "1", "yes", "Jack_Spades.jpg"],
["Ace", "Spades", "4", "yes", "Ace_Spades.jpg"],
["2", "Spades", "1", "no", "2_Spades.jpg"],
["3", "Spades", "1", "no", "3_Spades.jpg"],
["4", "Spades", "1", "no", "4_Spades.jpg"],
["5", "Spades", "1", "no", "5_Spades.jpg"],
["6", "Spades", "1", "no", "6_Spades.jpg"],
["7", "Spades", "1", "no", "7_Spades.jpg"],
["8", "Spades", "1", "no", "8_Spades.jpg"],
["9", "Spades", "1", "no", "9_Spades.jpg"],
["10", "Spades", "1", "no", "10_Spades.jpg"],
["Queen", "Hearts", "2", "yes", "Queen_Hearts.jpg"],
["King", "Hearts", "3", "yes", "King_Hearts.jpg"],
["Jack", "Hearts", "1", "yes", "Jack_Hearts.jpg"],
["Ace", "Hearts", "4", "yes", "Ace_Hearts.jpg"],
["2", "Hearts", "1", "no", "2_Hearts.jpg"],
["3", "Hearts", "1", "no", "3_Hearts.jpg"],
["4", "Hearts", "1", "no", "4_Hearts.jpg"],
["5", "Hearts", "1", "no", "5_Hearts.jpg"],
["6", "Hearts", "1", "no", "6_Hearts.jpg"],
["7", "Hearts", "1", "no", "7_Hearts.jpg"],
["8", "Hearts", "1", "no", "8_Hearts.jpg"],
["9", "Hearts", "1", "no", "9_Hearts.jpg"],
["10", "Hearts", "1", "no", "10_Hearts.jpg"],
["Queen", "Diamonds", "2", "yes", "Queen_Diamonds.jpg"],
["King", "Diamonds", "3", "yes", "King_Diamonds.jpg"],
["Jack", "Diamonds", "1", "yes", "Jack_Diamonds.jpg"],
["Ace", "Diamonds", "4", "yes", "Ace_Diamonds.jpg"],
["2", "Diamonds", "1", "no", "2_Diamonds.jpg"],
["3", "Diamonds", "1", "no", "3_Diamonds.jpg"],
["4", "Diamonds", "1", "no", "4_Diamonds.jpg"],
["5", "Diamonds", "1", "no", "5_Diamonds.jpg"],
["6", "Diamonds", "1", "no", "6_Diamonds.jpg"],
["7", "Diamonds", "1", "no", "7_Diamonds.jpg"],
["8", "Diamonds", "1", "no", "8_Diamonds.jpg"],
["9", "Diamonds", "1", "no", "9_Diamonds.jpg"],
["10", "Diamonds", "1", "no", "10_Diamonds.jpg"],
["Queen", "Clubs", "2", "yes", "Queen_Clubs.jpg"],
["King", "Clubs", "3", "yes", "King_Clubs.jpg"],
["Jack", "Clubs", "1", "yes", "Jack_Clubs.jpg"],
["Ace", "Clubs", "4", "yes", "Ace_Clubs.jpg"],
["2", "Clubs", "1", "no", "2_Clubs.jpg"],
["3", "Clubs", "1", "no", "3_Clubs.jpg"],
["4", "Clubs", "1", "no", "4_Clubs.jpg"],
["5", "Clubs", "1", "no", "5_Clubs.jpg"],
["6", "Clubs", "1", "no", "6_Clubs.jpg"],
["7", "Clubs", "1", "no", "7_Clubs.jpg"],
["8", "Clubs", "1", "no", "8_Clubs.jpg"],
["9", "Clubs", "1", "no", "9_Clubs.jpg"],
["10", "Clubs", "1", "no", "10_Clubs.jpg"]
]
var last: UInt32 = UInt32(Cards.endIndex - 1)//instance member 'Cards' cannot be used on type 'GameViewController'
var random = Int(arc4random_uniform(last) + 1)//instance member 'last' cannot be used on type 'GameViewController'
var TopCard = UIButton(type: .Custom)
let image = UIImage(named: Pot[Int(last)][4])//instance member 'Pot' cannot be used on type 'GameViewController'
TopCard.setImage(image, forState: .Normal)
答案 0 :(得分:0)
使用先前定义的属性的代码必须位于方法内,或位于初始化程序内,或位于计算属性内。
git remote add origin https://USERNAME:PASSWORD@github.com/username/reponame.git
答案 1 :(得分:0)
事实证明,在表格加载之前我已经宣布了所有这些混乱。这就是为什么我有一百万个错误!谢谢你的答案!