Post

Replies

Boosts

Views

Activity

Reply to Fatal error: Index out of range. In for loop using an array.
With this line: var randomSeq: [Int] = [] You initialize randomSeq with a zero-length Array. So, any index including 0 would cause Index out of range. In Swift, accessing an Array with subscript does not automatically extend the Array, and may cause Index out of range. I guess, you may need to write something like this: import Foundation let maxLevel: Int = 99 var randomSeq: [Int] = [] struct NumGen { static func generate() { //randomSeq.removeAll() for i in 1...maxLevel { randomSeq.append(Int.random(in: 1...4)) print(i) } } }
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Why is this crashing?
Would you like me to give you my project so you can run it? Thank you for your proposal, but as far as I see the code you have already shown, the whole project would not clarify what I want to know. The if I am talking about is on line 15 and it is supposed to prompt to get purchased if not purchased already If you say the if on line 15 is not working as you expect, why are you setting setIconPurchased to true before it is ready?
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Why is this crashing?
However, the part with the if runs before it can be purchased Please clarify: Where is the part with the if? When is the time it can be purchased? In my opinion, your code is too complex than it should be so just showing the code does not explain enough.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Configuring MIDiSysexSendRequest (Data types)
MIDICompletionProc is a typealias of a closure type, as shown in the doc - https://developer.apple.com/documentation/coremidi/midicompletionproc. typealias MIDICompletionProc = (UnsafeMutablePointerMIDISysexSendRequest) - Void You may need to pass a global function or a closure of @convention(c). completionRefCon is any type of pointer which points to some stable address while MIDI process is running. Or it can be nil. So, for example, you can write something like this: // Define a global function, somewhere outside any classes func handleMIDISysexSendRequestCompletion(_ request: UnsafeMutablePointerMIDISysexSendRequest) { //... } class SomeClass { //... func someFunc(...) { //... var request = MIDISysexSendRequest( destination: endPoint, data: dataPointer, bytesToSend: dataSize, complete: isComplete, reserved: (0,0,0), completionProc: handleMIDISysexSendRequestCompletion, completionRefCon: nil ) let result = MIDISendSysex(&request) print(result) //... } }
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to iPhone IDE
maybe someone can think about developing one. Unfortunately, there are many agreements or contracts between Apple and us developers. So, most developers believe that third party developers cannot develop a fully functional IDE on iPhone or iPad. You can write a feature request to Apple using the Feedback Assistant - https://developer.apple.com/bug-reporting/. You may already know and may not think it as a fully functional development tool, but Swift Playgrounds is a good tool to learn programming in Swift.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Page Switching
Writing an initialization code of Views in Button actions does not make sense. Write a code to show other views using NavigationLink or sheet or something else, and change the @State variable for it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Required content for platform tvOS simulator is missing. Please reinstall Xcode.
My internet connection is slow. I don't want to download 11 GB Xcode. Could someone help me? Better find a good place where you can use broadband internet. The recent Xcode works with tight communications with Apple's servers. You will meet many other messages and cannot run or distribute your app unless you do things in the right way. Generally, installing Xcode through More Download pages - https://developer.apple.com/download/more/ may work in a little less stable communications environment, but you need to download 11GB Xcode and many more hidden components.
May ’21