IPhone/ iPad iOS and Mac OS are two different birds. I'm not aware of any problems with iOS unless it's been jail breaked as mentioned above, all Apps are vetted through Apple and the Apple Store. As far as Mac OS, there have been a very very few cases I remember. The first one was WDEF that I think was all the way back in the 80's on my original 1984 Mac. I don't remember how I got it nor how I even identified it, and it wasn't destructive but just irritating it was there. I think this was a proof of concept.
I do wish Apple would quit daring/ challenging the code writers by bragging about no virus's. Thats just a challenge to write one.
(Edit: spelling)