Comments (3)
Maybe you forgot to add the .environmentObject
modifier to your content view?
Like this:
from multipeerkit.
Hey, thanks for your response!
I got exactly the same files as in Example project with this line. Problem appears in newer version of Xcode which has no AppDelegate.swift and uses this root file to create view:
import SwiftUI
@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
from multipeerkit.
You need to provide the environment object to the content view, regardless of whether the project uses the app delegate infrastructure or the SwiftUI one.
You could probably do something like this in your TestApp
struct:
import SwiftUI
import MultipeerKit
@main
struct TestApp: App {
// The transceiver here could be stored somewhere else, such as in a static property in
// the MultipeerTransceiver type itself that you declare in an extension.
@StateObject var dataSource = MultipeerDataSource(transceiver: transceiver)
var body: some Scene {
WindowGroup {
ContentView().environmentObject(dataSource)
}
}
}
You can find more information in this article: https://www.hackingwithswift.com/quick-start/swiftui/how-to-use-environmentobject-to-share-data-between-views
I'll close this issue since it's not related to the library itself. If you have more general questions about usage, you can post them on Github Discussions.
from multipeerkit.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multipeerkit.