-2

I have a memory leak spawning from the block below. Im pretty certain the following objects are getting tangled up. I have tried setting them up with (weak) relationships but that hasn't been successful. Any ideas on how I could combat/rewrite this issue? Thanks.

AssistHub.m

 @implementation

- (void)startGameWithBlock:(void (^)(Game *))block
{

     _viewControllerGame = [[GameViewController alloc] init];
     _viewControllerGame.delegate = (id)self;

     Game *game = [[Game alloc] init];
     _viewControllerGame.thisGame = game;
     game.delegate = _viewControllerGame;

     block(game);

}
trincot
  • 317,000
  • 35
  • 244
  • 286
  • Refer this post http://stackoverflow.com/questions/10707143/can-using-weak-attribute-to-pass-parameter-to-blocks-lead-to-memory-leaks – Natarajan Apr 30 '14 at 13:47

1 Answers1

0

Please, do the following checks:

  1. First ensure you use weak references if required to avoid memory retain cycles. Please see the following link that could help you to write weak reference in a more consice way weak references.

  2. Be sure that you're using weak for your delegates too. If not, you'd be causing a cycle there too. Check _viewControllerGame.delegate and +game.delegate = _viewControllerGame;*

Barbara R
  • 1,057
  • 5
  • 18