App delegate is nil in cocos2d-x v2.2?

Appcontroller * appDelegate = [[UIApplication sharedApplication]delegate];

but appDelegate is nil, Why?

Here is for C++ talk. Maybe you can post at www.cocos2d-iphone.org/‎.

Thanks Changjun,

But i need to get the appDelegate in a cocos2d-x ios project to access some function provided by ios,
Does a cocos2d-x ios project only need C++ , but no objective-c part?

Surely there exits platform relative part. But i am not a objective-c dev. Sorry can’t help.
Jason Lee wrote:

Thanks Changjun,
>
But i need to get the appDelegate in a cocos2d-x ios project to access some function provided by ios,
Does a cocos2d-x ios project only need C++ , but no objective-c part?

did you use it in cocos2d-x? which oc code is default.

Yes, I create a project with create_project.py in cocos2d-x v2.2, and compile in xcode 5.01, I just can not get the app delegate in the oc code, and [UIApplication shareApplication] returns nil in didFinishLaunchingWithOptions.
However, if i create a brandnew ios project with xcode 5.01, [[UIApplication sharedApplication]delegate] works prety well.

Set Compiler C Flags of Debug to O0 solve this problem.

Thanks:D