小编use*_*302的帖子

带有标识符的 NSTableView 单元格保持为零

我正在构建 MacOS 应用程序。当我按下添加按钮时,我正在尝试制作更新单元格的表格视图。

在此处输入图片说明

以下是我的代码:

 func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
    let identifier = tableColumn?.identifier as NSString?
    if ( identifier == "NameCell")
    {
        var result: NSTableCellView
        let cell = tableView.make(withIdentifier: "NameCell", owner: self) as! NSTableCellView
        cell.textField?.stringValue = self.data[row].setting!
            return cell

    }
    else if (identifier == "SettingCell")
    {
        if let cell = tableView.make(withIdentifier: "SettingCell", owner: self) as? NSTableCellView {
        cell.textField?.stringValue = self.data[row].setting!
        return cell
    }
    }
    return nil
}
Run Code Online (Sandbox Code Playgroud)

但是,行 let cell = tableView.make(withIdentifier: "NameCell", owner: …

macos cocoa nstableview nstableviewcell swift3

4
推荐指数
2
解决办法
3297
查看次数

查找文本中“ x”的确切单词的实例数

我正在c#中查找确切的单词“ x”的实例数。例如:

List<string> words = new List<string> {"Mode", "Model", "Model:"};
Text= "This is Model: x Type: y aa: e";
Run Code Online (Sandbox Code Playgroud)

我用过正则表达式:

for(i=0; i<words.count; i++)
{
    word= list[i]
    int count= Regex.Matches(Text,word) 
}
Run Code Online (Sandbox Code Playgroud)

但是它不起作用。以上代码的结果给了count=1每一个ModeModelModel:。我想有我统计是0Mode0Model,但1对于Model:它找到确切的词的实例的数量。

忘了我不能在我的情况下使用split。有什么办法可以让我不使用split吗?

c# regex string

2
推荐指数
1
解决办法
128
查看次数

相同的方法有两个不同的名字?

我喜欢使用相同的方法,但两个不同的名称.

例如:

def func(a):
    print a

def func2(a):
    print a

n= "yes"
func(n)
func2(n)
Run Code Online (Sandbox Code Playgroud)

答案应该是:

"yes"
"yes"
Run Code Online (Sandbox Code Playgroud)

我能做什么办法:

def fun(a) or func2(a):
    print a
Run Code Online (Sandbox Code Playgroud)

或类似的东西?

python function python-2.7

0
推荐指数
1
解决办法
145
查看次数