PDA

View Full Version : Error in Apple example documentation?




thomasjt
Jul 7, 2009, 07:28 PM
Hi,

I was having some problems with initialising an NSMutableDictionary so I turned to the documentation. There, I found this example:

NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2", nil];

which I then tried to compile. I got the following error - the same one as the error I was getting for my code:

error: initalizor element is not constant

Any ideas what's going on?

Cheers,

Tom



dejo
Jul 7, 2009, 07:36 PM
Where are you calling this code? If it's outside of a method in your @implementation block, you'll get this error.

thomasjt
Jul 7, 2009, 08:53 PM
Oh wow I suck, it was outside of a method. Thanks so much for your help.

Tom