Let $A$ be a commutative ring and $f \in A$. If $X_f=\operatorname{Spec}A \setminus V(f)$ show that $X_f = \operatorname{Spec}A$ if and only if $f$ is a unit.
Suppose that $X_f = \operatorname{Spec}A$, then taking complements $V(f) = \emptyset \iff \forall \mathfrak p \subset A : f \notin \mathfrak p$ i.e $f$ is not in the nilradical $\mathfrak N = \bigcap_{\mathfrak p \in \operatorname{Spec}A} \mathfrak p$.
How can I conclude that $f$ must be a unit? In Atiyah & MacDonald they have a Corollary
Every non-unit of $A$ is contained in a maximal ideal
but I cannot see if this can be used here. I know that every maximal ideal is prime, but the converse doesn't neccessarily hold.
I considered the arugment that if $f$ isn't in any prime, then it is not in any maximal ideal which by the corollary would imply that $f$ is a unit, but this would require the converse of "every maximal ideal is prime" to hold?