Question: I made this simple effect of a ball bouncing off the screen. It only works with the top and bottom edges but I don't know why. Besides, when I try this code in an iOS 7 `SpriteKit` template in the `initwithsize` method it works. Is this a bug or something?

```
#import "GameScene.h"

@implementation GameScene

-(void)didMoveToView:(SKView *)view {
    self.backgroundColor = [SKColor whiteColor];
    SKSpriteNode *ball =[SKSpriteNode spriteNodeWithImageNamed:@"ball"];
    ball.position =CGPointMake(self.frame.size.width/2, self.frame.size.height/2);
    ball.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:ball.frame.size.width/2];
    self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame];
    self.physicsWorld.gravity = CGVectorMake(0, 0);
    CGVector impulse =     CGVectorMake(20,20);
    [self addChild:ball];

    [ball.physicsBody applyImpulse:  impulse];

    ball.physicsBody.restitution = 1;
    ball.physicsBody.friction = 0;
    ball.physicsBody.linearDamping = 0;

  /* 
   SKSpriteNode *wall =[SKSpriteNode spriteNodeWithImageNamed:@"wall"];

   SKSpriteNode *bar =[SKSpriteNode spriteNodeWithImageNamed:@"bar"];

   wall.position= CGPointMake(self.frame.size.width/2, 103);
    bar.position = CGPointMake(self.frame.size.width/2,  (wall.frame.size.height));
    [self addChild:wall];
    [self addChild:bar];

    */

}

-(void)update:(CFTimeInterval)currentTime {
    /* Called before each frame is rendered */
}

@end

```

Answer: 
Solution 1 is very simple and you can make it a little bit less dirty.

Assuming you want to perform the check for every action in the controller, you can just use the `initializeAction`:

```
public function initializeAction() {
    if (!$this->myObjectService->isAuthenticatedUserOwnerOfObject($this->arguments['myObject'])) {
        $code = 401;
        $message = 'Authorization Required';
        $this->response->setStatus($code, $message);
        $this->response->shutdown();
    }
}

```

If you have actions in your controller that don't need this check, you might want to split it to two controllers, one for protected and one for non-protected methods.

You can also use the magic initialize\*Action for every action, e.g. in your case:

```
public function initializeGetObjectAction()

```
At the end I decided to go for item 3. Current application logic is such, that any controller, which has *MyObject* in arguments should perform access check.

My **ext\_localconf.php**

```
$signalSlotDispatcher->connect(
    \TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class,
    'beforeCallActionMethod',
    \MyVendor\MyExt\Slot\MyObjectAccessor::class,
    'actionAuthorized'
);

```

**\MyVendor\MyExt\Slot\MyObjectAccessor**

```
class MyObjectAccessor{

    use LoggedInUserAccessor;

    /**
     * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
     * @inject
     */
    protected $objectManager;

    /**
     * Checks whether current user is allowed to access MyObject, from provided arguments
     * @param string $controller
     * @param string $action
     * @param array $arguments
     * @throws AccessViolationException
     */
    public function actionAuthorized($controller, $action, array $arguments) {
        foreach($arguments as $argument) {
            // if MyObject is accessed and it was persisted before
            if(($argument instanceof MyObject) && $argument->getUid()) {
                $loggedInUser = $this->getLoggedInUser();
                if($argument->getUser() !== $loggedInUser) {
                    throw new AccessViolationException(
                        'Access violation by "' . $loggedInUser->getUsername() . '" with MyObject "' . $argument->getTitle() . '"',
                        1441808407
                    );
                }
            }
        }
    }
}

```

**Drawback** of this solution: slot runs for any action, which may eat some resources.

**Benefit**: no controller should know details about access rules for MyObject.