我正在使用從Apple的有用UIElementUtilities應用程序中借用的Core Foundations方法。問題是我希望更新這個借用的方法,以便在Apple的新自動引用計數(ARC)系統下運行。通過在變量之前插入'__bridge'限定符,我已經取得了一些進展,但是使用下面顯示的方法,嘗試轉換爲ARC後出現以下錯誤:「error:Incompatible types cast'NSString __strong *'到'CFTypeRef *'(aka'const void **)用__bridge cast「。我該如何製作一個可接受的指向'actionDescription'緩衝區的指針,以便將其內容重新改寫爲NSString?ARC不兼容類型鑄造
+ (NSString *)descriptionOfAction:(NSString *)actionName ofUIElement:(AXUIElementRef)element {
NSString * actionDescription = nil;
AXUIElementCopyActionDescription(element, (__bridge CFStringRef)actionName, (__bridge CFStringRef *)&actionDescription);
return actionDescription;
//return [actionDescription autorelease];
}
感謝您的解決方案和解釋,但很明顯,我是在我的頭上。 – Antony 2014-12-06 16:04:13