Post

Replies

Boosts

Views

Created

Use of Airdrop systematically
Hi there I have a question that I'd be very grateful for if someone could help me get an idea of how I could find an answer. Is it possible to use the Airdrop function of the iPhone systematically while coding in Xcode? So say I want to automatically share a hint for an escape room with all participants in the room. Could I program an app to automatically select all available receivers in a room and send them a preselect photo? Thanks for your help! Any suggestions on how I can solve this problem are very welcome!
2
0
1.1k
Jul ’21
Swift UI Simulator Crash on Xcode
Hi everyone, I'm building my first project on Xcode using SwiftUI. While working on a screen that lets people enter the names of players. Additionally, it should and open a popup sheet that lets them delete certain players. While doing this I encountered a strange error. The Preview seems to crash every time I try to delete an entry in the list. Does anyone have an idea how I could get the following code to work? Thanks very much, any help is highly appreciated. SwiftUI import SwiftUI struct Test_17_05_1: View {       @State var pName: [String] = [""]   @State var playerEnterCount: Int = 0   @State var showPlayerlist: Bool = false       func delete(at offsets: IndexSet) {           pName.remove(atOffsets: offsets)   }       var body: some View {          NavigationView {             VStack {       Spacer()              HStack {                 Image (systemName: "person.fill")           .foregroundColor(.secondary)         Text("What's the name of player " + String(playerEnterCount+1) + "?")         Spacer ()       }               HStack {                   Image (systemName: "person.fill.badge.plus")           .foregroundColor(.secondary)                         }             Spacer()               Button("next player") {                   playerEnterCount += 1                   pName.append("")                 }       .foregroundColor(.secondary)                           Spacer()     }           .navigationBarItems(trailing:                 Button(action: {                   showPlayerlist.toggle()                     },                     label: {                     Image(systemName: "person.3.fill")                     Text("Players")                     }).foregroundColor(.secondary)     )     .sheet(isPresented: $showPlayerlist, content: {                 List {ForEach(pName, id: \.self) {pName in           Text(pName)         }.onDelete(perform: delete)         }               })             }         }     }
4
0
1.2k
May ’21
The compiler is unable to time-check
Hi, I'm relatively new to Xcode and I've just received an error while working on my fitness dare app that I'm not sure how to interpret. It says "The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions" But as you see in the following my code shouldn't actually be too complex I think. Thanks a lot for any help. This is the code that prompts the error: struct PlayScreen: View {         @Binding var name: [String]     @State var qCount = 0     let qCountMax = 1     @Binding var pCount: Int     @State var p1 = 0     @State var p2 = 1       var body: some View {           let q1 = ["Whoever can do more situps out of " + name[p1] + " & " + name[p2] " gets two points.",       name[p1] + " & " + name [p2] +" who is quicker to touch the ceiling? Winner gets a point.",       ]              VStack(alignment: .center) {                    Spacer ()                   Text(q1[qCount])         .multilineTextAlignment(.center)         .padding(.bottom, 10.0)     Spacer()                          Button(action: {                   if qCount qCountMax {           qCount += 1         }                   else if qCount == qCountMax {           qCount = 0         }                   p1 = Int.random(in: 1 ... pCount)         p2 = Int.random(in: 0 ... pCount)                   if p2==p1 {p2 = 0}                 }, label: {         Text("next")       }).frame(width: 200.0, height: 100.0)       .foregroundColor(.secondary)               }       } }
2
0
1.4k
May ’21