Tag: 核心基础

Swift:在CFArray中提取/向下转换基于CFType的CoreTexttypes

我想将CoreAnimationText示例的元素移植到Swift中。 但是我不知道如何从数组中提取或向下转换CTRun的元素,以便将它们传递给期望并在Swift ified CTRuntypes上执行的函数。 我要么得到运行时错误或从下面的游乐场片段链接错误 import CoreText import QuartzCore let text = NSAttributedString(string: "hello") var line: CTLine = CTLineCreateWithAttributedString(text) var ctRuns:CFArray = CTLineGetGlyphRuns(line) let nsRuns:Array<AnyObject> = ctRuns as NSArray nsRuns.count // == 1 // Playground execution failed: error: error: Couldn't lookup symbols:_OBJC_CLASS_$_CTRun let nsRun = nsRuns[0] as CTRun nsRun.self println(nsRun.self) let anyRuns = nsRuns as […]

Swift:CGPathRelease和ARC

刚更新到Xcode Beta 4,并注意到下面的编译器错误与我的代码如下: var path = CGPathCreateMutable() … CGPathRelease(path) “CGPathRelease”不可用:核心基础对象会自动进行内存pipe理 所以我只是简单地删除我的发布呼叫,一切都应该罚款? 还是有更多我失踪? 有什么特殊情况我应该知道与ARC?

保留的核心基础属性

(Xcode 4.2,iOS 5, ARC ) 我有一些Core Foundation(/ Graphics)对象的属性,它们应该拥有对象的所有权。 现在在这些苹果文档中,我发现这个: 在OS X v10.6和更高版本中,可以使用__attribute__关键字来指定Core Foundation属性应该像内存pipe理的Objective-C对象一样对待: @property(retain) __attribute__((NSObject)) CFDictionaryRef myDictionary; 不幸的是我找不到任何细节。 我正在使用这个: @property (nonatomic, strong) __attribute__((NSObject)) CGImageRef loupeImage; 而且它似乎以我期望的方式工作。 它将保留设置属性的对象,并在将属性设置为nil时释放它。 现在我的问题是,我仍然需要明确地设置这些属性为零在我dealloc?

Xcode 7 Beta 6,dyld ___NSArray0__崩溃

我第一次能够在Xcode 7中编译我的应用程序(在testing版4和5中失败)。 所以,我猜这是很好的进展。 但是,当我加载我的iPhone 6,iOS 8.4.1的应用程序,它崩溃在debugging器中,并显示以下消息: dyld:找不到符号: _NSArray0引用自:/private/var/mobile/Containers/Bundle/Application/0294DF62-AE80-485D-BB11-8C3A5D39777D/Boxtiq.app/Boxtiq预计位于:/ System / Library / Frameworks / CoreFoundation。 framework / CoreFoundation in /private/var/mobile/Containers/Bundle/Application/0294DF62-AE80-485D-BB11-8C3A5D39777D/Boxtiq.app/Boxtiq 这是与被链接的库的顺序有关吗? 期待一些build议。 谢谢!