我正在寻找创建以下字典的方法
NSDictionary *frameProperties = [NSDictionary dictionaryWithObject:[NSDictionary
dictionaryWithObject:[NSNumber numberWithInt:2]
forKey:(NSString *) kCGImagePropertyGIFDelayTime]
forKey:(NSString *) kCGImagePropertyGIFDictionary];
通过核心基金会,即CFDictionaryCreate
任何想法如何实现这一点?
似乎我已经自己构建了答案,请确认某人。代码编译正常,但我还无法测试它。
int delayOnEachFrame = 2;
const void *tkeys[1] = { kCGImagePropertyGIFDelayTime };
const void *tvalues[1] = { CFNumberCreate(0, kCFNumberSInt32Type, &delayOnEachFrame) };
CFDictionaryRef tframeProperties = CFDictionaryCreate(NULL, tkeys, tvalues, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
const void *keys[1] = { kCGImagePropertyGIFDictionary };
const void *values[1] = { tframeProperties };
CFDictionaryRef frameProperties = CFDictionaryCreate(NULL, keys, values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);