gpt4 book ai didi

ios7 - Zombie in Game Center 的 [addPlayersToMatch] 在一个 20-liner 项目中

转载 作者:行者123 更新时间:2023-12-04 15:23:04 25 4
gpt4 key购买 nike

我受不了僵尸了。 findMatchForRequest: 不适合一致的配对,因此使用 [addPlayersToMatch:matchRequest:completionHandler:] 大概 崩溃:

-[__NSMallocBlock__ intValue]: unrecognized selector sent to instance
-[CFString retain]: message sent to deallocated instance // NSZombieEnabled

下面是迟早会崩溃的整个“最小工作示例”项目 ( on Dropbox )。

@implementation GameCenterHelper { GKMatch* _currentMatch; }
+ (GameCenterHelper *)sharedInstance {
static GameCenterHelper* sharedHelper;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^ {
sharedHelper = [GameCenterHelper new];
});
return sharedHelper;
}
- (void)authenticateLocalPlayer {
[GKLocalPlayer localPlayer].authenticateHandler = ^(UIViewController *loginViewController, NSError *error) {
[self findMatch];
};
}
- (void)findMatch {
GKMatchRequest *request = [GKMatchRequest new];
request.minPlayers = 2;
request.maxPlayers = 4;
[[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error) {
_currentMatch = match;
_currentMatch.delegate = self;
}];
}
- (void)addPlayersToMatch {
GKMatchRequest *request = [GKMatchRequest new];
request.minPlayers = 2;
request.maxPlayers = 4;
[[GKMatchmaker sharedMatchmaker] addPlayersToMatch:_currentMatch matchRequest:request completionHandler:nil];
}
- (void)match:(GKMatch *)match player:(NSString *)playerID didChangeState:(GKPlayerConnectionState)state {
[self addPlayersToMatch];
}
@end

我是否遗漏了 block 内存管理的一些基本知识?上面的内容被调用:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[GameCenterHelper sharedInstance] authenticateLocalPlayer];
return YES;
}

这里没有错误处理,必须在 iTunesConnect 上创建一个模型应用程序体验崩溃,否则没有 GKMatch 被返回。我还确保 Xcode 和 iTunesConnect 之间的 bundle 版本一致,即 1.01.0.0

痕迹

Instruments 中的僵尸: enter image description here

Instruments 中每个 Event Type 的堆栈跟踪(MallocReleaseZombie ):

MallocRefCt 1:

   0 libsystem_malloc.dylib malloc_zone_malloc
1 CoreFoundation _CFRuntimeCreateInstance
2 CoreFoundation __CFStringCreateImmutableFunnel3
3 CoreFoundation CFStringCreateCopy
4 CoreFoundation _CFStringCreateWithFormatAndArgumentsAux
5 Foundation -[NSPlaceholderString initWithFormat:locale:arguments:]
6 Foundation -[NSString initWithFormat:]
7 GameKitServices -[GKConnectionInternal connectParticipantsWithConnectionData:withSessionInfo:]
8 GameCenterFoundation -[GKMatch connectToPeersWithDictionaries:version:sessionToken:cdxTicket:]
9 GameCenterFoundation __104-[GKMatchmaker matchWithRequest:currentMatch:currentPlayerIDs:serverHosted:rematchID:completionHandler:]_block_invoke_2
10 CoreFoundation __invoking___
11 CoreFoundation -[NSInvocation invoke]
12 GameCenterFoundation -[NSInvocation(GKProxyHelpers) _gkInvokeOnce]
13 GameCenterFoundation __53-[GKDaemonProxy connection:handleInvocation:isReply:]_block_invoke
14 libdispatch.dylib _dispatch_call_block_and_release
15 libdispatch.dylib _dispatch_client_callout
16 libdispatch.dylib _dispatch_main_queue_callback_4CF
17 CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
18 CoreFoundation __CFRunLoopRun
19 CoreFoundation CFRunLoopRunSpecific
20 CoreFoundation CFRunLoopRunInMode
21 GraphicsServices GSEventRunModal
22 UIKit UIApplicationMain
23 GameCenterBug main /Volumes/Lion2/Developer/Objective-C/GameCenterBug/GameCenterBug/main.m:7
24 libdyld.dylib start

