core-foundation

CoreFoundation vs Foundation

为君一笑 提交于 2019-12-31 08:23:26
问题 In iPhone development, speed is of the essence. Does anyone know if there is a speed difference between using a CoreFoundation type (like CFMutableDictionaryRef) versus a Foundation type (its counterpart, NSMutableDictionary). I would think manipulating the CF type would be faster as it doesnt have to throw around ObjC runtime messages, is this an unfounded assumption, has anyone actually looked in to this? 回答1: In a technical sense, yes, it is faster, for exactly that reason. In a practical

CoreFoundation vs Foundation

蹲街弑〆低调 提交于 2019-12-31 08:23:15
问题 In iPhone development, speed is of the essence. Does anyone know if there is a speed difference between using a CoreFoundation type (like CFMutableDictionaryRef) versus a Foundation type (its counterpart, NSMutableDictionary). I would think manipulating the CF type would be faster as it doesnt have to throw around ObjC runtime messages, is this an unfounded assumption, has anyone actually looked in to this? 回答1: In a technical sense, yes, it is faster, for exactly that reason. In a practical

Swift: CGPathRelease and ARC

安稳与你 提交于 2019-12-30 18:26:13
问题 Just updated to Xcode Beta 4, and noticed the following compiler error with my code below: var path = CGPathCreateMutable() ... CGPathRelease(path) 'CGPathRelease' is unavailable: Core Foundation objects are automatically memory managed So do I simply just remove my release calls and everything should be fine? Or is there something more I'm missing? And are there any special cases I should be aware of with ARC? 回答1: The Working with Cocoa Data Types section of Using Swift with Cocoa and

Can't pass parameter of type CGColorRef in LLDB

爷,独闯天下 提交于 2019-12-25 14:25:07
问题 I'm extending Facebook’s Chisel to be able to visualize a color from the debugger. I want it to work for UIColor , CIColor , and CGColorRef . The two object-based ones are working fine, but the CGColorRef is giving me trouble. Here is the bug I'm working from, where I've already hashed out a bunch of the stuff from this question. I've boiled the issue down to this test case: If I have some function: + (UIColor *)someColor { UIColor *uiColor = [UIColor redColor]; CGColorRef cgColor = uiColor

Create a shell-escaped POSIX path in macOS

一世执手 提交于 2019-12-25 03:03:33
问题 I need to create a string from a full POSIX path (starting at the root), so that it could be pasted directly into a Unix shell like bash , e.g. in Terminal.app , without the need for quotes around the path. (I do not actually pass the string to a shell, but instead need it for passing it to another program. That program expects the path in just the form that you get when you drag a file into Terminal.app .) For that, I need to escape at least any spaces in the string, by prepending them with

What is __CFString?

梦想与她 提交于 2019-12-25 01:08:17
问题 I have arg1 which is an IMessage. IMessage is defined as: struct IMessage { ... struct CFString _field2; ... }; and CFString is defined as: struct CFString { void **_vptr$CFObject; struct __CFString *mCFRef; _Bool mIsMutable; }; and __CFString is defined as: struct __CFString; My goal is to get a string of some sort be it NSString or CFStringRef from arg1, so how can i do it? Thanks. Here is the error I get when I try to nslog mCFRef: Thread 0 crashed: # 1 0x97b41edb in _objc_msgSend +

parsing DER format data using SecAsn1Decode

瘦欲@ 提交于 2019-12-24 21:32:59
问题 I'm trying to use SecAsn1Decode in order to parse the following DER encoded data. However, I failed to define the template for this struct (represented by SecAsn1Template ). perhaps anybody can explain how to create a template for the following DER structure : here's the binary raw data (DER formatted) 30 81 8E 31 0B 30 09 06 03 55 04 06 13 02 49 4C 31 0F 30 0D 06 03 55 04 08 0C 06 69 73 72 61 65 6C 31 0C 30 0A 06 03 55 04 07 0C 03 54 4C 56 31 0B 30 09 06 03 55 04 0A 0C 02 54 53 31 1E 30 1C

How can I start QuickTime and have it start playing a url?

隐身守侯 提交于 2019-12-24 10:01:51
问题 I'm using MonoMac, but I understand cocoa and objc well enough that if you can answer me in those languages, please do. I have a url from my web server which returns an mp4. I'd like my MonoMac application to launch QuickTime and start playing that url. I tried these methods: Process.Start("/Applications/QuickTime Player.app/Contents/MacOS/QuickTime Player", url); but when the url is something like http://webhost/1/blah.mp4, quicktime says "The document blah.mp4 could not be opened. The file

How could I type check CGColor / CGPath?

拥有回忆 提交于 2019-12-24 00:53:09
问题 So what it appears there is a filed bug for swift relating to the CoreFoundation types. Based on the description it appears there is not type checking for CGPath and CGColor, below is a snippet from the bug that demonstrates the behavior. func check(a: AnyObject) -> Bool { return a is CGColor } check("hey") --> true check(1.0) --> true check(UIColor.redColor()) --> true And here is what I'm trying to do if let value = self.valueForKeyPath(keyPath) { if let currentValue = value as? CGColor { /

Storing a C struct in CFMutableDictionary

南笙酒味 提交于 2019-12-22 08:12:56
问题 Since there is no counterpart to NSValue in Core Foundation, how are we supposed to store C structs in a CFMutableDictionary? 回答1: First, you can put an NSvalue in a CFMutableDictionary as-is, so the answer is "use NSValue." But I assume the rest of your question is "without using any Cocoa objects." In that case, just create a non-retaining CFMutableDictionary, and you can put any pointer you want into it. See "Defining Custom Collection Callbacks" for some example code. I use these a lot.