In a word, how?
I have a view controller that creates a few custom objects. One of those objects needs to call a method back in the controller. The object looks like it wants to call a class method in the controller, which might be fine, except that class in the controller needs to call an instance method in the controller, and it doesn't seem to want to do that. Does that make sense?
If not, here's pseudo code:
ViewController.m
#import "customObj.h"
-(void)viewDidLoad{
foobar=@"string";//declared in ViewController.h
}
-(void)createObj{
foobar=@"different string";
customObj *customObjInstance=[[customObj alloc] init];
}
---
customObj.m
#import "ViewController.h"
-(void)callBack{
[ViewController createObj];
}
Okay, so when callBack runs, it errors, saying it's looking for +createObj (not -createObj). I can change createObj to a class method, but then it has a problem setting foobar because foobar was initialized in -viewDidLoad, and I can't change that to +viewDidLoad. I could maybe move foobar out into a class method, but then how do I call it? Instead of self, do I refer to [ViewController ...]? I don't think that works.
My guess is I'm missing some basic concept and it's not anywhere as difficult as I'm making it. I am indebted to anyone who can straighten me out.
Thanks much.