Working with segue.destrinationViewController in Xcode?

Good day!


Stuck in the problem, digging for a second day.

There are two view controller (let's call them VC1 and VC2). They are linked by a transition (segue) to Xcode (ctrl-drag from VC1 to VC2, the choice of method — push). Want to prepare VC2 to display:


VC1.m:
(...)<br>
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender<br>
{<br>
 if ([segue.identifier isEqualToString:@"mySegue"]) <br>
{<br>
 VC2 *vc = segue.destinationViewController;<br>
 [vc blahblah:self];<br>
}<br>
}<br>



blahblah — method VC2 host id in KACH-ve parameter. When you run the code get acceptn with the words:

"reason: '-[your uiviewcontroller blahblah:]: unrecognized selector sent to instance 0x6a73630'"


After long dances with a tambourine decided to replace the code to:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender<br>
{<br>
 if ([segue.identifier isEqualToString:@"mySegue"]) <br>
{<br>
 NSLog(@"source VC - %@", segue.sourceViewController);<br>
 NSLog(@"VC target - %@", segue.destinationViewController); <br>
}<br>
}<br>



when you perform a get in the log:
source VC - <VC1: 0x6861ed0><br>
target VC - <your uiviewcontroller: 0x6878670><br>



I.e. the target VC is not my type, and therefore not invoked the appropriate method.

In all the examples I see in the network, destinationVC is set to the type of the VC which is to be shown, so examples of this error could not find it.


Ideas/assumptions/guidance at my school? :)


PS: tried to delete/re-create segue in storyboard — the same result...
October 8th 19 at 02:56
2 answers
October 8th 19 at 02:58
OK, tell fortunes...
Pretty sure that the reason you provided incorrect information Interface Builder a
Check whether the class VC2 to the line that the picture below is marked with number 3
image
October 8th 19 at 03:00
Yes, the class is correct, VC2.
Now pour the project to the thread
As usual, we should involve someone from the "outside" to the problem as "it" itself is allowed.
The problem was that I ignored as the linker swore at my class VC2 during start-up (solution here stackoverflow.com/questions/1725881/unknown-class-myclass-in-interface-builder-file-error-at-runtime). Now all decided.

Thank you :) - Ova_Flatl commented on October 8th 19 at 03:03

Find more questions by tags Apple XcodeiOS