"This is a clear choice that the American people have. I had the courage and the judgment to say I would rather lose a political campaign than lose a war. It seems to me that Obama would rather lose a war in order to win a political campaign."
McCain's comments are unacceptable, as they demonize Obama and his position on the Iraq War.
McCain and Obama have significant differences regarding the conflict in Iraq, but it is illegitimate for McCain to caricature those differences as being between people who want to win in Iraq (that is, on McCain's side) and people who don't want to win in Iraq, or who would rather lose there in order to win an election in the U.S. (that is, on Obama's side).
Obama and his fellow critics are skeptical of whether victory can be achieved in Iraq, and whether any victory there will be worth the cost to the U.S. Perhaps Obama and his allies are wrong in those assessments -- McCain certainly believes so, and it is fair for him to say so and argue his case -- but this is different from saying that Obama has no desire whatsoever to win in Iraq, or that he has prioritized his own political success over the nation's success in Iraq.
McCain should retract his statement and apologize for it. It is fair game for McCain to say Obama is wrong to think victory in Iraq is out of reach or not worth the cost. But it is wrong for him to accuse his opponents of not caring about victory there at all.