I would like to know the process to create a set of letters, assign point values to them (use the game "Scrabble" as reference), and be able to access them via an index number, so I can shuffle and manipulate the order of tiles.... all in Objective-C.
I'm using XCode4, and I'm trying to program a simple word game loosely based on Scrabble.
I was able to do this in C by creating a structure to hold the different variables of a letter block.
struct singleTile {
char letter;
int value;
};
Another structure that held an array, storing the data for each letter.
struct singleTile set[] =
{
{"A", 1},
{"B", 4},
{"C", 4},
{"D", 2}, ...etc.
}
I'm able to display the information about each letter via an index number.
printf("The second letter is %s and is worth %d points\n", set[2].letter, set[2].value);
How do I translate this into Objective-C? I've read some tutorials about NSArrays and NSMutableArrays, but I haven't found examples of these arrays that hold more than one piece of information, like mine above (specifically a letter and a value).
Please don't type everything out, unless you feel inclined to do so. If you explain the process and/or logic to me and point me in the right direction, I should be able to figure out how to program it.
In the future, I'd like to have each tile hold more information beyond a letter and a value, so this basic lesson that I can't hurdle is important to me.
I appreciate your time and generosity.
Thank you in advance. -Jeff