You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Aplikasi tetap berjalan cuma gak menampilkan berita apapun karena ada masalah di image icon bookmark
Penyebab error:
Thread 1: Fatal error: No ObservableObject of type ArticleBookmarkViewModel found. A View.environmentObject(_:) for ArticleBookmarkViewModel may be missing as an ancestor of this view.
No ObservableObject of type ArticleBookmarkViewModel found. A View.environmentObject(_:) for ArticleBookmarkViewModel may be missing as an ancestor of this view.
CrashReportError: Preview is missing environment object "ArticleBookmarkViewModel"
iNews crashed due to missing environment of type: ArticleBookmarkViewModel. To resolve this add .environmentObject(ArticleBookmarkViewModel(...)) to the appropriate preview.
// Bookmark button Button { toggleBookmark(for: article) } label: { // jika ada Artikel yang di Bookmark maka munculkan icon Bookmark Fil, jika tidak ada maka pakai icon bookmark biasa Image(systemName: articleBookmarkVM.isBookmarked(for: article) ? "bookmark.fill" : "bookmark") }
The text was updated successfully, but these errors were encountered:
Penyebab: kesalahan pemanggilan environment object di root project file iNews.swift, dan di Views files folder ArticleRowView.swift, ArticleListView.swift, dan NewsTabView.swift
Dari code ini di iNews.swift: @StateObject var articleBookmarkVM = ArticleNewsViewModel()
menjadi @StateObject var articleBookmarkVM = ArticleBookmarkViewModel()
Dari code ini di ArticleRowView.swift, ArticleListView.swift, dan NewsTabView.swift: @StateObject static var articleBookmarkVM = ArticleNewsViewModel()
menjadi @StateObject static var articleBookmarkVM = ArticleBookmarkViewModel()
Hasilnya: Preview Canvas bisa dilakukan dan tidak ada error ketika build & run di ios emulator
Notes: HARUS HATI-HATI KETIKA MEMANGGIL ENVIRONMENT OBJECT
Aplikasi tetap berjalan cuma gak menampilkan berita apapun karena ada masalah di image icon bookmark
Penyebab error:
CrashReportError: Preview is missing environment object "ArticleBookmarkViewModel"
iNews crashed due to missing environment of type: ArticleBookmarkViewModel. To resolve this add
.environmentObject(ArticleBookmarkViewModel(...))
to the appropriate preview.// Bookmark button Button { toggleBookmark(for: article) } label: { // jika ada Artikel yang di Bookmark maka munculkan icon Bookmark Fil, jika tidak ada maka pakai icon bookmark biasa Image(systemName: articleBookmarkVM.isBookmarked(for: article) ? "bookmark.fill" : "bookmark") }
The text was updated successfully, but these errors were encountered: