[問題] CFDictionaryRef 轉換成 CFString 問題
大家好
我現在在看別人寫的code
程式中有一部分是使用c將一些資料以CFDictionaryRef格式儲存
參考CFDictionaryRef的說明
https://developer.apple.co1m/library/mac/documentation/
corefoundation/Reference/CFDictionaryRef/Reference/reference.html
並參考別人的用法
http://pastebin.com/qAtbBraA
const void * keys;
const void * values;
CFDictionaryGetKeysAndValues(cfdref, &keys, &values);
for (int i = 0 ; i < CFDictionaryGetCount(cfdref); i++)
{
CFStringRef x = (CFStringRef)&keys[i];
CFStringRef y = (CFStringRef)&values[i];
}
在for 迴圈裡面的兩個assign都會出現下述錯誤
Subscript of pointer to incomplete type 'const void'
想請教一下 該怎麼寫才是正確的把CFDictionaryRef的key與value
轉成CFStringRef的方式呢
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 210.59.147.226
※ 文章網址: http://www.ptt.cc/bbs/MacDev/M.1396862087.A.646.html
→
04/07 18:43, , 1F
04/07 18:43, 1F
→
04/07 18:43, , 2F
04/07 18:43, 2F
→
04/07 22:16, , 3F
04/07 22:16, 3F
阿 我key來PTT時打錯^^;
→
04/08 09:46, , 4F
04/08 09:46, 4F
後來改成
CFIndex count = CFDictionaryGetCount(cfdref);
const CFStringRef* pname = new CFStringRef[count];
const CFStringRef* pvalue = new CFStringRef[count];
CFDictionaryGetKeysAndValues(cfdref, (const void**)pname, (const void**)pvalue);
for (CFIndex i = 0; i < count; i++)
{
CFStringRef x = pname[i];
CFStringRef y = pvalue[i];
}
delete[] pname;
delete[] pvalue;
才compile過...
(compiler是GCC 4.2 xcode4.02 4a2002a)
有解決了 感謝大家:)
※ 編輯: donkeychen (210.59.147.226), 04/08/2014 09:53:19
→
04/08 10:18, , 5F
04/08 10:18, 5F
→
04/08 10:19, , 6F
04/08 10:19, 6F
→
04/08 15:15, , 7F
04/08 15:15, 7F
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章