On Mon, Oct 12, 2015, at 03:45 PM, Alex Hall wrote:
> I'm guessing the best thing to do is to set each cell's segue in code,
> when that cell is made? I know what the cell references in the data, so I
> can just look at the data and determine the segue needed, then set it. Is
> there a better/recommended way of doing this, or is what I'm planning
> going to be the best solution? Thanks.

For your information: you cannot assign segues in code. You can
_perform_ them, via the -[UIViewController
performSegueWithIdentifier:sender:] method. But the segue must be
defined in Interface Builder.

If you do not want to create multiple prototype cells, you can always
define the segue by dragging from the view controller that contains the
table view, rather than from the table view cell itself. This creates a
so-called "manual" segue, since the only way to trigger it is in code.
In this case, you'd either implement an IBAction method or the table
view's selection delegate methods to perform the appropriate segue from
code.

You might choose to do this if your cells are reasonably complex and
might need to dynamically segue to different destinations based on their
content. In that case, the little bit of extra boilerplate in your view
controller is much better than the risk of breakage that comes with
duplicating your prototype cells.

--Kyle Sluder
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (Xcode-users@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to