我试图让用户能够查看表格视图中的某些项目,我实际上已经弄明白了但是我有错误:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath:
NSIndexPath!) {
tableView.deselectRowAtIndexPath(indexPath, animated: false)
# var tappedItem: AssesmentsManager = taskMgr.tasks[indexPath.row] as
AssesmentsManager
# tappedItem.send = !tappedItem.send
tableView.reloadData()
}
它说任务不能转换为AssesmentMAnager 和 AssesmentManager没有一个名为completed 的成员。
这是类 AssesmentManager.swift :
import UIKit
var taskMgr : AssesmentsManager = AssesmentsManager()
struct task {
var name = "Un-Named"
var score = "No-Score"
var send = false
}
class AssesmentsManager: NSObject {
var tasks = [task]()
func addtask(name: String, score: String, send: Bool) {
tasks.append(task(name: name, score: score, send: send))
}
}
答案 0 :(得分:0)
您必须将完成的bool变量添加到任务结构
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// The program needs to input an integer like 2341, then sum it as 2+3+4+1 + 10
// I am in putting an integer and will pass it to a funtion by &.
int main()
{
string strNumber;
int intNumber = 0;
cout << "Enter your number: ";
cin >> intNumber;
// programming the logic for sumTotal(& intNumber) function before creating
strNumber = to_string(intNumber);
cout << "Your number is: " << strNumber << endl;
cout << "Your numbers length: " << strNumber.length() << " digits" << endl;
// here I need to convert the string array to an integer array
for (int i = 0; i < strNumber.length(); ++i){
intNumber[&i] = strNumber[i] - '0';
cout << "Element [" << i << "] contains: " << strNumber[i] << endl;
}
// next a recursive function must sum the integer array
// I am taking an online course and cant afford a tutor please help!
system("pause");
return 0;
}
尝试直接编辑值
struct task {
var name = "Un-Named"
var score = "No-Score"
var send = false
}
class AssesmentsManager: NSObject {
var tasks = [task]()
func addtask(name: String, score: String, send : Bool) {
tasks.append(task(name: name, score: score, send: send))
}
}
答案 1 :(得分:0)
错误告诉您已完成的名称method or function or property
。因此,在 AssesmentsManager 类中,您需要实现一个