I am using MVC architecture for a GUI application. The model class has some C functions. One of the C functions calls some methods of Objective-C class. I call those methods using an object of that class. The strange thing happening is that methods previously to the an xyz method are called perfectly but when that xyz method is called, that method and the methods after it aren't getting executed. I don't get any errors. So can't figure out what exactly is happening. Any ideas as to what might be the reason for this?
As Marc points out, you're probably using a reference to the OBJC object that is un-initialised outside the objective-c scope.
Here's a working sample of C code calling an ObjC object's method:
#import <Cocoa/Cocoa.h>
id refToSelf;
@interface SomeClass: NSObject
@end
@implementation SomeClass
- (void) doNothing
{
NSLog(@"Doing nothing");
}
@end
int otherCfunction()
{
[refToSelf doNothing];
}
int main()
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
SomeClass * t = [[SomeClass alloc] init];
refToSelf = t;
otherCfunction();
[pool release];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With