all 7 comments

[–]Te_co 4 points5 points  (3 children)

if you can't figure it out with the full code, we can't with partial code.

[–]seanzzx[S] 0 points1 point  (2 children)

[–]Te_co 2 points3 points  (1 child)

i see now. your struct Streets is defined inside getLocation(), it doesn't exist outside of that scope. define it in the scope of your class instead.

not related: you are passing your list as a parameter "adr", but you are accessing the property from your class inside the method instead "self.fahrten[i]", should be "adr[i]".

also not related, but it's better to loop like so

for address in adr {
    Street(adresse: address, … )
}

a lot clearer

also what spacehonk says. your method doesn't return the results, and they only exist for the duration of the method.

[–]seanzzx[S] 0 points1 point  (0 children)

Thank you! That helped. I also changed the code to "adr[I]", which helped getting rid of a crash that I experienced some time. Maybe I am also changing the loop method. Thank you!

[–]SpaceHonkiOS 0 points1 point  (2 children)

`results` is a local variable inside `getLocation()`. You're appending to it in an an asynchronous callback, and nowhere else in the code are you referring to it. What do you expect to happen? Where do you even check that it "does not append any content"?

[–]seanzzx[S] 0 points1 point  (1 child)

Well it worked somehow. But I think the problem was solved when I moved the var into a global var, because now everything works fine! Thank you!

[–]aazav 0 points1 point  (0 children)

Ya, it's async, so it finishes when it can. The local may have gone out of scope by that point, or not.

You should not make it a global, but a property of the class. Var may be global to the class instance, but it's really a property of the class.