Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGabriel Lopez
354 PointsEXC_BAD_ACCESS error when coding an array
When trying to code an array such as var todo: [String] = "Finish collections course" , "Buy groceries"]
I run into this error message:
Playground execution failed:
error: Execution was interrupted, reason : EXC_BAD_ACCESS ( code =1, address = 0x0). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.
I am running Xcode 11.1 and I have tried restarting Xcode, trying it in a new page, and creating a new file.
2 Answers
Michael Hulet
47,913 PointsPlaygrounds can be weird with it's error messages sometimes, but I'm surprised this compiled (unless this is just Playgrounds crashing instead of your code). You're missing an opening square bracket ([
) at the beginning of your array definition, so that code won't compile. Swift will also understand that you're creating an array of String
s from the value you give the variable, so you also don't strictly need to explicitly declare the variable's type, though it will still work if you do
Gabriel Lopez
354 PointsI made a mistake in copying down my code, I originally had the opening square bracket ([). It gives me that error when trying to make any list or dictionary like the example below.
["LGA": "La Guardia"]