Всем спасибо!
Решение найдено:
-(void) start{
double __block firstY, mediumY, lastY=0;
int __block i=0;
[self addObserver:self forKeyPath:@"count" options:NSKeyValueObservingOptionNew context:nil];
self.motionManager = [[CMMotionManager alloc]init];
self.motionManager.deviceMotionUpdateInterval = 0.1;
[self.motionManager startDeviceMotionUpdatesToQueue:[[NSOperationQueue alloc]init] withHandler:^(CMDeviceMotion *motion, NSError *error) {
CMAcceleration acceleration = motion.userAcceleration;
[self changeFilter:[LowpassFilter class]];
[filter addAcceleration:&acceleration];
if([UIDevice currentDevice].orientation!=1){
[self.messageText performSelectorOnMainThread:@selector(setText:) withObject:@"Держите телефон вертикально!" waitUntilDone:NO];
} else {
[self.messageText performSelectorOnMainThread:@selector(setText:) withObject:@"" waitUntilDone:NO];
double y = filter.y>0.5?filter.y:0;
if (i < 3){
if(i%3==0){
firstY = y;
}
if(i%3==1){
mediumY = y;
}
if(i%3==2){
lastY = y;
}
}else{
firstY = mediumY;
mediumY = lastY;
lastY = y;
}
if(mediumY>firstY){
if(mediumY>lastY){
self.count++;
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
}
}
i++;
}
}];
self.trained = YES;
}
Считает не без корявостей, конечно. Но хоть как-то. Буду благодарен за модификации.