我需要向object map
添加bool
,我的 CGSize size = CGSizeZero;
if ([label.text respondsToSelector: @selector(boundingRectWithSize:options:attributes:context:)] == YES) {
size = [label.text boundingRectWithSize: constrainedSize options: NSStringDrawingUsesLineFragmentOrigin
attributes: @{ NSFontAttributeName: label.font } context: nil].size;
} else {
size = [label.text sizeWithFont: label.font constrainedToSize: constrainedSize lineBreakMode: UILineBreakModeWordWrap];
}
被定义为基元,我需要将其转换为对象。
我该怎么做?
答案 0 :(得分:0)
您可以将bool转换为jboolean,然后将jboolean列入带有JNI调用的布尔作业,如下所示:
jboolean value = true;
jclass booleanClass = env->FindClass("java/lang/Boolean");
jmethodID methodID = env->GetMethodID(booleanClass, "<init>", "(Z)V", false);
jobject booleanObject = env->NewObject(booleanClass, methodID, value);