Questions tagged [cfdictionary]

CFDictionary and its derived mutable type, CFMutableDictionary Reference, manage associations of key-value pairs.

FDictionary and its derived mutable type, CFMutableDictionary Reference, manage associations of key-value pairs. CFDictionary creates static dictionaries where you set the key-value pairs when first creating a dictionary and cannot modify them afterward; CFMutableDictionary creates dynamic dictionaries where you can add or delete key-value pairs at any time, and the dictionary automatically allocates memory as needed.

A key-value pair within a dictionary is called an entry. Each entry consists of one object that represents the key and a second object that is that key’s value. Within a dictionary, the keys are unique. That is, no two keys in a single dictionary are equal (as determined by the equal callback). Internally, a dictionary uses a hash table to organize its storage and to provide rapid access to a value given the corresponding key.

Keys for a CFDictionary may be of any C type, however note that if you want to convert a CFPropertyList to XML, any dictionary’s keys must be CFString objects.

Apple Documentation

17 questions
5
votes
1 answer

CFDictionary won't bridge to NSDictionary (Swift 2.0 / iOS9)

OK, this is a case I came across when working with CGImageSource and noticed that the toll-free-bridging between CFDictionary and NSDictionary seems to run into problems in certain cases. I've managed to construct the below example to show what I…
4
votes
2 answers

How to create a CFDictionary in an OS X target?

According to documentation CFDictionaryCreate is used to instantiate CFDictionary in swift. func CFDictionaryCreate(_ allocator: CFAllocator!, _ keys: UnsafeMutablePointer>, _ values:…
PovilasB
  • 1,488
  • 1
  • 15
  • 25
3
votes
1 answer

Cast Swift Dictionary to CFDictionary

What is the right way to cast Dictionary in Swift 3 to a CFDictionary? Is it legal to write like this? var dictionary:Dictionary = [:] and then dictionary as CFDictionary
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
2
votes
2 answers

CFDictionary get Value for Key in Swift3

I've a problem with accessing a specific (or any) key in a CFDictionary. Honestly I don't really get the way you need to do this in Swift and I think it's overly complicated... My Code: if let session = DASessionCreate(kCFAllocatorDefault) { let…
nja
  • 571
  • 1
  • 7
  • 15
2
votes
1 answer

CFDictionaryRef issues in Swift

I'm converting some of my older Objective-C code to Swift so I can move away from some deprecated methods but I keep getting a crash and so far I can't seem to figure out what's causing it. I'm getting a private key from a P12 Certificate and this…
Sal Aldana
  • 1,235
  • 4
  • 17
  • 39
2
votes
1 answer

Swift CGPDFContextBeginPage and CFData

I would like to create some PDF pages in Swift. This is my code to create a PDF page // Initialize context and other stuff CGPDFContextBeginPage(pdfContext, aDictionary); CGContextDrawPDFPage(pdfContext,…
Infinite Possibilities
  • 7,415
  • 13
  • 55
  • 118
1
vote
2 answers

Causes of CFDictionaryGetValue crash?

I'm having random crashes within my swift app and they are all throwing a similar error around CFDictionaryGetValue Here are two screenshots from my Google Crashlytics showing the error and that its effecting to different URLs, Note these are from…
user10460877
1
vote
3 answers

How to use CFDictionarySetValue in swift?

Currently, I am converting the hardware decoding Obj-C code to Swift version. (Xcode 8, Swift 3). I don't know how to set up a dictionary to set up an output option on the screen, also, I don't know how to use it. The following code works fine in…
1
vote
1 answer

How to create CVPixelBuffer attributes dictionary in Swift

To create a CVPixelBuffer attributes in Objective-C I would do something like so: NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], kCVPixelBufferCGImageCompatibilityKey, …
nwales
  • 3,521
  • 2
  • 25
  • 47
1
vote
1 answer

CFDictionary updates to PHPhotoLibrary kCGImagePropertyExifDictionary not Taking

I am trying to add/modify the image metadata when I add an image asset to an album in an iOS 8.4 Photos collection. The following code successfully adds the GPS dictionary but does not add or change the EXIF data (I have examined the image header…
0
votes
2 answers

Converting CFData to C-String

I wanted to get gpu name, and found the code that does this using IOKit. The only problem is that this code was in Objective-C, while my project is in C, and I don't know how to use C-string instead of NSString. const void *GPUModel =…
0
votes
0 answers

What is the difference between CFDictionaryContainsKey and CFDictionaryGetCountOfKey

CFDictionaryContainsKey CFDictionaryGetCountOfKey It seems that they both return 1 if the key is found and 0 if not. Any difference?
Darren Ng
  • 373
  • 5
  • 12
0
votes
0 answers

Command-line Objective-C++ tool has started crashing in [NSApplication sharedApplication]

I have a little CLT for copying and pasting images, written in Objective-C++. Until recently, this program compiled and ran as intended – but only just now, it seems, it has started crashing in the call to [NSApplication sharedApplication]. The…
0
votes
2 answers

Converting NSDictionary to CFDictionary in VideoToolbox

What's the difference between const void *keys[] = { kCVPixelBufferPixelFormatTypeKey }; OSStatus pixelFormatType = kCVPixelFormatType_32BGRA; CFNumberRef pixelFormatTypeRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type,…
viz
  • 1,247
  • 16
  • 27
0
votes
0 answers

Translating Apple Sample "Complex Multi-Touch Handling" Code into Swift

This website describes what I want to achieve under the 'Handling a Complex Multitouch Sequence' section. Unfortunately, it is shown in Objective-C. I can translate most of it into Swift, but when it comes to a few lines, like the lines with…
Mahclark
  • 1
  • 1
1
2