发布RefCt 0:

   0 CoreFoundation -[__NSCFString release]
1 GameKitServices -[GKConnectionInternal connectParticipantsWithConnectionData:withSessionInfo:]
2 GameCenterFoundation -[GKMatch connectToPeersWithDictionaries:version:sessionToken:cdxTicket:]
3 GameCenterFoundation __104-[GKMatchmaker matchWithRequest:currentMatch:currentPlayerIDs:serverHosted:rematchID:completionHandler:]_block_invoke_2
4 CoreFoundation __invoking___
5 CoreFoundation -[NSInvocation invoke]
6 GameCenterFoundation -[NSInvocation(GKProxyHelpers) _gkInvokeOnce]
7 GameCenterFoundation __53-[GKDaemonProxy connection:handleInvocation:isReply:]_block_invoke
8 libdispatch.dylib _dispatch_call_block_and_release
9 libdispatch.dylib _dispatch_client_callout
10 libdispatch.dylib _dispatch_main_queue_callback_4CF
11 CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
12 CoreFoundation __CFRunLoopRun
13 CoreFoundation CFRunLoopRunSpecific
14 CoreFoundation CFRunLoopRunInMode
15 GraphicsServices GSEventRunModal
16 UIKit UIApplicationMain
17 GameCenterBug main /Volumes/Lion2/Developer/Objective-C/GameCenterBug/GameCenterBug/main.m:7
18 libdyld.dylib start

ZombieRefCt -1:

   0 CoreFoundation ___forwarding___
1 CoreFoundation _CF_forwarding_prep_0
2 libsystem_blocks.dylib _Block_object_assign
3 GameKitServices __copy_helper_block_355
4 libsystem_blocks.dylib _Block_copy_internal
5 libdispatch.dylib _dispatch_Block_copy
6 libdispatch.dylib dispatch_group_async
7 GameKitServices -[GKConnectionInternal connectParticipantsWithConnectionData:withSessionInfo:]
8 GameCenterFoundation -[GKMatch connectToPeersWithDictionaries:version:sessionToken:cdxTicket:]
9 GameCenterFoundation __104-[GKMatchmaker matchWithRequest:currentMatch:currentPlayerIDs:serverHosted:rematchID:completionHandler:]_block_invoke_2
10 CoreFoundation __invoking___
11 CoreFoundation -[NSInvocation invoke]
12 GameCenterFoundation -[NSInvocation(GKProxyHelpers) _gkInvokeOnce]
13 GameCenterFoundation __53-[GKDaemonProxy connection:handleInvocation:isReply:]_block_invoke
14 libdispatch.dylib _dispatch_call_block_and_release
15 libdispatch.dylib _dispatch_client_callout
16 libdispatch.dylib _dispatch_main_queue_callback_4CF
17 CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
18 CoreFoundation __CFRunLoopRun
19 CoreFoundation CFRunLoopRunSpecific
20 CoreFoundation CFRunLoopRunInMode
21 GraphicsServices GSEventRunModal
22 UIKit UIApplicationMain
23 GameCenterBug main /Volumes/Lion2/Developer/Objective-C/GameCenterBug/GameCenterBug/main.m:7
24 libdyld.dylib start

相同的 ARC 前问题(答案可疑):-[CFString retain]: message sent to deallocated instance 0x215076c0

相关:

最佳答案

就在几个小时前,Apple 表示该错误已得到修复,并将在下一个 iOS 版本中进行修复。

关于ios7 - Zombie in Game Center 的 [addPlayersToMatch] 在一个 20-liner 项目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22258040/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com