Group Group Group Group Group Group Group Group Group

SwiftUI · Using Bindings to Build a Settings Page | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4001741-swiftui/lessons/32

When finishing the PetReplacementRow, I noticed that the preview works when looking at PetReplacementRow by itself. When opening SettingsView, I get the following error:

PotentialCrashError: P04E04-Complete.app may have crashed

P04E04-Complete.app may have crashed. Check ~/Library/Logs/DiagnosticReports for any crash logs from your application.

==================================

| Error Domain=com.apple.dt.ultraviolet.service Code=12 “Rendering service was interrupted” UserInfo={NSLocalizedDescription=Rendering service was interrupted}

When opening ContentView, the Preview for MewsListView works just fine, but the SettingsView crashes too.

Works on a Device (iPhone 11 Pro) and Simulators. In Device and Simulators though, when tapping the “Replace Pet” Picker, the CatMaskImage appears without content inside. Don’t know if this is related to the above crash.

Xcode version 11.2.1
OS 10.15.1

If anyone found the same error:

From the logs found out that the EnvironmentObject petPreferences in SettingsView was not being set when trying to preview SettingsView or ContentView. Solved this by adding:

static let petPreferences = PetPreferences()

static var previews: some View {
    SettingsView().environmentObject(petPreferences)
}

inside SettingView. Doing the same environment in ContentView. That way the previews can be used without crashing. Correct me if I’m wrong, but SceneDelegate is providing the EnvironmentObject only when running on simulator or a device.

Still can’t get the images to show when tapping the picker, though.

1 Like

When running on the simulator, I do not see the images when drilled into the picker either. Some quality control issues with this class for sure.

Hey Im sorry you’ve had issues with this class. We’re doing a review just now and will fix all the little issues we possibly can. Thanks so much for reporting it and it will probably be a silly mistake I made somewhere. Have a nice day :smiley:

yes, you need to pass .environmentObject() to every Previews

Seems like many photos were missing?
Like the Profile pictures folder

I tried to add the pictures but keep getting this black profiles

Assets are missed for profile images!

Maybe something’s wrong

I get fatal error: Index out of range when moving the slider!

Hey @jawad14 - an update is about to be published with all the assets included. They’re in the ‘completed’ folder if you need them. Laurie.

1 Like

@jawad14 in regards to your ‘out of range’ exception, can you show me the code you’ve got? I’ve just double-checked the project and code and everything is working fine. Thanks so much. Laurie.

Thanks @isaacmendez I’ve tested the code in end folder and it works with no crashes unlike the code I’ve added in Begin folder which means this app crash caused by me ^^.

Let me take this chance to say Thanks so much for all efforts
you’ve put in this course also I liked your smiles in the videos :grinning:.