Search code examples
iosobjective-cemailmailcore2mailcore

Why In Mailcore2 Sample the 'MCOMessageView' file is a c++ file instead of objective c one?


I'm checking the source code from mailcore 2 sample demo. The IOS project has a class 'MCOMessageView.mm'. It's a very good helper class with a webview and a few delegates for html rendering. So why use 'mm' as its file extension since it doesn't contain any c++ code.


Solution

  • Some developers, used to deal with ObjC++, use the .mm extension by default for their ObjC class, even if no C++ code is needed, so that they can use ObjC++ later on if needed.

    MailCore uses ObjC++ by default, so .mm extension for class by default even if at their is no C++ code in it at the time, it can be added in the future.

    It as virtually no cost a run time, so it's.. just a way of doing things. And since LVVM, it has but little cost at build time

    Another possibility is that their was C++ in a previous version of the file and, commit after commit, C++ code was replace and they didn't bother renaming the class because they can still add some C++ code in the future and they want to keep their hand free.