Post

Replies

Boosts

Views

Activity

How to add textfield to an alert
hi, I have this alert in SwiftUI in my some view. how do I add a textfield to the alert, return the string. All the places I have tried to find an answer, they uses a func. Do I need to do that as well?             .alert(isPresented: $showAlert) {                 Alert(title: Text("Login"), message: Text("Type in your password"), primaryButton: .destructive(Text("Cancel")), secondaryButton: .default(Text("Login")))
1
0
866
Apr ’22
slots to hangman game
hello world ;) i am trying my best to learn swift and now I am trying to build a hangman game. so far I have made a word array to chose from and the buttons frem a-z and made it count the letters. but I kind a got stock trying to figure out how to generates the slots for each letter in the word. dose anyone have an idea, how I should approach this. thanks.
2
0
1.1k
Aug ’21
return raw.value enum
hey. i am trying to make a hangman game and I want to make a grid of buttons for the letters. I did that with a enum but now my problem is I can't figure out for to return the letters value, inside the button actions. so I can later use them in the game enum letters:String {     case a = "a"     case b = "b"     case c = "c" ...   }  let buttons: [[letters]] = [         [.a, .b, .c, .d, .e, .f, .g],         [.h, .i, .j, .k, .l, .m, .n],         [.o, .p, .q, .r, .s, .t, .u],         [.v, .w, .x, .y, .z] ForEach(buttons, id: .self) {row in                 HStack{                     ForEach(row, id: .self) {item in                         Button(action: {                              //what to put here to return the letter as string?                                                      }, label: {                             Text(item.rawValue)
1
0
368
Aug ’21
How to make a pop up view?
I am new to Xcode and I have made a small game in SwiftUI. I want to have a button in the corner that displays a new view with the some rules on it. I don’t want to use navigationView or Tabview because it takes up to much space from the game. how do I achieve this? thank you already :)
3
0
4.9k
Jul ’21