我刚刚将我的代码从 Objective-C 切换到 Objective-C++。除了两条线,一切都很顺利。
NSString * text1=[[NSString stringWithFormat:@"%.2f",ymax] UTF8String];
这条线抱怨说
error: cannot convert 'const char*' to 'NSString*' in initialization
与第一个相关的第二个错误来自以下行:
CGContextShowTextAtPoint(context, 2, 8, text1, strlen(text1));
它抱怨说
error: cannot convert 'NSString*' to 'const char*' for argument '1' to 'size_t strlen(const char*)'
在 ObjC 和 ObjC++ 之间的差异中我错过了什么吗?