我刚刚将我的代码从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++之间的差异我忽略了的?