Relations between cohomology and homotopy for CW complexes Given an n-dimensional CW-complex X, how can I show that $H^n(X;\mathbb{Z}) \cong [X,S^n]$? 
 A: What is true for any CW complex $X$ is that $H^n(X;\mathbb{Z})\cong [X,K(\mathbb{Z},n)]$, where $K(\mathbb{Z},n)$ is the Eilenberg-MacLane space for $\mathbb{Z}$ in degree $n$. The reason your statement holds for $n$-dimensional CW complexes is because we can construct a model of $K(\mathbb{Z}, n)$ so that $S^n$ is the $(n+1)$-skeleton, since $\pi_i(S^n)$ has the correct value for $i\leq n$ so we only need to eliminate $\pi_i(S^n)$ for $i\geq n+1$ with cells of dimension $\geq n+2$.
Now the claim is that the inclusion $\iota\colon S^n = K(\mathbb{Z}, n)^{(n+1)} \to K(\mathbb{Z},n)$ induces a bijection $\iota_*\colon [X,S^n] \to [X,K(\mathbb{Z}, n)]$ for any $n$-dimensional complex $X$. This is because of the much more general fact that if $X$ is $n$-dimensional then $\iota_*\colon[X,Y^{(n+1)}]\cong[X,Y]$ for any other CW complex $Y$. Surjectivity is equivalent to factoring any map $f\colon X\to Y$ up to homotopy through some $\tilde{f}\colon X \to Y^{(n+1)}$, which we can do by CW approximation. To see injectivity, consider two (cellular) maps $f, g\colon X \to Y^{(n+1)}$, and suppose they are homotopic as maps $X \to Y$ via some
$$ H\colon X\times I \to Y$$ 
Then since $X\times I$ is $(n+1)$-dimensional and $H$ is already cellular on the subcomplex $X\times \{0,1\}$, relative CW approximation applies to give a homotopy 
$$ H'\colon X\times I \to Y^{(n+1)}$$
which agrees with $H$ on $X\times \{0,1\}$, i.e. $H'$ is a homotopy between $f$ and $g$ through $Y^{(n+1)}$, therefore $\iota_*$ is injective.
