我非常感谢有人可以帮助我调用从内部super获取内容的语法.这是一个静态表.UITableViewCellfunc tableView (tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!)
override func tableView (tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
// The Objective-C code is: UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
var cell = super.??
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试过,但似乎无法获得正确的语法.提前致谢.
我已经实现了一个使用UITableViewController/UITableView和Core Data的iPhone应用程序.此外,我使用NSFetchedResultsController来管理表数据.这一切都很直接,效果很好.然后我决定在没有找到/检索的行时在UITableView中显示一条消息.在研究了这个之后,似乎最好的方法(也许唯一的方法)就是返回一个包含消息的"虚拟"单元格.但是,当我这样做时,我从运行时系统得到了一个令人讨厌的数据库,它抱怨(并且理所当然地)数据不一致:"无效更新:无效的节数.表视图中包含的节数...".这是相关代码:
- (NSInteger) numberOfSectionsInTableView: (UITableView *)tableView
{
if ([[self.fetchedResultsController fetchedObjects] count] == 0) return 1;
return [[self.fetchedResultsController sections] count];
}
- (NSInteger) tableView: (UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if ([[self.fetchedResultsController fetchedObjects] count] == 0) return 1;
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex: section];
return [sectionInfo numberOfObjects];
}
- (UITableViewCell *) tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
if ([[self.fetchedResultsController fetchedObjects] count] == 0) {
UITableViewCell *cell = [[UITableViewCell alloc] init];
cell.textLabel.text = @"No widgets found.";
return cell;
}
STCellView …Run Code Online (Sandbox Code Playgroud)