performSegueWithIdentifier does not trigger prepareForSegue when app build with Xcode 9.2

Greetings! I have an app. When built under Xcode 8, it runs fine in all previous device iOS (just verified with iOS 11.0.3, 10.3, 10.0, 9.0).


However, when built under Xcode 9.2 (9C40b), it hangs under iOS 11.0.3 when calling "performSegueWithIdentifier:sender:".


It looks as if prepareForSegue is not being called. And it just "sits" there in limbo.


How do I find out why? And code around it?


Thanks, -A

Replies

Does it work correctly in simulator ?

Unknown at this time. I am having server connectivity issues in the simulator, which I do not have on the device. So, I cannot get to the spot causing me problems.

Can you post the complete code for prepareForSegue, now named prepare(for:sender:)

Thanks! Let me get something together.

While I am getting the code snippet(s) together, let me describe what is happening.


I have EDViewController. Lets call it EDVC for short. A button press on the status bar triggers multiple calls to EDVC.prepareForSegue.


a) EDVC.prepareForSegue checks the segue.identifier. Base on the segue.identifier, EDVC.prepareForSegue sets destinationViewControllers based on the identifier,


b) EDVC.viewDidAppear is then called,


c) EDVC.viewDidAppear checks the vars set when EDVC.prepareForSegue was called. Based on that:


d) EDVC.viewDidAppear then [self performSegueWithIdentifier:kSegueEditToDemographics sender:self];


e) That triggers another call to EDVC.prepareForSegue,


f) Withing EDVC.prepareForSegue, the identifer kSegueEditToDemographics triggers the segue to DemoViewController,


g) DemoViewController.viewDidLoad is called.


Prior to Xcode 9/iOS 11 upgrade, a-g happens.


After upgrade, f) and g) are not called.


There might be something going on (that has changed for iOS 11) when triggering a segue from viewDidAppear. But I am guessing.


Thanks,


Allen

In b, do you call EDVC.viewDidAppear youself, or do you think that's what the system is doing ?

It is coming from UIApplicationMain. I am not calling it.

I do not understand your sequence.


You press a button in EVDC.


That means that the view has appeared.


So how can you assume that EDVC.viewDidAppear will be called again ?


a) EDVC.prepareForSegue checks the segue.identifier. Base on the segue.identifier, EDVC.prepareForSegue sets destinationViewControllers based on the identifier,

b) EDVC.viewDidAppear is then called,


Or it is another EDVC.view ?


Not clear for me.

Let me try to clarify. There is a DictationListMasterViewController, which has a toolbar. On it, is the button which triggers EDViewController. The EDVC, through the sequence above, determines where to go. Verbally it does this: the button creates (or edits) a dictation. If the demographics for the dictation are "complete", it segues to a recorder (so you can begin recording). If the demographics are "not complete", then it segues to a demographics scene to obtain the missing info. When demographics is dismissed, then go to recorder.


I have narrowed it down to what happens immediately after performSegueWithIdentifier.


Prior to Xcode 9/iOS 11 upgrade, performSegueWithIdentifier triggers demographics viewDidLoad. After the Xcode 9/iOS 11 upgrade, the demographics screen does not appear. There is no viewDidLoad. No viewWillAppear. No viewDidAppear. Nothing, just a black screen.


One last observation: when the code is built with Xcode 8, it runs on iOS 8/9/10/11 devices just fine. There is something that has changed, which has me stumped.


I am trying to distill the code down to essential code, so I can post it. Way easier said.


Thanks, -A

Yes, posting code will ease analysis. Include perform(segue…)

Sorry about that. I had some production issues, so had to downgrade to Xcode 8 to prepare for a release.


Lines 11-17 are what kick off the segue. I included doAfterAlertActions: as well. Just to restate what I am seeing:


Prior to Xcode 9/iOS 11 upgrade, performSegueWithIdentifier (line 15) triggers DemographicsVC viewDidLoad, and everything appears.


After the Xcode 9/iOS 11 upgrade, the DemographicsVC screen does not appear. DemographicsVC viewDidLoad is not called. No viewWillAppear. No viewDidAppear. Nothing, just a black screen.


I can add more snippets, if necessary. Thanks!


---------- 8 < ------------ cut here ---------- 8 < -------------


// EditDictationViewController.m

1-(void)viewDidAppear:(BOOL)animated

2{

3

4 [super viewDidAppear:animated];

5

6 [[SharedApplication sharedInstance] turnOffSleepMode];

7

8 if ([Utilities IsSmallFormat])

9 {

10 //If a new dictation doesn't have demographics, the editor passes control to the demographics screen

11 if (!self.demographicsInitialized && self.newDictation)

12 {

13 self.navigationController.navigationBar.alpha = k1Percent;

14 [Utilities doAfterAlertActions:^{

15 [self performSegueWithIdentifier:kSegueEditToDemographics sender:self]; NSLog(@"Stack trace B: %@", [NSThread callStackSymbols]);

16 }];

17 }

18 }

19 [SharedApplication sharedInstance].segueInProgress = nil;

20 [self setMicrophoneState];

21}

22

23+(void)doAfterAlertActions:(void (^)(void))simpleBlock

24{

25

26 SharedApplication *sa = [SharedApplication sharedInstance];

27

28 for (DFAlertView *alert in sa.alertViews)

29 {

30 if (alert.isBeingPresented || alert.isBeingDismissed)

31 { // if one is found, queue up another try in 5 ms

32 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(k5Milliseconds * NSEC_PER_SEC)),

33 dispatch_get_main_queue(), ^{

34 [Utilities doAfterAlertActions:simpleBlock];

35 });

36 return;

37 }

38 }

39 simpleBlock();

40}