0

i have a subclass of UIViewController, and when it is called from another class the app just freezes - i used the Xcode debugger and figured that when I'm trying to access the class's view property the app freeze. another weird thing is that when i type in the debugger control panel: "po objectOfTheProblematicClass.view" the debugger stops responding. the code I used was similar to this:

    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
WTStickyViewController *stickyVC = [sb instantiateViewControllerWithIdentifier:@"WTStickyViewController"];
stickyVC.sticky = sticky;
// Setup view controller containment:
[self.parentViewController addChildViewController:stickyVC];

self.containerView = self.parentViewController.view;
[self.containerView addSubview:stickyVC.view];

WTStickyViewController is the subclass of UIViewController. the app freezes when it reaches

       [self.containerView addSubview:stickyVC.view];

but it's because this is the first time that stickyVC.view is called.
if for example i would put somewhere in the code

UIView *viewForExample = stickyVC.view;

the app would freeze there.
the exact same app works fine when compiled on a device with iOS 8 but has this problem with iOS 9. if anyone knows why is this happening and if there is a solution it will be great. thank you.

8
  • did you call the super in your subclass viewLoad method Commented Sep 7, 2015 at 6:55
  • Check your breakpoints. Xcode can hang when trying to break if there is an error in the breakpoint condition or command.
    – user4151918
    Commented Sep 7, 2015 at 7:03
  • Update your question with the relevant code causing you the problem.
    – rmaddy
    Commented Sep 7, 2015 at 7:05
  • @PetahChristian even without breakpoints the app freeze.
    – Nitzan R
    Commented Sep 7, 2015 at 7:44
  • @RaheelSadiq I didn't override loadView if that's what you meant
    – Nitzan R
    Commented Sep 7, 2015 at 7:45

2 Answers 2

1

I was having a similar issue and it was absolutely maddening. The CPU went to around 100% in the resource monitor during debug as the app deadlocked. Printing to console or just generally accessing the view controller's view property caused this behavior. Ultimately, what 'fixed' it for me was removing it from the base localization file. I know that doesn't make sense, but I'll elaborate as best as I can.

I'm maintaining a legacy universal app that has 2 'main' storyboards called Main_iPhone and Main_iPad, which as you can probably guess are the loaded dynamically based on what device you're launching on. I noticed that only the iPhone nib view was deadlocking as described, and iPad was loading fine. The only thing I could tell as that the iPhone storyboard had localization enabled while the iPad storyboard had not. So here's the steps I took loosely to remove it from base localization (you may want to do this in a separate branch/sandbox to make sure this works before deleting project references):

  1. Right click the problematic view and/or storyboard in question, show in finder. For me it was inside the Base.lproj folder as expected.
  2. [Re]move the file to a different directory so Xcode can not find the link the project (file goes red in file browser). Press delete to remove the file from the project file's reference from the project itself.
  3. Add the file back at the new location in your repository/project structure so Xcode picks it up as a new file. Ensure all of your references to the file are updated to the new location.
  4. Verify your storyboard/xib file is not localized anymore, clean project, re-run and see if the issue is still there (see image). Non-localized setting

You can also just update the file location using the update location button in the file properties view on the right side (see other image). enter image description here

Don't know if this will fix it, but I thought I'd share what helped me in the chance that it helps others as well.

2
  • seems like you had exactly the same problem. Since I wrote the question I consulted with a more experienced developer than myself, and we figured that the problem had something to do with the new Xcode 7. when compiled on Xcode 6 it works fine. We are probably going to report to apple about this, and hopefully they will fix this issue.
    – Nitzan R
    Commented Oct 21, 2015 at 6:21
  • It did seem odd, and I attempted to recreate it in a test project with no success yet. If you file a bug report, I'd be appreciative if you posted the open radar link.
    – Jack B
    Commented Oct 21, 2015 at 13:53
0

A bug report was sent to apple and hopefully it will be fixed soon - the problem is indeed with Xcode 7. If you are encountering a similar problem, it can be solved by doing one of the following: 1) Use Xcode 6.4, at least until apple fixes this bug.

2) Rebuild the problematic view in the storyboard.

I will post the radar link once I got a chance to speak with my manager about it...

Not the answer you're looking for? Browse other questions tagged or ask your own question.