TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Hangman game

Forums > Swift

I have looked at different ways to work with character, but I am stuck on this question, can you please guide me? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .............................................

The challenge is this: make a hangman game using UIKit. As a reminder, this means choosing a random word from a list of possibilities, but presenting it to the user as a series of underscores. So, if your word was “RHYTHM” the user would see “??????”.

The user can then guess letters one at a time: if they guess a letter that it’s in the word, e.g. H, it gets revealed to make “?H??H?”; if they guess an incorrect letter, they inch closer to death. If they seven incorrect answers they lose, but if they manage to spell the full word before that they win.


This is a difficult question to answer without knowing how you are attempting to approach the problem, as it could be done in a number of different ways.

In my project, I decided to make a sort of custom keyboard for the user to select letters with. It's basically just an array of buttons displayed on the screen, one for each letter of the alphabet. This is not a requirement for the project, so the way that I did it may be different from the way that you are attempting to do it.

To start, maybe you should think about (or tell us) how you would like the user to be able to select letters. From there, you can start to form ideas of how the selected letters can be stored, and used to replace the _ or ? in the hidden word.


I used string character.

There are shortcomings in working with index value. Where can I find a complete tutorial for working with index value?

I searched the internet but couldn't find the whole topic


Hacking with Swift is sponsored by Superwall.

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.