i am confused that what is difference between
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
and
NSUserDefaults *userDefault = [[NSUserDefaults alloc] init];
can any one can help me......
thnx in advance
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
the above line gives you the singleton object by using the class method standardUserDefaults the object received by this method is allocated single memory throughout the application.
NSUserDefaults *userDefault = [[NSUserDefaults alloc] init];
this will gives you the new object, each object is allocated a different memory and deallocated when object scope is finished.
If you want to store and use the value throughout the application then its better to use singleton object and that will be deallocated when you delete your application
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With