简体   繁体   中英

IOS compiler warning “Multiple segues with identifier work”

So i am re-using a view for multiple segues, i have a UITableView, which contains 4 Cells

Work1 - Tag 1 Work2 - Tag 2 Work3 - Tag 3 Work4 - Tag 4

I have tagged each cell accordingly, now, in prepare for segue with identifier, i fetch the tag of the index row selected, and set it in the new next view, which i then segue over to.

In the other View, i intercept the value and set some things in the view accordingly.

For this to work, i need 4 segues with the same identifier, one from each static cell. (I have the cell actions set up via storyboard)

This leads to this warning, is there any way to get around this?

EDIT: I asume i would have to hook up the segues programmatically, so how would i do this?

You probably can't have two segues with the same identifier on your Storyborad. And I highly doubt you can do this in code too. So why bother and not use just 1 universal segue that will be called programatically by [self preformSegueWithidentifier:@""]; ?

I do not understand why you "need 4 segues with the same identifier". And this warning is here for a good reason.

If I tell you "Go talk to Jim". And you know 4 people named Jim, how would you possibly know which Jim I was referring to. The same thing is happening here, you are telling a view controller to use a segue, but it has 4 of them named the same thing, so it has no idea what segue to use. Doing this programmitically will not fix anything.

You only get a warning because the code will work, it will run a segue, but you have no idea of knowing which one it will run.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM