On Feb 15, 2009, at 1:32 PM, Martin Redington wrote:

In my projects, I tend to define methods which need access to member
variables as class methods, and related functions, which do not need
"direct" access to any internal object data, as C functions, like the
simple example below.

@implementation FunctionTestAppController

+ (id) sharedController
{
        return [NSApp delegate];
}

- (BOOL) someMethod
{
       // would normally access some ivar.
        return YES;
}

@end


BOOL SomeFunction()
{
        return YES;
}



I've recently been implementing unit testing, following
http://developer.apple.com/mac/articles/tools/unittestingwithxcode3.html
- i.e. the main app binary is specified as the bundle loader, and
testing is done via injection of the unit test bundle, with a clear
separation between application and test code.

Everything works fine for objective-C methods, but I get linker errors
when I try and reference any of the C functions defined in my
application code. nm reveals that the symbols are present in the app
binary, but the linker doesn't seem to be able to see them.

Is there a recommended, or even a good way, to get the test code to
link correctly to the applications C functions?


That's really bad OO design. One of the reasons is the one you face now. Testing it. Rewrite them correctly as instance methods, then test.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to