Why do artichokes have pointy needles in the leaves of their exterior?

Natural selection was probably the culprit, but what event/animal caused it to evolve into a plant with splkes for defense, I do not know.