Understanding compiler error - Dictionary - "unwrapped"

I'm trying to declare a dictionary:
var alphanum2Index: Dictionary<Character, Int> = [" ": 0,
"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6, "G": 7]
for i in longText
oneChar = i
newCode = alphanum2Index[i]
print ("i, newCode: ", i, newCode)

longText is a ~300 characters of text, but I get the following error message:
/Users/wayned1/devel/KeyGen2/Testing/testing2/testing2/AppDelegate.swift:95:37 Value of optional type 'Int?' must be unwrapped to a value of type 'Int'

I'd like to use meaningful names instead of data types in the declaration, maybe inChar & index, but right now I'm at a loss. What does "unwrapped" mean in this context?

Also I'm trying to use "fseek"(?) to move around in a file, but for the time being that's on the back burner while I continue with the algorithm development.

I'm also not sure which category this fits in.

“Unwrapping” in this context means getting from Int? (aka Optional<Int>) to Int.

Dictionary subscript returns Optional.some() when key is present in the dictionary, and Optional.none when not. And you need to handle the latter case somehow.

There many ways of doing that. Here are few of the most common ones:

1. Use if let, guard let or switch to handle cases of .some() and .none:

// alpha2index[i] has type Optional<Int>
// code has type Int
if let code = alpha2index[i] {
    newCode = alphanum2Index[i]
    print("i, newCode: ", i, newCode)
} else {
    // Handle character being not in the dictionary 

2. Use null coalescing operator to provide a default value:

newCode = alpha2index[i] ?? -1

This one should be used only when there is actually a good default value. When there is no good default value, it’s better to keep using Optional type. Which leads to the next option:

3. Make newCode of optional type:

var newCode: Int?

Values of optional type can be printed. They look ugly when printed, so you will get a warning, but they can be printed.

4. Use force cast if know something that compiler doesn’t, that allow you to be confident that value is never .none. If there is already some code that prevents longText from having any other characters, you can use this:

newCode = alpha2index[i]!

But if you are wrong, and value happens to be .none - it will crash your program.

5. Use methods like Optional.map() and Optional.flatMap() to unwrap value, if present, and then wrap it back into optional:

alpha2index[i].map { $0 + 1 }

Hmmm, I understand (well, I sort of understand). This is going to take more experimentation & fiddling!

This clown speaks for himself