我正在构建 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: …
我正在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每一个Mode,Model和Model:。我想有我统计是0对Mode,0对Model,但1对于Model:它找到确切的词的实例的数量。
忘了我不能在我的情况下使用split。有什么办法可以让我不使用split吗?
我喜欢使用相同的方法,但两个不同的名称.
例如:
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)
或类似的东西?
c# ×1
cocoa ×1
function ×1
macos ×1
nstableview ×1
python ×1
python-2.7 ×1
regex ×1
string ×1
swift3 ×1