EXC_BAD_ACCESS与GCM 3.0

时间:2015-09-10 05:38:12

标签: ios objective-c google-cloud-messaging cocos2d-x cocos2d-x-3.0

我试图将GCM v3集成到cocos2d-x v3.6项目中,经过几天的使用CocoaPods和Xcode,我终于能够构建应用程序。但是,当部署在设备上进行测试时,它会在调用[[GGLInstanceID sharedInstance] tokenWithAuthorizedEntity:_gcmSenderID scope:kGGLInstanceIDScopeGCM options:_registrationOptions handler:_registrationHandler]时因错误EXC_BAD_ACCESS而崩溃。是什么给了什么?

屏幕截图:http://i.imgur.com/s0HnxTp.png

我的配置如下:

  

daffodilistic$ pod --version 0.39.0.beta.4 daffodilistic$ cat Podfile platform :ios, '8.1' source 'https://github.com/CocoaPods/Specs.git' target 'project-redacted iOS' do pod 'Google/CloudMessaging' end target 'project-redacted Mac' do end

1 个答案:

答案 0 :(得分:1)

我成功地调试并成功解决了异常 - 显然,它是由NULL0x00000000值引起的,@property(nonatomic, retain) void (^registrationHandler)(^registrationHandler)值是由- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 块属性指定的- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken 3}}。至于是否是Xcode,iOS或cocos2d-x导致块声明被解除引用/解除分配,我不确定。

解决方案是从

移动var viewer = Ti.UI.iOS.createDocumentViewer({ url: "sample.pdf" }); viewer.show(); Google's sample GCM v3 code for iOS
  public void popUp(){
        final LayoutInflater layoutInflater = LayoutInflater.from(Record.this);

        final View promptView = layoutInflater.inflate(R.layout.input_language, null);
        final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Record.this);
        alertDialogBuilder.setView(promptView);

        String[] languages = {"Arabic","Bulgarian","Catalan"};

        ListView list = (ListView) promptView.findViewById(R.id.inputlang);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, languages);
        list.setAdapter(adapter);

        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position,
                                    long id) {

                String from_language = ((TextView)view).getText().toString();
                Toast.makeText(getBaseContext(), from_language, Toast.LENGTH_LONG).show();

                // CLOSE POPUP WINDOW
            }
        });

        // setup a dialog window
        alertDialogBuilder.setCancelable(false)
                .setNegativeButton("Cancel",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                            }
                        });

        // create an alert dialog
        AlertDialog alert = alertDialogBuilder.create();
        alert.show();
    }

function reconvert($array,$del,$path=array()){
    $string="";
    foreach($array as $key=>$val){
        if(is_string($val) || is_numeric($val)){
            $string.=implode($del,$path).$del.$key.$del.$val."\n";
        } else if(is_bool($val)){
            $string.=implode($del,$path).$del.$key.$del.($val?"True":"False")."\n";
        } else if(is_null($val)){
            $string.=implode($del,$path).$del.$key.$del."NULL\n";
        }else if(is_array($val)=='array') {
            $path[]=$key;
            $string.=reconvert($val,$del,$path);
            array_pop($path);
        } else {
            throw new Exception($key." has type ".gettype($val).' which is not a printable value.');
        }
    }
    return $string;
}

相关的SO链接很有用,但不是很重要:block declaration