简体   繁体   中英

Get NSBundle in release mode

I'm new in iOS Programming and I need help with a problem.

If edit scheme to run in release configuration when I access to mainBundle function of NSBundle, this function return nil.

In debug mode working properly.

NSBundle* bundle = [NSBundle mainBundle];

Thanks


UPDATE

I've found the problem, in release mode every log prints to nil but work properly.

I'm a Net developer and in Visual Studio this work different.

Thanks

I was facing the same problem today.

Turned out it is to do with Optimzation Level for release mode. If you change the build settings to None (no optimisation), then it will be working as expected.

Wrote a post on the pitfall: http://samwize.com/2015/03/03/pitfall-release-scheme-optimizes-code/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM