Given a positive integer $n$ and a group $G$ (necessarily abelian if $n > 2$) then a based space $X$ is said to be $K(G, n)$ if $\pi_k(X)$ is trivial for $k \neq n$ and $\pi_n(X) = G$. First a pedantic question - is such a space necessarily a CW complex (as the wiki seems to suggest) or do we include that in the definition?
Secondly, for fixed $n$ and $G$, why is such a space unique up to homotopy equivalence? I know Whitehead's theorem that says that a map between two CW complexes that induces isomorphisms on all of the homotopy groups (and a bijection on $\pi_0$) is necessarily a homotopy equivalence. So if we have two (CW complex) $K(G,n)$'s say $X$ and $Y$ and we can cook up a map $f: X \to Y$ with $f_\# : \pi_n(X) \to \pi_n(Y)$ an isomorphism, then by Whitehead $X$ and $Y$ are homotopy equivalent. However, why does such a map $f$ exist?