tags:

views:

24

answers:

1

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"];
+3  A: 

Although you're declaring NSMutableDictionary you're creating immutable NSDictionary object.

The correct declaration and initialization of myDic would be

NSMutableDictionary *myDic = [NSMutableDictionary dictionary];
Eimantas