Posts

Post not yet marked as solved
6 Replies
3.7k Views
Hi,During the research, I found that it was possible for me to create a python file using the cross-platform function inside Xcode, however, I'm not sure if I am able to use both kinds of programming at the same time? Or do I have to create an app in Python, and then somehow link that into the Swift app that I have at the start? Every single question related to this topic either dates back a few years ago, or all the questions remained open, and there weren't any answers to them.If I'm unclear please tell me so I can respond, help would be greatly appreciated!Thanks
Posted Last updated
.
Post marked as solved
10 Replies
1.9k Views
I have a problem with extracting values from an array that only has one index, however, it has many values. Example belowarray = [(fruit, milk, cheese, cake)]So how can I extract those variables so that for example if I had a normal array with 4 indices (index)easyarray = [ceral, chocolate, brownie, fish]With an easy array, I can call up the values with a simple .map {$0._____}But how do I do that, or a different function (function referring to being able to extract the values cheese, milk etc).Much thanks
Posted Last updated
.
Post marked as solved
7 Replies
493 Views
I have a very confusing situation that I can't figure out. I'm not quite fluid in swift so please bear with me if this is a rookie mistake.So let's say I have a variable xlet number = Int.random(in: 0 ... 5) x = number let number2 = Int.random(in: 0 ... 5) y = number2ok, so establishing that x is a random integer from 0 to 5 if I'm not correct, which means it's 6 valuesAlso, we have this arraylet arrayValues = ["apples", "bannanas", "cherry", "date", "eggplant", "dorito"]Here we can begin with the situation, I will include some of the steps I have attempted.So I want to have x, let's say in this case the computer chooses a 3, and y is 5.Keep in mind that every time the program runs, it will provide a different number.What I want to do, is to match those x and y values with the indexes of the array "arrayValue".In this example, x = 3 and y = 5therefore if we compare the index of the array "arrayValues", with the x and y that would be"date", (the index would be 3 which is equal to x )and "dorito" (the index is 5, which is equal to y).However, here's the problem, how do I do this? Because the values are changing every time, I also can't use arrayValue.contain to find the value. due to the fact, the numbers aren't strings. As well as the fact if we convert the numbers into strings it would be pointless again, because it would be searching for "x", and not searching for the actual value of x. Is there a code to fix this?Thanks in advance.
Posted Last updated
.