I am just learning objective-c but can't figure out whats wrong with my code
Code:
NSMutableDictionary *myDic = [NSDictionary dictionary];
[myDic setObject:[NSURL URLWithString:@"http://www.apple.com"] forKey:@"Apple"];
I am just learning objective-c but can't figure out whats wrong with my code
Code:
NSMutableDictionary *myDic = [NSDictionary dictionary];
[myDic setObject:[NSURL URLWithString:@"http://www.apple.com"] forKey:@"Apple"];
Although you're declaring NSMutableDictionary
you're creating immutable NSDictionary
object.
The correct declaration and initialization of myDic
would be
NSMutableDictionary *myDic = [NSMutableDictionary dictionary];