I want to prove the following:
$[X, \mathbb{R} P^\infty] \cong H^1(X; \mathbb{Z}/2)$ via the map $[f] \mapsto f^* w_1(\gamma^1)$ where $\gamma^1$ denotes the tautological line bundle over $\mathbb{R} P^\infty$.
This is my attempt so far:
We have that $\pi_1(\mathbb{R} P^\infty) = \mathbb{Z}/2$, and that the universal cover of $\mathbb{R} P^\infty$ is $S^\infty$, which is contractible. Now consider a map $f : X \to \mathbb{R} P^\infty$ and the induced map $$ \overline{f} : H_1(X) = \pi_1(X)/[\pi_1(X), \pi_1(X)] \to \pi_1(\mathbb{R} P^\infty). $$ We see that $\overline{f} \in Hom (H_1(X), \mathbb{Z}/2) \cong H^1(X, \mathbb{Z}/2)$. Note that $\overline{f} = 0$ exactly when $f$ lifts to $S^\infty$. But $f$ lifts to $S^\infty$ if and only if the induced map $f : \pi_1(X) \to \pi_1(\mathbb{R} P^\infty) = \mathbb{Z}/2$ is the contractible map. Therefore the map $[X, \mathbb{R} P^\infty] \to H^1(X; \mathbb{Z}/2)$ is injective.
Is this correct? And how do I go about proving surjectivity?
After poking around for a little bit I realize that this is a special case of a very general theorem about classifying spaces and Eilenberg–MacLane spaces, but that's beyond what I've learned about on the topic so I'm hoping for a more basic proof.