Swi Interview Questions
When you can't initialise a property that is not nil (absence of value) by
definition at the moment of instantiation. An Interface Builder outlet, for
example, is always initialised a er its owner. In this case, you have ensured that
the outlet is non-nil before using it, provided it's properly configured in Interface
Builder.
To tackle the problem of a strong reference cycle, which occurs when two
instances refer to each other and one of them requires a non-nil reference to the
other. In this situation, one side of the reference is marked as unowned, while
the other employs an implicitly unwrapped optional.
30. In Swi , how would you describe a circular reference? What
are your options for resolving it?
When two instances have a strong connection to one other, a circular reference
occurs, resulting in a memory leak because neither of the two instances will ever be
deallocated. The reason for this is that you can't deallocate an instance if it has a
strong reference to it, yet each instance maintains the other alive due to the strong
reference. This might lead to a deadlock which is extremely bad for the application.
Breaking the strong circular reference by replacing one of the strong references with
a weak or unowned reference would fix the problem of a circular reference.
Do'stlaringiz bilan baham: