ios - Difference between instance and initialization -


i hope i'm not out of order on fisrt post here i'm triple-oh nooob wanting fundamental concepts right

i classes about, not clear on difference between instances , inits ( initialisations )

can think of way?:

a small building development site has design approved. (blueprint) that'll class, sure enough

the 'instance' 1 unit bought in factory on truck , craned in

but init when surveyor comes , pegs out space 'allocation' on site ? ( started in objective-c before swift, , have looked swift, can tell ) or else?

because swift documentation tels me 'var' or 'let' object needs value assigned, cant nil. that's strange when see lots of material things like

var x : int let str : string 

i see no values there, explicitly want see x = 5 or str ="cotton"

so tat leaves 2 possible analogies init() :

var x : int // building has bounds set out, it's not filling space? var x = 5  // building in place, still empty , not in habitation 

not asking great discussion, 'more right'? if any

quite literally, "instantiation" or "initialization" (same thing) when create instance of class. using similar metaphor, class blueprint house, initialization (init) when construction crew builds house, , instance finished house live in.

in example above, var x = 5. construction crew built x , set 5. can whatever want instance of x, change 6. first example of telling x going int class for.


Comments