I didn't change anything at all, and in another app in which I use the exact same code, everything works just fine. It's crazy how things work out sometimes.