ARC,桥接演员表和GHUnit [英] ARC, bridged cast and GHUnit

查看:129
本文介绍了ARC,桥接演员表和GHUnit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在跟踪 http://gabriel.github上的教程. com/gh-unit/docs/appledoc_include/guide_testing.html .问题是我的项目使用的是ARC,而GHUnit没有使用.我已经解决了以前的错误,但是现在我应该进行桥接转换,这是我从未使用过的,而且我迷路了.

I'm followinng tutorial from http://gabriel.github.com/gh-unit/docs/appledoc_include/guide_testing.html. The problem is that my project uses ARC and GHUnit doesn't. I managed previous errors, but now i should do bridged cast, that i've never used, and i'm lost.

NSString *string1 = @"a string";
GHAssertNotNULL(string1, nil); //error here

错误描述:Objective-C指针类型'NSString *'隐式转换为C指针类型'const void *'需要桥接转换.

Error description: Implicit conversion of Objective-C pointer type 'NSString *' to C pointer type 'const void *' requires a bridged cast.

欢迎任何帮助:)

推荐答案

由于要比较NSString,因此应使用GHAssertNotNil检查.有关更多信息,请参见 Objective-C中的NULL vs nil .

Since you are comparing an NSString, you should use the GHAssertNotNil check. See NULL vs nil in Objective-C for more info.

因此您的示例应为:

NSString *string1 = @"a string";
GHAssertNotNil(string1, nil);

在GHUnit的ARC项目中,我还注意到GHUnit main.m文件需要

I've also noticed in my ARC projects using GHUnit that the GHUnit main.m file needs the

-fno-objc-arc

以前建议的链接器标志.

linker flag as was suggested previously.

这篇关于ARC,桥接演员表和GHUnit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