I'm sure I miss something obvious.
Using Parse Server I want to fill some data from a request into a dictionary.
query.findObjectsInBackgroundWithBlock { (books, error) in
guard (books != nil) else {
print(error)
return
}
for book in books! {
print("\n\n\(book)") //#1 Got some book
if let coverString = book["cover"] {
print("coverString OK : \(coverString)") //#2 got a valid String
self.bookImages.append(coverString as? String)
} else {
print("coverString nil")
self.bookImages.append(nil)
}
}
}
If I : print("Tableau image: \(bookImages)\n")
I got nothing in my var bookImages = [String?]()
even if I got something inside coverString
#2.
but if I .append("foobar") anywhere else (to try) except in the closure my dictionary is not empty.
Why this strange magic ?