This is just for clarification because I don't think it does. Every time I create a project using a game template thing, there's no option to use SwiftUI. When you create the project, it uses Storyboards and UIKit.
Post
Replies
Boosts
Views
Activity
I just want users to be able to save their settings/preferences. My problem is that using Core Data with SwiftUI (not Storyboards) seems a bit too complicated.
Hi! I've been messing around with Swift and SwiftUI for 2-4 weeks now. I decided to make a guide app or something that's a bit customizable. So, I searched for tutorials on how to save data locally. I found out Core Data is the framework for that job, and luckily, I found out it's in Apple's developer documentation website. The thing is, though, it isn't for SwiftUI. I think it's for Storyboards or UIKit.
Can I use CoreData with SwiftUI?
Does it use custom views?
Is GM seed the final beta or something?
Is it stuck on portrait mode? There's no option that lets me change the orientation.
@State private var menuItems = ["Heroes", "Items", "Tips"]
var body: some View {
ZStack {
VStack {
ForEach(0 ..< menuItems.count) {_ in
Button(action: {}) {
Text("\(menuItems[$index])")
.foregroundColor(Color.white)
}
.padding(.horizontal, 75.0)
.padding(.vertical, 25.0)
.background(Color.gray)
}
}
}
I get an "Cannot find '$index' in scope"
var sum: Double {
let peopleCount = Double(numberOfPeople + 2)
let tipSelection = Double(tipPercentages[tipPercentage])
let orderAmount = Double(checkAmount) ?? 0
return orderAmount / peopleCount * tipSelection
}
Is this a function, a variable, or both?
I'm confused. If I get an error, I just replace it with the other and it just works, but what I don't know is why it works. Both share the same value with the variable they're bonded to, so what's the difference?
I have 2 files that I want to work together or something.
The first is the main file: ContentView.swift. The second is the file where my other view is: KeysView.swift.
This is what KeysView contains:
struct KeysView: View {
var body: some View {
HStack {
Button(action: {
}) {
Text("1")
.padding()
.background(Color.black)
.clipShape(/*@START_MENU_TOKEN@*/Circle()/*@END_MENU_TOKEN@*/)
}
Button(action: {
}) {
Text("2")
.padding()
.background(Color.black)
.clipShape(/*@START_MENU_TOKEN@*/Circle()/*@END_MENU_TOKEN@*/)
}
Button(action: {
}) {
Text("3")
.padding()
.background(Color.black)
.clipShape(/*@START_MENU_TOKEN@*/Circle()/*@END_MENU_TOKEN@*/)
}
}
HStack {
Button(action: {
}) {
Text("4")
.padding()
.background(Color.black)
.clipShape(/*@START_MENU_TOKEN@*/Circle()/*@END_MENU_TOKEN@*/)
}
Button(action: {
}) {
Text("5")
.padding()
.background(Color.black)
.clipShape(/*@START_MENU_TOKEN@*/Circle()/*@END_MENU_TOKEN@*/)
}
Button(action: {
}) {
Text("6")
.padding()
.background(Color.black)
.clipShape(/*@START_MENU_TOKEN@*/Circle()/*@END_MENU_TOKEN@*/)
}
}
HStack {
Button(action: {
}) {
Text("7")
.padding()
.background(Color.black)
.clipShape(/*@START_MENU_TOKEN@*/Circle()/*@END_MENU_TOKEN@*/)
}
Button(action: {
}) {
Text("8")
.padding()
.background(Color.black)
.clipShape(/*@START_MENU_TOKEN@*/Circle()/*@END_MENU_TOKEN@*/)
}
Button(action: {
}) {
Text("9")
.padding()
.background(Color.black)
.clipShape(/*@START_MENU_TOKEN@*/Circle()/*@END_MENU_TOKEN@*/)
}
}
}
}
In ContentView, I'm trying to call the view using KeysView(), but I keep getting a Cannot find 'KeysView' in scope error.
I always get errors whenever I use the normal for loop and the repeat loop.
My code:
Text("alpha")
.font(.subheadline)
.background(RoundedRectangle(cornerRadius:
.strokeBorder(lineWidth: 1))
It works as expected, but there's no space between the border and the text.
ScrollView(.horizontal, showsIndicators: false) {
Image("sandwich0")
.resizable()
.frame(width: 100.0, height: 100.0)
Image("sandwich1")
.resizable()
.frame(width: 100.0, height: 100.0)
Image("sandwich2")
.resizable()
.frame(width: 100.0, height: 100.0)
}
Relevant code ^
My ScrollView isn't horizontal. It's vertical, but you can swipe horizontally. I can't upload an image here because I can't link to Imgur for some reason.
I get no error if my code is this
ForEach((1...10), id: \.self) {
Text("\($0)")
}
But, if I change the \($0) to something else, like "bruh" or "\($variableName), it won't work. It gives me 5 errors
"Cannot convert value of type 'ClosedRange<Int>' to expected argument type 'Range<Int>'
Cannot infer key path type from context; consider explicitly specifying a root type Insert '<#Root#>
Extra arguments at positions #2, #3 in call
Generic parameter 'Content' could not be inferred Explicitly specify the generic arguments to fix this issue
Missing argument for parameter 'context' in call Insert ', content: <#(Int) -> _#>'
I can modify the toolbar thing on projectname.storyboard, but I can't find a way to edit the window that pops up when I click "About app name"