Creating an NSDictionary

后端 未结 3 942
灰色年华
灰色年华 2021-01-01 09:18

In the following code, the first log statement shows a decimal as expected, but the second logs NULL. What am I doing wrong?

NSDictionary *entry = [[NSDictio         


        
3条回答
  •  自闭症患者
    2021-01-01 09:52

    You are exchanging the order in which you insert objects and key: you need to insert first the object, then the key as shown in the following example.

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

提交回复
热议问题