I wonder why it gets null pointer

If you run it in Debugger, it will tell you what’s failing.