Please tell me how to pass the URL without using sugar.

Asked 1 years ago, Updated 1 years ago, 95 views

In Xcode 7.3, if you click tableview without using the storyboard, you will be writing the source for the screen transition to DetailViewController.swift.

I would like to substitute the value of self.List [indexPath.row] for CustomViewController.entry, but I got an error saying cannot assign value of type self.List [indexPath.row] and I cannot substitute it.

The self.List [indexPath.row] contains the URL.

How do I pass the URL to the CustomViewController without using sugue?

override functableView(tableView:UITableView, didSelectRowAtIndexPath:NSIndexPath){

    letCustomViewController=DetailViewController()
    CustomViewController.entry=self.List [indexPath.row]
    parent!.navigationController!.pushViewController(detailViewController, animated:true)
}

swift2 xcode7

2022-09-30 17:21

1 Answers

I would like to substitute the value of self.List [indexPath.row] for CustomViewController.entry, but I got an error saying cannot assign value of type self.List [indexPath.row] and I cannot substitute it.

The error indicates a type mismatch: CustomViewController.entry and self.List [indexPath.row] do not match and cannot be substituted.
Swift is a type-sensitive language, for example, you cannot even substitute a value of type Float for a variable of type Double.You can only substitute variables of type Any for variables of type parent class with child class instances, between upcast and typealias, and between the same entity.

The self.List [indexPath.row] contains the URL.

If you only write the URL, but you don't know if it's a string type or an instance of NSURL, you can't move on.And the problem is not directly related to "how to pass a URL without using suuge." (suugeseuge)


2022-09-30 17:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.