读取位置 0xCDCDCDCD 时发生访问冲突

#include “HelloWorldScene.h”

USING_NS_CC;

Scene* HelloWorld::createScene()
{
// ‘scene’ is an autorelease object
auto scene = Scene::create();

// 'layer' is an autorelease object
auto layer = HelloWorld::create();

// add layer as a child to scene
scene->addChild(layer);

// return the scene
return scene;

}

// on “init” you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}

visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
srand(time(NULL)); 
theRandomNum = rand()%100;

log("The random num is %d", theRandomNum);

buildUI();
addListeners();
return true;

}
void HelloWorld::buildUI(){
auto label = Label::create();
label->setString(“Please input a number between 0-100”);
addChild(label);
label->setPosition(visibleSize.width / 2, visibleSize.height - label->getContentSize().height / 2 - 20);
tf = TextFieldTTF::textFieldWithPlaceHolder(“Input number here”, “Courier”, 16);
tf->setPosition(visibleSize.width / 2, label->getPositionY() - 50);
addChild(tf);
auto submitBtn = Label::create();
submitBtn->setPosition(visibleSize.width / 2, tf->getPositionY() - 50);
submitBtn->setString(“Submit”);
addChild(submitBtn);
}
void HelloWorld::addListeners(){

auto director = Director::getInstance();
auto handler = (Touch* t, Event *e){
    auto target = e->getCurrentTarget();
    auto point = t->getLocation();
    if (target->getBoundingBox().containsPoint(point)){
        if (target == tf){
            tf->attachWithIME();
        }
        else if (target==submitBtn){
            tf->detachWithIME();
            log("submit");
        }
    
    }
    else{
        tf->detachWithIME();
    
    }
    return false;
};

auto l = EventListenerTouchOneByOne::create();
l->onTouchBegan = handler;

/*director->getEventDispatcher()->
    addEventListenerWithSceneGraphPriority(l, tf);

*/
auto submitBtnClickListener = EventListenerTouchOneByOne::create();
submitBtnClickListener->onTouchBegan = handler;

//director->getEventDispatcher()->
//    addEventListenerWithSceneGraphPriority(submitBtnClickListener, submitBtn);

}
void HelloWorld::menuCloseCallback(Ref* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
MessageBox(“You pressed the close button. Windows Store Apps do not implement a close button.”,“Alert”);
return;
#endif

Director::getInstance()->end();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}
本来是不报错的,但是加上这两句之后就报错了,
/*director->getEventDispatcher()->
addEventListenerWithSceneGraphPriority(l, tf);
*/
但是对着视频看了好几遍,就是这样做的啊,,,求大神帮看看