Note that there are some explanatory texts on larger screens.

plurals
  1. POCall a method from another class when shake is detected
    primarykey
    data
    text
    <p>HERE IS THE CODE: <a href="http://min.us/mWdMO0n14" rel="nofollow">http://min.us/mWdMO0n14</a></p> <p>I'm a Obj C newbie, so I've searched quite a bit, but haven't found anything that can solve my problem.</p> <p>I have CalculatorViewController.h and .m and then CalculatorBrain.h and.m (Stanford Lectures)</p> <p>in CalculatorBrain.m, I have the following method, with all of the variables defined as private in the CalculatorBrain header.</p> <pre><code>- (void)clearEverythingOnShakeGesture{ operand = 0; waitingOperation = @""; waitingOperand = 0; } </code></pre> <p>Then in CalculatorBrain.m , I have everything set up to detect shakes, as follows. I've included some of the code above the shake detection just so you have a general idea.</p> <pre><code>@interface CalculatorViewController() @property(nonatomic, retain) CalculatorBrain *brain; @end @implementation CalculatorViewController @synthesize brain; - (CalculatorBrain *)brain { if (!brain) { brain = [[CalculatorBrain alloc] init]; } return brain; } -(BOOL)canBecomeFirstResponder{ return YES; } -(void)viewDidAppear: (BOOL) animated{ [super viewDidAppear:animated]; [self becomeFirstResponder]; } - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.subtype == UIEventSubtypeMotionShake) { NSLog(@"SHAKE IT!"); [brain clearEverythingOnShakeGesture]; //********** not sure how to call this. } } </code></pre> <p>I'm not sure how to call <code>[brain clearEverythingOnShakeGesture];</code> , because I get the error "Class method +clearEverythingOnShakeGesture not found, defaults to return type id". However, if I make it a class method, the variables inside are instance variables, which provides another error. Any help greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload