App crash. Generic type and Protocol
| Originator: | konstantin.koval1 | ||
| Number: | rdar://18879087 | Date Originated: | 05-Nov-2014 12:25 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 6.1 (6A1052d) |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary:
I have an DataModel with Generic type array.
When I select cell I want to pass this item to delegate.
Delegate has a method with protocol type, not an class type.
App crash. If I change method type of a delegate from protocol to class, it works
App crashes in strange place
///// code
// View controller
class ArmaturListViewController: UITableViewController {
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("ArmaturTupeCell", forIndexPath: indexPath) as UITableViewCell
let armatur = viewModel.tableModel[indexPath]
cell.textLabel.text = armatur.name // CRASH HERE!
return cell
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let armatur = viewModel.tableModel[indexPath]
if let armatruSetupVC = targetViewControllerForAction("selectArmatur:", sender: self) as? ArmaturDrillingSetupViewController {
armatruSetupVC.selectArmatur(armatur)
// Change this method type to fix
}
}
}
// ArmaturDrillingSetupViewController
func selectArmatur(armatur: ArmaturType) {
Swell.debug("Select armatur")
}
FIX!!
If I change type of that method app works!!
func selectArmatur(armatur: Armatur) {
Swell.debug("Select armatur")
}
Steps to Reproduce:
Run code. Crash every time.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!