I am trying to make an app for iOS 8 using swift. The goal here is to make a kind of news feed. This feed displays posts from users who follow a specific pattern.
I was thinking about using a UITableView, where each cell follows a custom layout. The problem occurs when I try to access a text label inside it. I try to access it by its tag, but when I do this, the entire application crashes. The reported error is "Swift dynamic cast failed" , and I use the following code to access the view:
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { let cellId: String = "cell" var cell : UITableViewCell = tableView.dequeueReusableCellWithIdentifier(cellId) as UITableViewCell if let ip = indexPath{ cell.textLabel.text = myData[ip.row] as String var lbl = cell.contentView.viewWithTag(0) as UILabel lbl.text = "ola" } return cell }
Am I doing something wrong? Thanks in advance!
source share