我正在尝试将 a 添加UISearchController
到以编程方式创建UITableView
的UIViewController
类中。这是我的代码:
var resultSearchController = UISearchController()
var myTableView = UITableView()
override func viewDidLoad() {
super.viewDidLoad()
myTableView.frame = CGRectMake(0, 0, view.bounds.width, view.bounds.height)
myTableView.delegate = self
myTableView.dataSource = self
myTableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
self.resultSearchController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchResultsUpdater = self //ERROR
controller.searchBar.delegate = self //ERROR
controller.dimsBackgroundDuringPresentation = false
controller.searchBar.sizeToFit()
self.myTableView.tableHeaderView = controller.searchBar
return controller
})()
UIApplication.sharedApplication().keyWindow?.addSubview(myTableView)
}
Run Code Online (Sandbox Code Playgroud)
我得到的两个错误是
- Cannot assign a value of type 'ViewController' to a value of type 'UISearchBarDelegate? …
Run Code Online (Sandbox Code Playgroud) 假设我有两个功能:
void function1(int *ptr) {
printf("%d", *ptr);
}
Run Code Online (Sandbox Code Playgroud)
和
void function2(char *str) {
printf("%s", str);
}
Run Code Online (Sandbox Code Playgroud)
为什么function2工作,以前没有deference运算符str
?在str
只存在地址它指向的不是价值,因为我以为.
我的问题很简单,就像谷歌让我失望一样.如何将无界字符串转换为整数?
如果字符串有界,我可以这样做: I : Integer := Integer'Value("613");
但是,我的字符串无限制,Ada抛出此错误:
expected type "Standard.String"
found private type "Ada.Strings.Unbounded.Unbounded_String"
我想做什么?
说我有这个字符串: "this","is a, string"
我希望能够检查逗号是否在一对引号内。第一个逗号不是,而第二个逗号是。我怎么能在 C 中实现这一点?