UITableView in Swift

前端 未结 17 1417
滥情空心
滥情空心 2020-12-04 08:09

I\'m struggling to figure out what\'s wrong with this code snippet. This is currently working in Objective-C, but in Swift this just crashes on the first line of the method.

17条回答
  •  感动是毒
    2020-12-04 08:17

    Why not this?

    (please delete if i am not in the goal...)

    func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
    
        if let cell: UITableViewCell = theTableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath) as? UITableViewCell {
            // cell ok
        }else{
           // not ok
        }
    }
    

提交回复
热议问题