Post

Replies

Boosts

Views

Activity

Reply to 'init()' is deprecated: Use init(configuration:) instead and handle errors appropriately.
There was a problem and could not finish editing my post… Which line do you get the error ? What is the class you try to init ? I called it THEMODEL You should try this let model: THEMODEL = { do { let config = MLModelConfiguration() return try THEMODEL(configuration: config) } catch { print(error) fatalError("Couldn't create SleepCalculator") } }() See details here: http ://www.hackingwithswift. om/forums/swiftui/betterrest-init-deprecated/2593
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21
Reply to Which document do I need to read on how to make an app?
Have you looked at AppDevelopment with Swift from Apple ? Entry point is defined by @UIApplicationMain in AppDelegate It contains the code to execute once app is launched:     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { } May have a look at this thread: https://developer.apple.com/forums/thread/112690
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21
Reply to Xcode phone display
Is it XCode 12 ? When you display storyboard, you should see at the bottom a few buttons. On the left : "Devices" When you click on this button, you get a long list of devices. What is your list presently ? If it does not contain the one you want, add new simulators. At the top left of XCode window, click on the name of present device. You'll get a menu item with "add new simulators"
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21
Reply to Which document do I need to read on how to make an app?
Are you selecting SwiftUI when you create the app? Have a look here for detailed explanation about main https ://swiftrocks. com/entry-points-swift-uiapplicationmain-main For more general, search in Archive https://developer.apple.com/library/archive/navigation/ You'll find documents like this for Cocoa https://developer.apple.com/library/archive/documentation/General/Conceptual/MOSXAppProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40010543 As stated, those types of docs are no more updated… You may ask Apple support for further references.
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21
Reply to How to turn a String to a Binding<String>
Here is an example of several ways to pass parameters: import SwiftUI struct DestView: View { &#9;&#9;var body: some View { &#9;&#9;&#9;&#9;Text("Hello, Destination!") &#9;&#9;} } struct DestViewState: View { &#9;&#9;@State var theState: Int = 0 &#9;&#9;@State var theStateStr: String = "hello" &#9;&#9;var body: some View { &#9;&#9;&#9;&#9;Text("Hello, Destination! \(theState) \(theStateStr)") &#9;&#9;} } struct DestViewStateBinding: View { &#9;&#9;@Binding var theStateBinding: Int &#9;&#9;@Binding var theStateStrBinding: String &#9;&#9;var body: some View { &#9;&#9;&#9;&#9;if theStateBinding < 50 { theStateBinding += 10 } &#9;&#9;&#9;&#9;return Text("Hello, Destination! \(theStateBinding) \(theStateStrBinding)") &#9;&#9;} } struct ContentView: View { &#9;&#9;var contentNoState : Int = 1 &#9;&#9;@State var contentState : Int = 1 &#9;&#9;@State var contentStateStr: String = "hello you" &#9;&#9;var body: some View { &#9;&#9;&#9;&#9;NavigationView { &#9;&#9;&#9;&#9;&#9;&#9;VStack { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text("Hello, World!") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Spacer() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;NavigationLink(destination: DestView()) { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text("Press on me") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;}.buttonStyle(PlainButtonStyle()) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Spacer() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;NavigationLink(destination: DestViewState(theState: contentNoState, theStateStr: "Modified hello")) {@// You can skip parameters as they are initialized in the struct &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text("Press on me with State") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;}.buttonStyle(PlainButtonStyle()) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Spacer() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;NavigationLink(destination: DestViewStateBinding(theStateBinding: $contentState, theStateStrBinding: $contentStateStr)) { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text("Press on me with Binding") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;}.buttonStyle(PlainButtonStyle()) &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;} &#9;&#9;} } struct ContentView_Previews: PreviewProvider { &#9;&#9;static var previews: some View { &#9;&#9;&#9;&#9;ContentView() &#9;&#9;} }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’21
Reply to Firebase | Retrieving Data Error
What were you expecting ? You get the first userId. Is it what you request with observeSingleEvent ? probably you have to change to observe. If that works, don't forget to close the thread on this answer. May read this: https://stackoverflow.com/questions/46515454/swift-firebase-convert-observesingleevent-to-observe-childadded?rq=1 Note: that's more a Firebase question than a Swift. So you should look in detail at Firebase API doc and possibly ask to Firebase forums directly.
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21
Reply to Fragment Function(visualizeScalar): missing buffer binding at index 0 for bufferData[0] after modifying buffer
First question to get more context. You say tou receive error message: Fragment Function(visualizeScalar): missing buffer binding at index 0 for bufferData[0] after modifying buffer Is it swift code (as the tag seems to tell) ? If so, is Function a func or yours (should be as it unusually starts with Uppercase) ? Where is the Fragment keyword coming from ? Is it MetalKit or a 3rd party library ? So, please provide more information (it was not either in your SO post that you replicated here)
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21
Reply to Xcode phone display
I don't understand your question: But in the storyboard I can't see any 5.6 inch display device. - which device should be 5.6"" ? I don't know any. https ://www.knowyourmobile. com/user-guides/iphone-size-comparison-chart/ Do you mean you look for 5.8" (not 5.6) ? Did you try adding simulator (maybe you have to download first): you can install iPhone X, XS, all with 5.8". Why do you need to display by screen physical size ? Only the resolution may matter, as far as Xcode is concerned.
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’21