A
A
Arseniy2012-02-26 11:09:21
iOS
Arseniy, 2012-02-26 11:09:21

Working with segue.destrinationViewController in Xcode?

Good day!
Stuck in a problem, I've been digging for the second day.
There are two view controllers (let's call them VC1 and VC2). They are interconnected by a transition (segue) in Xcode (ctrl-drag from VC1 to VC2, the choice of method is push). I want to prepare VC2 for display:
VC1.m:

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

blahblah is a VC2 method that takes id as a parameter. When executing the code, I get an exception with the words:
"reason: '-[UIViewController blahblah:]: unrecognized selector sent to instance 0x6a73630'"
After a long dance with a tambourine, I decided to replace the code with:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender<br/>
{<br/>
 if ([segue.identifier isEqualToString:@&quot;mySegue&quot;]) <br/>
 {<br/>
 NSLog(@&quot;source VC - %@&quot;, segue.sourceViewController);<br/>
 NSLog(@&quot;target VC - %@&quot;, segue.destinationViewController); <br/>
 }<br/>
}<br/>

when executed I get in the log:
source VC - &lt;VC1: 0x6861ed0&gt;<br/>
target VC - &lt;UIViewController: 0x6878670&gt;<br/>

Those. the target VC is not of my type, so the correct method is not being called.
In all the examples that I see on the net, destinationVC is set to the VC type that is being prepared for display, so I could not find examples with such an error.
Ideas/suggestions/pointing to my joint? :)
P.S.: I tried deleting/recreating segue in the storyboard - the result is the same...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
An, 2012-02-26
@Flanker_4

Ok, I'll guess ...
I'm almost sure that the reason is in the wrong data of the Interface
Builder
image

A
Arseniy, 2012-02-26
@keyf

Yes, the class is correct, VC2.
I'll upload the project somewhere

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question