core-foundation

CFPreferences to /Library/Preferences

可紊 提交于 2019-12-04 06:42:22
问题 I have a prefpane used in System Preferences (With the authorization lock). I need to get my preferences to write to /Library/Preferences . However, whenever I try to synchronize the prefs to kCFPreferencesAnyUser and kCFPreferencesCurrentHost it just fails out even if my lock is unlocked. Is there any way to write my preferences to /Library/Preferences without creating a helper application? I would want to avoid that because it's redundant. Note that to modify “Any User” preferences requires

NSString is exactly the same as CFString?

回眸只為那壹抹淺笑 提交于 2019-12-04 03:47:36
O'Reilly's Programming iOS 5 says (maybe in a looser sense), that "an NSString is a CFString". But is it true that at least NSString * will point to some memory chunk with an isa , while CFStringRef probably does not? Not exactly the same; they are Toll-Free Bridged . This Apple Doc should explain in more detail. Here is even more detail from iOS 5 Programming Pushing The Limits on Google Books . 来源: https://stackoverflow.com/questions/12641189/nsstring-is-exactly-the-same-as-cfstring

Unmounting Drive/volume without ejecting

与世无争的帅哥 提交于 2019-12-03 20:54:37
I am want to unmount a disk WITHOUT EJECTING. To do that I tried following code { NSString *path; CFStringRef *volumeName=(__bridge CFStringRef)path; DASessionRef session = DASessionCreate(kCFAllocatorDefault); CFURLRef pathRef = CFURLCreateWithString(NULL, CFSTR("/volumes/Untitled"), NULL); DADiskRef disk = DADiskCreateFromVolumePath(kCFAllocatorDefault, session, pathRef); DADiskUnmount(disk, kDADiskUnmountOptionForce, NULL, NULL); } This code is from this question, Thanks to @zeFree Its working but I want dynamic path to the volume where as in the code its static. I tried changing NSString

reading value in CFDictionary with swift

江枫思渺然 提交于 2019-12-03 19:13:17
问题 I'm just starting with swift and cocoa. I'm trying to create a basic app that does image manipulation. I've allready got all information of the image with this: let imageRef:CGImageSourceRef = CGImageSourceCreateWithURL(url, nil).takeUnretainedValue() let imageDict:CFDictionaryRef = CGImageSourceCopyPropertiesAtIndex(imageRef, 0, nil).takeUnretainedValue() the dictionary contains following information: { ColorModel = Gray; DPIHeight = 300; DPIWidth = 300; Depth = 1; Orientation = 1;

Converting plist to binary plist

☆樱花仙子☆ 提交于 2019-12-03 18:20:55
问题 Apple strongly recommends using the binary plist format when reading large XML-based data sets into iPhone apps. Among their reasoning is the fact that XML parsing is very taxing on the iPhone. However, this requires that files residing on the remote web server be converted first. For frequently-changing content, it is not acceptable to do this manually. If at all possible, I'd like to avoid having a web based app call the command line to perform the conversion (i.e., plutil). Are there

Why would CFRelease(NULL) crash?

瘦欲@ 提交于 2019-12-03 18:00:57
问题 Is there a reason why CFRelease does not check for NULL? Isn't it unacceptable when [nil release]; free(NULL); delete NULL; all work perfectly fine? 回答1: The source code to CoreFoundation is publicly available. Specifically, for Snow Leopard the code to CFRelease is in http://www.opensource.apple.com/source/CF/CF-550/CFRuntime.c Here is what the relevant portion looks like: void CFRelease(CFTypeRef cf) { if (NULL == cf) HALT; #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED if (CF

Is it safe to schedule and invalidate NSTimers on a GCD serial queue?

牧云@^-^@ 提交于 2019-12-03 17:50:02
问题 What's the right way to do this? The NSTimer documentation says this: Special Considerations You must send this message from the thread on which the timer was installed. If you send this message from another thread, the input source associated with the timer may not be removed from its run loop, which could prevent the thread from exiting properly. Since GCD doesn't assure you that a serial queue will always run blocks on the same thread, what's the right way to ensure that you schedule and

What's the right memory management pattern for buffer->CGImageRef->UIImage?

末鹿安然 提交于 2019-12-03 17:12:36
问题 I have a function that takes some bitmap data and returns a UIImage * from it. It looks something like so: UIImage * makeAnImage() { unsigned char * pixels = malloc(...); // ... CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, pixels, pixelBufferSize, NULL); CGImageRef imageRef = CGImageCreate(..., provider, ...); UIImage * image = [[UIImage alloc] initWithCGImage:imageRef]; return [image autorelease]; } Can anyone explain exactly who owns what memory here? I want to clean up

where to download for apple's open source core foundation?

我怕爱的太早我们不能终老 提交于 2019-12-03 15:49:21
where should I download the core foundation library? I have a program that includes CoreFoundation/CoreFoundation.h ... It is an iPhone app, but I'm thinking the core foundation code will run on linux. All Apple's open source code can be found in http://opensource.apple.com/ . The source code of Core Foundation (actually, "CFLite") can be found in http://www.opensource.apple.com/source/CF/CF-635.19/ , and can be downloaded from http://www.opensource.apple.com/tarballs/CF/CF-635.19.tar.gz . The README file describes how to build the library on Linux. Note that not the full Core Foundation is

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

半腔热情 提交于 2019-12-03 13:33:44
问题 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 change. On newer mid-2010 MacBook Pro's, Apple started using auto-switching Intel/nVidia graphics. Laptops have two GPU's, a low-powered Intel, and a high-powered nVidia.