Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search Segue Identifier in storyboard?

I have a lot of controller in my storyboard and i am calling.

[self performSegueWithIdentifier:@"someIdentifier" sender:self];

If i want to search the controller associate with someIdentifier in xcode storyboard then how can i do?

Is there any way or i have to click and check on all the controller?

like image 452
Rajneesh071 Avatar asked Jul 08 '14 10:07

Rajneesh071


People also ask

How do I get a segue identifier?

Adding A Segue IdentifierSelect the segue by clicking on it. With the segue selected, navigate to the Attributes Inspector in the Utilities area. Set the Identifier field to displayNote .

How do you set the identifier on a storyboard?

Step 1: Set a Storyboard IDIn the Storyboard, select the view controller that you want to instantiate in code. Make sure the yellow circle is highlighted, and click on the Identity Inspector. Set the custom class as well as the field called "Storyboard ID". You can use the class name as the Storyboard ID.

How do you add embed segue to a storyboard?

To create a segue between view controllers in the same storyboard file, Control-click an appropriate element in the first view controller and drag to the target view controller. The starting point of a segue must be a view or object with a defined action, such as a control, bar button item, or gesture recognizer.


2 Answers

As suggest by Drux:

The best way i found is search Segue Identifier in the XML source code (Open As | Source Code) for the name of the viewcontroller and take it from there.

like image 148
Rajneesh071 Avatar answered Sep 20 '22 01:09

Rajneesh071


Unfortunately there's no way in code to find storyboard identifiers for a view controller / storyboard scene.

You could consider adding an additional target/build phase to your project that runs a script to extract the segue identifiers from the storyboard XML and convert into a file of constants you can import. Then you get runtime checking of the strings.

Something like this (for push segues):

grep -r -h  "kind=\"push\"" *.storyboard | sed -e 's/.*identifier="\(.*\)".*id=\".*/extern NSString * const XXXSegueName_\1;/' | sort | uniq  > "XXXSegueConstants.h"
grep -r -h  "kind=\"push\"" *.storyboard | sed -e 's/.*identifier="\(.*\)".*id=\".*/NSString * const XXXSegueName_\1 = @\"\1\";/' | sort | uniq  > "XXXSegueConstants.m"

should give you:

extern NSString * const HDCSegueName_PushMyViewController;

and

NSString * const HDCSegueName_PushMyViewController = @"PushMyViewController";

I'll leave other segue types as an exercise for the reader!

like image 41
Ashley Mills Avatar answered Sep 19 '22 01:09

Ashley Mills