I would like to use a method (writeToFile) only available for NSDictionary to a NSMutableDictionary object. So, how do I convert this NSMutableDictionary object to NSDictionary?
NSMutableDictionary inherits from NSDictionary. So, writeToFile should be available to both classes.
For those coming here genuinely looking for conversion from NSMutableDictionary to NSDictionary :
NSMutableDictionary *mutableDict = [[[NSDictionary alloc] initWithObjectsAndKeys:
@"value", @"key"] mutableCopy];
NSDictionary *dict = [NSDictionary dictionaryWithDictionary:mutableDict]; //there you have it
NSMutableDictionary is a subclass of NSDictionary, so the writeToFile method should be available for your object without having to do any casting or conversions.
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