Skip to content
This repository was archived by the owner on Apr 9, 2025. It is now read-only.
This repository was archived by the owner on Apr 9, 2025. It is now read-only.

Observable object with iPages #17

Description

@skegget

So, first of all, I'm a total SwiftUI beginner so bare with me.

I'm working on my first app in which I would like a page view controller that allows me to swipe between views. In my app I'm fetching calendar events which I'm accessing in my views through an observable object. The problem is that when I'm trying to access my observed object in iPages, the array is empty and I can't understand why. Here is a simplified example:

class EventsRepository: ObservableObject {
    static let shared = EventsRepository()
    // Code
    @Published var events: [EKEvent]?
    // Code
    let events = self.eventStore.events(matching: predicate)
}
import iPages
struct ContentView: View {
@ObservedObject var eventsRepository = EventsRepository.shared
@State private var currentPage = 0
    var body: some View {
    
        Text(String(describing: eventsRepository.events)) // This is **not** empty
        
        iPages(selection: $currentPage) {
            Text(String(describing: eventsRepository.events)) // This **is** nil
        }
    }
}

If this is not a problem with iPages I would really appreciate if you could try to explain to me what I'm doing wrong.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions