ARC, bridged cast and GHUnit
Asked Answered
T

2

7

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

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

Any help welcome :)

Tsarism answered 3/4, 2012 at 10:3 Comment(0)
C
11

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

So your example should read:

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

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.

Coffey answered 20/4, 2012 at 15:47 Comment(1)
Good catch. The current documentation just uses GHAssertNotNull instead of GHAssertNotNil, which causes issues with ARC code.Ellga
P
1

You can exclude only GHUnit files from automatics referencing(ARC) from your project by going into Build Phase -> Compile Sources

and then double click on the files from GHUnit, a box will appear, paste following into it

-fno-objc-arc

This will exclude the files from GHUnit from automatics referencing(ARC).

Privett answered 3/4, 2012 at 10:48 Comment(1)
Thats a good idea until GHUnit don't implement ARC. However i still wish to know how to do these bridges, as far trying to get this info from some ARC-references.Tsarism

© 2022 - 2024 — McMap. All rights reserved.