explanation for nonatomic was it means to not be worried about multiple threads trying to access the object at the same time, and objective-c does not have to synthesize thread safe code. So what does that exactly mean as well.
Imagine you are asked to write your name on a piece of paper. You're given a list of instructions someone thought would work just fine:
- you find a line that's current empty,
- move your pen over it,
- write your name.
All good.
Now imagine you're given a new piece of paper, but both you and someone else are asked to write your names on the same piece of paper, and you're given the old instructions, perhaps:
1) You both look at the paper and determine to write on the first line.
2) You put your pens down (maybe you can both do it comfortably enough - one left / one right handed).
3) You start to write an I but the other person is writing a J and it comes out looking like a U.
4) gets worse from here....
But equally, it might be that you're paying more attention, and finish writing your name before they start looking for an empty line, or vice versa.
Threading is a lot like this... in the above example, each thread/person is keeping track of how they're progressing at the task, following their instructions very literally. Notice that if you complete only step 1, then the other person does step 1, you've already set yourselves up to write over each others' name regardless of the ordering or concurrency of the remaining steps.
In all this, you don't even have to be doing things at the same instant in time, it's just that the tracking of your tasks is independent - you're independent people with your own memory of where you are in your task. Same with threads - they're ways of tracking what to do independently, and it's optional whether they actually do things in your program at the same instant (which is possible with multi-core CPUs and multi-CPU systems).
"atomic" is used in the sense of indivisible (think: you can't cut an atom of gold in half and still have gold). Similarly, if you say write your name atomically, it means any observer is guaranteed to either witness the instant before - when no name is there - or the instant after - when your name is completely written - but they'll never see just half your name. An atomic update on a string variable is like that.
Atomic string updates don't solve the problem above... you might still clash in finding "an empty line" (in a computing context - say finding the next empty position in a container). If that process of finding an empty line is atomic, and the line is somehow marked "used" even before you've written anything on it yourself, then it means you'll never get the same line as someone else. At that stage, multiple people writing their names won't clash on the same line, but only when both the line finding and the name writing are atomic can people looking at the paper know that they're seeing completely written non-clashing names.
Making these kind of guarantees is very useful but expensive. It means that threads must communicate and coordinate amongst themselves, agreeing "who" will go first with others waiting as necessary.