Simple question, but this gives me an error and I can’t seem to resolve it.
In my object (UIViewController) I have declared a method in the .h
-(void)setCurrentLoc:(CLLocation *)loc;
and in the .m
-(void)setCurrentLoc:(CLLocation *)loc
{
currentLocation = loc;
}
All good. But this is how I initiate this object (which works fine) but when I call setCurrentLoc: it gives SIGBART
.h
IBOutlet VectorViewController *vectorView;
.m
vectorView = [[VectorViewController alloc] init];
...
//In another method I call:
[vectorView setCurrentLoc:location]; // Error/SIGBART line
Is there something I missed? Maybe not making it global or something?
Error:
-[UIView setCurrentLoc:]: unrecognized selector sent to instance 0x841cab0
This means that you are sending the message to a pointer that is no longer pointing at your
VectorViewController, but is now pointing at aUIView. This usually happens when the object has been autoreleased or released and the memory re-used.Check carefully what happens between when you create vectorView and when you call it again in your other method. You seem to be setting and accessing the instance variable directly – you should probably be accessing it via properties (hard to be specific without knowing if you are using ARC or not) and making sure those properties are declared appropriately.