initPrivate


#1

On page 166, why did we go through all this code writing when we could of just overrided the init? Instead we created three different methods
1.+ (instancetype)sharedStore
2.-(instancetype)init
3.-(instancetype)initPrivate

Also why is the first one a global method? I guess we did all this is so we can only allow the programmer to use only the global method?

Thanks (Btw, this question was already posted and I’m just posting it again cause I had the same exact question).


#2

(see the answer to the original posting)


#3

I read the answer to the original posting but it wasn’t clearly answer my question.

When I was reading this section, I can understand that

  1. we need to have singleton object for data source
  2. we need initPrivate method to separate the logic

What puzzled me is why we need three method to do these operation?
Rather than raising the exception from init method,
can we implement init method to do exactly what sharedSource do in the book and eliminate the sharedSource class method?
Basically, just to have init and initPrivate method…

init is still exposed to out side and we are still returning single object for data source and we still get nice separation of logic?
Am I missing something very obvious here?