objective-cautomatic-ref-countinggh-unit

ARC, bridged cast and 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

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

Any help welcome :)


Solution

  • 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.