Hello,
I created a widget kit extension for my app and would like it to pull information from the iOS coredata model. I can not figure this out. Here is my code for the widget. Thanks in advance.
2020-06-23 19:15:50.041978-0400 AssignmentsExtension[94980:3425649] [error] error: +[Assignments entity] Failed to find a unique match for an NSEntityDescription to a managed object subclass
CoreData: error: +[Assignments entity] Failed to find a unique match for an NSEntityDescription to a managed object subclass
Program ended with exit code: 9
struct LeaderboardEntry: TimelineEntry {
public let date: Date
public let assign: String?
}
struct Provider: TimelineProvider {
@FetchRequest(entity: Assignments.entity(), sortDescriptors: []) var contactsreq: FetchedResults<Assignments>
@State var s: String?
public func snapshot(with context: Context,completion: @escaping (LeaderboardEntry) -> ()) {
let entry = LeaderboardEntry(date: Date(), assign: contactsreq[0].name!)
s = contactsreq[1].name
completion(entry)
}
public func timeline(with context: Context,
completion: @escaping (Timeline<Entry>) -> ()) {
let entry = LeaderboardEntry(date: Date(), assign: contactsreq[1].name))
let timeline = Timeline(entries: [entry, entry], policy: .atEnd)
completion(timeline)
}
}
struct AssignmentsEntryView : View {
func dateToSting(d: Date) -> String{
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "EE MMMM d, YYYY"
return dateFormatter.string(from: d)
}
var entry: LeaderboardEntry
var body: some View {
Text(entry.assign!)
}
}
@main
struct AssignmenstWidget: Widget {
var body: some WidgetConfiguration {
StaticConfiguration(
kind: "com.mygame.game-status",
provider: Provider(),
placeholder: PlaceholderView()
) { entry in
AssignmentsEntryView(entry: entry)
}
.configurationDisplayName("Game Status")
.description("Shows an overview of your game status")
.supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
}}
Post
Replies
Boosts
Views
Activity
Hello,
I am using a Double Column Layout on the iPad.
I am trying to highlight the first row on the view loading. I was able to get the first row navigation link to load using selection and tags. I cannot figure out how to get the first row to highlight on the left as if it was tapped. Guidance would be great! Thanks in advance!