我通常从来没有遇到过这个步骤的问题,但由于某种原因,当我重新设置我的故事板时,我的代码部分存在问题:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! UITableViewCell
(cell as! TableViewCell).usernameLabel.text = friendsArray[indexPath.row] as String
return cell
}
Run Code Online (Sandbox Code Playgroud)
我做了所有明显的事情,比如确保单元格标识符是"Cell".
我的错误是这样的:
无法将'UITableViewCell'(0x1094ada18)类型的值转换为'YOpub.TableViewCell'(0x106620410).
编辑:问题是我的didLoad函数中有self.tableView.registerClass(UITableViewCell.self,forCellReuseIdentifier:"Cell").删除此行后,我的代码再次运行.
到目前为止,我的代码旨在创建一副牌,9 - ACE每个套件的价值,并向4名玩家交易5张牌.这些牌是交易3-2-3-2然后2-3-2-3每个玩家总共有5张牌.稍后我会编写代码来洗牌,然后在euchre游戏中对它们进行比较,但是现在我只想要处理这些卡片.无论如何,它并不完全正常,我愿意接受建议.我得到的错误是"分段错误:11"
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
using namespace std;
int cards[24]; //array filled with card values
char DECK[24][25] =
{ //array filled with card names. Used for dealing //24elements long //25 characters in each element
"Ace of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades",
"Ace of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King …Run Code Online (Sandbox Code Playgroud) c++ arrays out-of-memory segmentation-fault multidimensional-array