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 trial

iOS Build a Vending Machine App in Swift Using the Vending Machine Displaying Icons with UIImage

Ahmed Jaboub
Ahmed Jaboub
2,272 Points

When I try to return default it disappears and it doesn't show up unless I press command(it returns a blue ? icon).

Similar to Jesse Gray's question...

1 Answer

From the Xcode 10 release notes:

Code Completion for Swift image literals has been removed in Xcode 10

So the return default method described in the video tutorial no longer works in Xcode 10 and up.

I am using Xcode 11 and this worked:

return #imageLiteral (resourceName: "default")

Typing the above turns the #imageLiteral (resourceName: "default") part into a UIImage instance that is unwrapped, and appears as tiny, in-line tiny image (as in the video tutorial.)

This also worked:

return UIImage(imageLiteralResourceName: "default")

This, however does not show an tiny, in-line image; but rather, it stays as a line of code.