LOKMAN CEYLAN
07010916
IOS FINAL EXAM SOLLUTIONS
GENERAL QUESTIONS
1)Mutable means the values can change,immutable means that once the values have been
set,that it.Quite a few objects in Objective-c have mutable and immutable forms:
NSarray->NSMutableArray
NSString->NSMutableString
NSDictionary->NSMutableDictionary
In conlusion ,if we do not want to change our types ,for example array we use NSarray but
if we want to change or modify our type we use NSMutableArray and mutable types
increas performence and we get best efficency.
2)In order to help you destroy objects when they are no longer needed, Cocoa associates a
counter with each object,which represents what is called the a retain count of the object. In
your program, when you store a reference to an object, you have to let the object know
about that by increasing its retain count by one. When you remove a reference to an object,
you let the object know about that by decreasing its retain count by one. When the retain
count of an object becomes equal to zero, the object knows that it is no longer referenced
anywhere and that it can be destroyed safely. The object then destroys itself, freeing the
associated memory.
For instance, suppose your application is a digital jukebox and you have objects
representing songs and playlists. Suppose that a given song object is referenced by three
playlists objects. If it is not referenced elsewhere, your song object will have a retain count
of three.
Now we Show the retaion on source code :