I don't know if the question was asked previously and Im searching for some good answer.
Question is : Whenever sometimes I don't use [[... alloc] init]
for some mutable class , I get crash.
Example :
NSMutableDictionary *myDict = someObject ; //[allocation of some other dictionary object directly without using alloc , init].
For some stages compiler warns me at runtime that you can not change values within myDict
even though it is mutable.
Instead of that if I write code :
NSMutableDictionary *myDict = [[NSMutableDictionary alloc] initWithDictionary:someObject];
then it works.
So why alloc
, init
is necessary ? Or What is the problem actually ?
Thanks.