How to retrieve the values for the particular key

2019-03-06 06:47发布

In C++ EventType.find(1)->second can be used to find the value for the key 1.

I am new to Objective C.I have implemented CFDictionary to addvalue onto it.But how do i

retreive and view the values of the particular key.

EDITED:

CFNumberRef tId = CFNumberCreate(NULL,kCFNumberShortType,&st);
CFDictionarySetValue(cfdict,tId,st);
NSLog(@"The value is:%s",(CFDictionaryGetValue(cfdict,tId)));

Its running without error but i could not get the output.

2条回答
Anthone
2楼-- · 2019-03-06 06:55

The documentation for CFMutableDictionary says:

The basic interface for managing dictionaries is provided by CFDictionary Reference.

... which leads you to CFDictionaryGetValue().

查看更多
混吃等死
3楼-- · 2019-03-06 07:14

Please do not edit your posts to ask another unrelated question.

Anyway: You are using the wrong format specifier: %s is used to print C strings. You can use Objective-C's %@ format specifier to print the object's description.

If you want to use pure Core Foundation you can use CFShow(object);

查看更多
登录 后发表回答