Note that there are some explanatory texts on larger screens.

plurals
  1. PO-[CFString retain]: message sent to deallocated instance 0x215076c0
    primarykey
    data
    text
    <p>I know this subject has been discussed several times, but I cannot figure out what is causing this error message. I've been stuck here for a couple weeks now and its driving me crazy. The first part of the method sets up a match for 2-4 players. Once a match is found, it tries to add 3 and 4 players within a certain limit. Right now, the limit is just set to 3 seconds, but I envision it being much larger once it is ready for release.</p> <p>I know this is a memory error somewhere in the matchmakerViewController code. When I comment out the code changing the scene, I still get the error. Can you show me what I've done wrong and how to fix it?</p> <pre><code>-(void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match { NSLog(@"IN matchmakerViewController!"); NSLog(@"Found a match!"); //startDate = [[NSDate date] retain]; //NSArray * playerIds1 = match.playerIDs; //[marray_players addObject:playerIds1]; // Setup match TXGameCenterManager *gameCenterManager = [TXGameCenterManager sharedTXGameCenterManager]; gameCenterManager.multiplayerMatch = match; // The delegate of the match is HelloWorldLayer gameCenterManager.multiplayerMatch.delegate = self; AppDelegate * delegate = (AppDelegate *) [UIApplication sharedApplication].delegate; [delegate.viewController dismissModalViewControllerAnimated:NO]; GKMatchRequest * matchRequest = [[[GKMatchRequest alloc] init] autorelease]; NSLog(@"playerIDs count is %d",[match.playerIDs count] ); if( match.expectedPlayerCount==0 ) { // Launching the game without waiting for connection change messages NSLog(@"Begin game without waiting for match connection change messages"); // Determine the host, local or remote NSArray * playerIds = match.playerIDs; NSLog(@"Number of players: %d", [playerIds count]); NSLog(@"ID of player: %@", [playerIds lastObject]); NSLog(@"I got the player ids"); [GKPlayer loadPlayersForIdentifiers:playerIds withCompletionHandler:^(NSArray *players, NSError * error) { NSLog(@"Player 1 %@", [[players objectAtIndex:0] alias] ); // NSLog(@"Player 2 %@", [[players objectAtIndex:1] alias] ); if( !error) { NSLog(@"Local player: %@", [[GKLocalPlayer localPlayer] alias]); NSLog(@"Remote player: %@", [[players lastObject] alias]); NSLog(@"Remote player: %@", [[players lastObject] alias]); //NSArray *nsarray_player2 = [marray_players objectAtIndex:1]; // remote1name= [[nsarray_player1 lastObject] alias]; int_totalremoteplayers=[match.playerIDs count]; boo_playersfound=true; localName = [[GKLocalPlayer localPlayer] alias]; remoteName = [[players objectAtIndex:0] alias]; NSLog(@"Player 1 %@", [[players objectAtIndex:0] alias] ); // NSLog(@"Player 2 %@", [[players objectAtIndex:1] alias] ); //remote1name= [[nsarray_player1 lastObject] alias]; if ([match.playerIDs count]==1) { NSLog(@"IN [match.playerIDs count]==1"); remoteplayer1name= [[players objectAtIndex:0] alias]; [playernames addObject:remoteplayer1name]; [playernames addObject:localName]; NSArray *sortedArray; sortedArray = [playernames sortedArrayUsingSelector: @selector(localizedCaseInsensitiveCompare:)]; NSLog(@"Host: %@", [sortedArray objectAtIndex:0]); NSLog(@"Player1: %@", [sortedArray objectAtIndex:1]); hostName=[sortedArray objectAtIndex:0]; remoteplayer1name=[sortedArray objectAtIndex:1]; if ([hostName isEqualToString:localName]) { [[TXGameCenterManager sharedTXGameCenterManager] setHost:YES]; } } if ([match.playerIDs count]==2) { NSLog(@"IN [match.playerIDs count]==2"); NSLog(@" [match.playerIDs count]==2 Player 1 %@", [[players objectAtIndex:0] alias] ); NSLog(@"[match.playerIDs count]==2 Player 2 %@", [[players objectAtIndex:1] alias] ); NSLog(@"[match.playerIDs count]==2 localName %@", localName ); remoteplayer1name= [[players objectAtIndex:0] alias]; remoteplayer2name= [[players objectAtIndex:1] alias]; [playernames addObject:remoteplayer1name]; [playernames addObject:remoteplayer2name]; [playernames addObject:localName]; NSLog(@"Players in playernames %d", [playernames count]); NSArray *sortedArray; sortedArray = [playernames sortedArrayUsingSelector: @selector(localizedCaseInsensitiveCompare:)]; NSLog(@"Host: %@", [sortedArray objectAtIndex:0]); NSLog(@"Player1: %@", [sortedArray objectAtIndex:1]); NSLog(@"Player2: %@", [sortedArray objectAtIndex:2]); hostName=[sortedArray objectAtIndex:0]; remoteplayer1name=[sortedArray objectAtIndex:1]; remoteplayer2name=[sortedArray objectAtIndex:2]; if ([hostName isEqualToString:localName]) { [[TXGameCenterManager sharedTXGameCenterManager] setHost:YES]; } NSLog(@"match.expectedPlayerCount = %d",match.expectedPlayerCount); } else if ([match.playerIDs count]==3) { remoteplayer1name= [[players objectAtIndex:0] alias]; remoteplayer2name= [[players objectAtIndex:1] alias]; remoteplayer3name= [[players objectAtIndex:2] alias]; [playernames addObject:remoteplayer1name]; [playernames addObject:remoteplayer2name]; [playernames addObject:remoteplayer3name]; [playernames addObject:localName]; NSArray *sortedArray; sortedArray = [playernames sortedArrayUsingSelector: @selector(localizedCaseInsensitiveCompare:)]; NSLog(@"Host: %@", [sortedArray objectAtIndex:0]); NSLog(@"Player 1: %@", [sortedArray objectAtIndex:1]); NSLog(@"Player 2: %@", [sortedArray objectAtIndex:2]); NSLog(@"Player 3: %@", [sortedArray objectAtIndex:3]); hostName=[sortedArray objectAtIndex:0]; remoteplayer1name=[sortedArray objectAtIndex:1]; remoteplayer2name=[sortedArray objectAtIndex:2]; remoteplayer3name=[sortedArray objectAtIndex:3]; if ([hostName isEqualToString:localName]) { [[TXGameCenterManager sharedTXGameCenterManager] setHost:YES]; } } NSLog(@"Player names"); // TODO: Set the correct player names in the globals player1 = localName; player2 = [[NSUserDefaults standardUserDefaults] objectForKey:@"player2name"]; player3 = [[NSUserDefaults standardUserDefaults] objectForKey:@"player3name"]; player4 = [[NSUserDefaults standardUserDefaults] objectForKey:@"player4name"]; NSLog(@"Launch the game"); // Launch the game int_team2tally=0; NSLog(@"boo_startgame"); boo_startgame=true; NSLog(@"go to the required scene"); //go to the required scene } else { NSLog(@"Error"); } NSLog(@"StartMultiplayerGameTablehost"); //gameCenterManager.matchController.matchmakerDelegate = nil; [self performSelector:@selector(StartMultiplayerGameTablehost) withObject:nil afterDelay:1.]; } ]; NSLog(@"No Error"); } // Believe the error is somewhere in the following code. if (boo_gamestarted!=true) { if (match.expectedPlayerCount==0) { //if([localName isEqualToString:hostName]) // { boo_startgame=true; if ([match.playerIDs count]==1) { matchRequest.minPlayers = 3; matchRequest.maxPlayers = 4; matchRequest.playersToInvite = nil; [[GKMatchmaker sharedMatchmaker] addPlayersToMatch:match matchRequest:matchRequest completionHandler:^(NSError *error) { if (error) { NSLog(@"An error occurred during adding a player to match: %@", [error localizedDescription]);} else if (match != nil) {NSLog(@"A player has been added to the match");} }]; } else if ([match.playerIDs count]==2) { matchRequest.minPlayers = 4; matchRequest.maxPlayers = 4; matchRequest.playersToInvite = nil; [[GKMatchmaker sharedMatchmaker] addPlayersToMatch:match matchRequest:matchRequest completionHandler:^(NSError *error) { if (error) { NSLog(@"An error occurred during adding a player to match: %@", [error localizedDescription]);} else if (match != nil) {NSLog(@"A player has been added to the match");} }]; } if ([match.playerIDs count]==3) { NSLog(@"Starting Game-589"); // [CCTimer timerWithTarget:self selector:@selector(StartMultiplayerGameTablehost) interval:10]; //[self performSelector:@selector(StartMultiplayerGameTablehost) withObject:nil afterDelay: 1.]; } // end if (match.expectedPlayerCount==0) else if (boo_gamestarted==false) { NSLog(@"player count = %d",[match.playerIDs count]); NSLog(@"Starting Game-597"); // [self performSelector:@selector(StartMultiplayerGameTablehost) withObject:nil afterDelay:1.]; } //[CCTimer timerWithTarget:self selector:@selector(StartMultiplayerGameTablehost) interval:10]; // [self performSelector:@selector(StartMultiplayerGameTablehost) withObject:nil afterDelay:3.]; // } // else { boo_startgame=true; matchRequest.minPlayers = 3; matchRequest.maxPlayers = 4; matchRequest.playersToInvite = nil; [[GKMatchmaker sharedMatchmaker] addPlayersToMatch:match matchRequest:matchRequest completionHandler:^(NSError *error) { if (error) { NSLog(@"An error occurrred during adding a player to match: %@", [error localizedDescription]);} else if (match != nil) {NSLog(@"A player has been added to the match");} }]; [self performSelector:@selector(StartMultiplayerGameTablehost) withObject:nil afterDelay:3.]; } } } } -(void)StartMultiplayerGameTablehost { boo_gamestarted=true; [[CCDirector sharedDirector] replaceScene:[HelloWorldLayer node]]; } -(void)dealloc { [super dealloc]; } </code></pre> <p>The end result is a message that looks like:</p> <pre><code>#0 0x32499468 in ___forwarding___ () #1 0x323f0f68 in __forwarding_prep_0___ () #2 0x31ffac5e in _Block_object_assign () #3 0x39614614 in __copy_helper_block_333 () #4 0x31ffa928 in _Block_copy_internal () #5 0x34a86694 in _dispatch_Block_copy () #6 0x34a8894e in dispatch_group_async$VARIANT$up () #7 0x39613c4e in -[GKConnectionInternal connectParticipantsWithConnectionData:withSessionInfo:] () #8 0x32c5e21c in -[GKMatch connectToPeersWithDictionaries:version:sessionToken:cdxTicket:] () #9 0x32c694b2 in __block_global_17 () #10 0x34a8711e in _dispatch_call_block_and_release () #11 0x34a864b6 in _dispatch_client_callout () #12 0x34a87dca in _dispatch_main_queue_callback_4CF$VARIANT$up () #13 0x3246af3a in __CFRunLoopRun () #14 0x323ddebc in CFRunLoopRunSpecific () #15 0x323ddd48 in CFRunLoopRunInMode () #16 0x3a1db2ea in GSEventRunModal () #17 0x39c992f8 in UIApplicationMain () #18 0x0009f370 in main () </code></pre> <p>None of these are from my now code.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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