Xcode 4.6 ARC Warning for Game Center Authentication

后端 未结 2 614
失恋的感觉
失恋的感觉 2021-02-14 07:33

This is a new compiler warning that only showed up when I updated XCode to 4.6. My code is lifted directly from Apple\'s documentation (this is my iOS 6 code btw).

2条回答
  •  臣服心动
    2021-02-14 08:17

    The compiler is just helping you out with code that was already a problem, it just didn't know about it before.

    You can read about retain cycles here: http://www.cocoawithlove.com/2009/07/rules-to-avoid-retain-cycles.html

    Basically you just need to change your code to something like:

    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
    
    __weak MyViewController *blockSelf = self;
    localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error) {
        [blockSelf setLastError:error];
        if(localPlayer.authenticated){
    

提交回复
热议问题