core-foundation

Core Foundation equivalents for NSURLRequest and NSURLConnection

I'm aware that NSUrl is bridged to CFUrl. What are the Core Foundation equivalents for NSURLRequest and NSURLConnection so I can do something with a CFUrl object using pure C? ...

How to resolve CGDirectDisplayID changing issues on newer multi-GPU Apple laptops in Core Foundation/IO Kit?

In Mac OS X, every display gets a unique CGDirectDisplayID number assigned to it. You can use CGGetActiveDisplayList() or [NSScreen screens] to access them, among others. Per Apple's docs: A display ID can persist across processes and system reboot, and typically remains constant as long as certain display parameters do not ...

EXC_BAD_ACCESS when trying to release an ABRecordRef

I've got the following class that is a wrapper around an ABPerson (ABRecordRef): @interface Recipient : NSObject { ABRecordRef person; } - (id)initWithPerson:(ABRecordRef)person; @end @implementation - (id)initWithPerson:(ABRecordRef)_person { if(self = [super init]) person = CFRetain(_person); return self; } - (void)dealloc { ...

CoreFoundation Lite on Linux and Android

I would like to use Apple's CoreFoundation library on linux and android. The source code is available here, but there is very little documentation on how to build it on Linux. As far as I could figure out, building is done through a script called BuildCFLite. I grepped for DEPLOYMENT_TARGET ./CFUtilities.c:#if DEPLOYMENT_TARGET_MACOSX ...

CGEventTapCreate breaks down mysteriously with "key down" events

I'm using CGEventTapCreate to "steal" media keys from iTunes when my app is running. The code inside of the callback that I pass to CGEventTapCreate examines the event, and if it finds that it's one of the media keys, posts an appropriate notification to the default notification center. Now, this works fine if I post a notification for...

Simple sound effect loop using AudioToolKit

I've created a few sounds for use in my game. I can play them at certain events without issue: // create sounds CFBundleRef mainBundle; mainBundle = CFBundleGetMainBundle(); _soundFileShake = CFBundleCopyResourceURL(mainBundle, CFSTR("shake"), CFSTR("wav"), NULL); AudioServicesCreateSystemSoundID(_soundFileShake, &_soundIdShake); // l...

Core Foundation equivalent for NSLog

What is the closest Core Foundation function to the functionality of NSLog? ...

Malloc to a CGPoint Pointer throwing EXC_BAD_ACCESS when accessing

I am trying to use a snippet of code from a Apple programming guide, and I am getting a EXC_BAD_ACCESS when trying to pass a pointer to a function, right after doing a malloc. (For Reference: iPhone Application Programming Guide: Event Handling - Listing 3-6) The code in question is really simple: CFMutableDictionaryRef touchBeginPoin...

How to intercept deallocate callbacks of Core Foundation objects in Objective-C.

I'm writing an Eiffel wrapper for AppKit and Foundation and I need to hijack all -dealloc methods. Thanks to the dynamic nature of Objective-C it is pretty easy to do that. But the problem is it only works with some of the Foundation or AppKit objects. There are certain objects (e.g. NSString, NSArray, NSDate, ...) that are actually CF...

Carbon or CF to list contents of a directory (OS X and C++)

How do I use Carbon or CoreFoundation (preferably the latter) to list the contents of a directory? ...

Calling Obj-C CoreFoundation functions from JNA with Rococoa

Hi, I'm using Rococoa in a Java project and I am a newbie with JNA. I need to cast a NSURL object to its CFURLRef equivalent and pass it to a low-level C function in CoreFoundation (to create a CFBundle). I can't figure out how to cast a Rococoa NSObject or ID to a JNA Structure reference. Any hints? Thanks. François ...

CGContext widths seem to be over stretched

I'm working with CGContext to create a simple square with four given points (the points should make a perfect square). However, instead of a 200px x 200px square, the iPad app makes, what looks like, 680w by 300h. Am I missing something? int beginPointX, beginPointY, gridSize, gridPadding; gridSize = 200; gridPadding = 10; beginPointX...

What is NSSearchPathForDirectoriesInDomains ?

[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] I used to know that sending a message to the object is kind of calling the method. However, I can't recognize what is NSSearchPathForDirectoriesInDomains. Is it C style function? If yes then why among all message style calls we have thing kind o...

Getting iPhone addressbook contents without GUI.

I would like to list all phone numbers (or any other field) of people in the addressbook. I've written the following code: - (void)addressBookFill{ ABAddressBookRef addressBook = ABAddressBookCreate(); people = (NSArray*)ABAddressBookCopyArrayOfAllPeople(addressBook); [addressBook release]; } - (void)printAddressBook{ ...

Analog of Glib quarks on Mac OS.

Maybe you know any analogs of g_quark_from_string() and g_quark_to_string() in CoreFoundation or other frameworks? ...

Want to find out if iPhone can receive incoming calls (airplane mode)

My application's users don't like interruptions like incoming phone calls. I want to find out if the device is in Airplane mode, warn the user about possible interruptions and recommend invoking Airplane mode. The reachability examples tell me if the device has a network connection, but it's possible that WiFi is on while the phone is i...

Create NSData object with hex data

Hi there, I have a hex set of data, ripped from a .plist save of an NSArray, that reads (for example) like this: 06000000 01000000 00000000 00000000 00000000 00000000 00000000 00000000 00010000 08020100 00000000 e028f440 00008543 00809343 b0e22a00 that I would like to turn into an NSData object. What is the appropriate way to do this...

CFDictionaryValueCallBacks retain/release?

Is there a constant retain callback I can use for generic id / NSObjects ? There is kCFTypeDictionaryValueCallBacks but they're only for "CFType-derived objects." I don't believe NSObjects are CFTypes, so I wrote these: const void *valueRetainCallBack(CFAllocatorRef allocator, const void *ptr) { id o = (id)ptr; [o retain]; ...

NSDecimalNumber to unsignedLongLong - wrong value

Here is code: NSNumber* number = [NSDecimalNumber decimalNumberWithString :@"11111111111111111"]; NSLog(@"%@ = %lld", number, [number unsignedLongLongValue]); And I get output: 11111111111111111 = 11111111111111112 Is it known bug or I do something wrong? UPDATE: bug reported: https://bugreport.apple.com/cgi-bin/WebObjects/RadarWe...

Trying to get GetPrimaryMACAddress to stop printing verbose

Okay, this one seems to me a bit weird. Any help would be greatly appreciated. I recently implemented code that I found here to get the MAC address. The funny thing is that is prints to the console (in addition to the MAC address) something like the following: <CFData 0x317df0 [0xa03e9ee0]>{length = 6, capacity = 6, bytes = 0x001f5bd...