deimus
deimus

Reputation: 9875

CFDictionaryCreate analogue of [NSDictionary dictionaryWithObject ... ]

I'm looking the way to create following dictionary

    NSDictionary *frameProperties = [NSDictionary dictionaryWithObject:[NSDictionary 
                                                  dictionaryWithObject:[NSNumber numberWithInt:2] 
                                                                forKey:(NSString *) kCGImagePropertyGIFDelayTime]
                                     forKey:(NSString *) kCGImagePropertyGIFDictionary];

By means of CoreFoundation i.e. with CFDictionaryCreate

Any Ideas how to implement this ?

Upvotes: 1

Views: 1827

Answers (1)

deimus
deimus

Reputation: 9875

seems I've constructed the answer on my own, please confirm someone. The code compiles OK, but I'm not able to test it yet.

    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);

Upvotes: 3

Related Questions