TableView rotation issue, crashes

Reposted - had it in wrong book category.

I’m currently doing the StoreSearch tutorial and as of lat it keeps crashing due to following error…

2019-11-19 18:11:32.056113+1000 StoreSearch[3317:436206] [Window] Manually adding the rootViewController’s view to the view hierarchy is no longer supported. Please allow UIWindow to add the rootViewController’s view to the view hierarchy itself.
URL: '’
Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file /Users/iMac2013/OneDrive/_CODING_Drives/Tutorials/iOS_Apprentice/StoreSearch/StoreSearch/SearchViewController.swift, line 67

line 67 (in SearchViewController.swift) is,
// reloads the tableview data

note - I am using devices (iPhone or iPad, whichever I get my hands on first) rather than the simulator. but the error and crash is exactly the same on both… even if I only checkmark the device I test on.

I don’t think it is a tutorial issue but an Xcode issue as there seems to be similar occurrence when I do a search for it… but can’t work out a fix.

to keep the tutorial going I have found that if I set it to portrait only (in the Xcode app setting) it won’t crash… but strangely you can rotate the tablet/phone and it will rotate and run in landscape even though landscape is unchecked… and it won’t crash/ check the landscape box for an and it crashes in landscape.

is this something that can be addressed within the tutorial code or is this just an apple bug that will keep going till fixed.

set rootViewController of window in AppDelegate

one of the ways to resolve these sort of errors yourself is straight up copy paste the error in the google search bar

check the outlets in the search view controller. Probably you mis-connected the view controller to “view”

Thanks for response… everything hooked up right. I think it is an Xcode thing as my fix is clean the build then do a fresh build… works every time, however if I build without a clean then second, third or fourth build to device will crash. This is the only app/tutorial it happens on so not too fussed. Thanks all.

@zoran Do you still have issues with this?

all good. just have to treat as Xcode glitch.I do a “clean the folder” on it and works fine. reverts to crashing on next “run to device” unless I clean folder beforehand. not fussed.

This topic was automatically closed after 166 days. New replies are no longer allowed.