The standard approach to proving that $H^n(X; G)$ is represented by $K(G, n)$ seems to be to prove that $\text{Hom}(X, K(G, n))$ defines a cohomology theory and then use EilenbergSteenrod uniqueness. This is utterly spiffing, but as far as I can see gives little geometric intuition. In his treatment, Hatcher mentions that there is a more direct cellbycell proof, albeit a somewhat messy and tedious one. I haven't been able to find any such proof, but I'd really like to see one; I think it would help me solidify my mental picture of EilenbergMacLane spaces. Does anyone have a reference?
3 Answers
I'd suggest looking up some basic material on obstruction theory. There, you generally find classification of maps $X \to Y$ with domain a CWcomplex in terms of cohomology groups $H^s(X;\pi_t(Y))$. The proofs are often very cellular indeed.
In the case where the range is an EilenbergMaclane space (for an abelian group), the dirty proof is something like:
 Any map from $X$ is homotopic to one where the (n1)skeleton $X^{(n1)}$ maps to the basepoint of $Y$.
 A map on the nskeleton $X^{(n)}$ sending the (n1)skeleton to the basepoint is determined, up to homotopy, by a choice of element of $G$ for each ncell of $X$, essentially by definition of homotopy. This is an element in the n'th CWchain group $C^n_{CW}(X;G)$.
 Such a map extends to all higher skeleta if and only if the attaching maps for all the (n+1)cells become nullhomotopic in $Y$. Thus the map extends if and only if it's represented by a cocycle, i.e. an element of $Z^n_{CW}(X;G)$.
 This is a complete invariant, up to homotopy, of maps that are trivial on the (n1)skeleton. (Higher cells have basically unique maps up to homotopy.)
 Any homotopy between two such maps can be pushed to a homotopy that's trivial on the (n2)skeleton of $X$.
 Such a homotopy is determined, up to a "track" (a homotopy between homotopies), by a choice of element of $G$ for each (n1)cell of $X$.
 Such a homotopy alters the map on the nskeleton (as an element of $C^n_{CW}(X;G)$) by adding a coboundary element, something in $B^n_{CW}(X;G)$.
 Therefore, the full mapping space mod homotopy is $H^n_{CW}(X;G)$.
This is a little messy. Often it's nice to use the filtration of $X$ by subcomplexes $X^{(n)}$ and use that each inclusion in the filtration induces a fibration of mapping spaces $$F(X^{(n)}/X^{(n1)},Y) \to F(X^{(n)},Y) \to F(X^{(n1)},Y)$$ to clean this homotopical analysis up a little into something slightly more systematic. This leads to a spectral sequence for the homotopy groups of the mapping spaces in terms of the cohomology of $X$ with coefficients in the homotopy groups of $Y$, but you have to be a little careful because there is a "fringe" that exhibits some nonabeliangrouplike behavior.
I think that a nice write up can be found in the first chapter of Mosher and Tangora (a very nice book).

3$\begingroup$ There's also a very nice, detailed "bareknuckle" account in Whitehead's big fat Algebraic Topology textbook. And although they don't address K(\pi,n)'s in Milnor and Stasheff, the main obstructiontheoretic arguments appear there and are readily adapted. $\endgroup$ Commented Nov 18, 2009 at 5:05
I don't know a reference, but here's an outline.
Step 1. Using the triviality of $\pi_k(K(G, n))$ for $k\ne n$, show that
(a) any map from $X$ to $K(G, n)$ is homotopic to one where the $(n1)$skeleton of $X$ goes to the base point of $K(G, n)$;
(b) such a map determines a function ($n$cochain) $f$ from the $n$cells of $X$ to $G$;
(c) $f$ above is necessarily a cocycle (because the map extends over $(n+1)$cells); and
(d) two such maps are homotopic if (but not only if) the functions $f$ above agree.
Step 2. Similarly, a homotopy between two maps of the above form determines a function ($(n1)$cochain) $g$ from the $(n1)$cells of $X$ to $G$.
Step 3. Observe that if a homotopy with corresponding map $g$ which connects maps corresponding to $f_1$ and $f_2$ must satisfy $\delta g + f_2  f_1 = 0$. Thus the homotopy classes of maps to $K(G, n)$ correspond bijectively with cocycles mod coboundaries.

$\begingroup$ This has nothing that is not already in Tyler Lawson's post. Is it possible to remove my own post? $\endgroup$ Commented Nov 14, 2009 at 16:09