objective-c - 为什么我不能访问这个指针的值。目标c
问题描述
我想访问YGNodeRef node
RCTMeasure 函数的参数。这是来自 react-native 中的瑜伽文件,RCTShadowText.m
static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode
widthMode, float height, YGMeasureMode heightMode)
{
RCTShadowText *shadowText = (__bridge RCTShadowText *)
YGNodeGetContext(node);
NSTextStorage *textStorage = [shadowText buildTextStorageForWidth:width
widthMode:widthMode];
[shadowText calculateTextFrame:textStorage];
NSLayoutManager *layoutManager = textStorage.layoutManagers.firstObject;
NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
CGSize computedSize = [layoutManager
usedRectForTextContainer:textContainer].size;
YGSize result;
result.width = RCTCeilPixelValue(computedSize.width);
if (shadowText->_effectiveLetterSpacing < 0) {
result.width -= shadowText->_effectiveLetterSpacing;
}
result.height = RCTCeilPixelValue(computedSize.height);
return result;
}
YGNodeRef 在另一个名为 Yoga.h 的类中被删除。
typedef struct YGNode *YGNodeRef;
我可以在调试器中看到 的值YGNodeRef node
,但我不知道如何在代码中访问它的元素。内容如下所示:
(YGNodeRef) 0x150094a00
> style (YGStyle)
> layout (YGLayout)
lineIndex = (uint32_t) 0
> parent = (YGNodeRef) 0x15009e200
..... etc .....
> context
我想访问“上下文”子项以检查它是否为空,非常感谢一些帮助。或者,如果您只是知道为什么上下文为 null 的原因,这也会对我有所帮助:)
我是 Objective C 的新手,所以我的逻辑可能有缺陷。
解决方案
推荐阅读
- php - PHP strtotime 不使用 mysql 值执行类似的转换
- wordpress - TinyMCE 是否允许不可变实体(CKEditor 的“小部件”功能的对应物)?
- mysql - 内连接没有匹配的列
- javascript - 回调函数抛出错误
- java - ArrayAdapter 中的 getView() 表示第 1 行是位置 0 而不是正确的位置 1
- laravel - Eloquent 关系数据透视表与 3 模型
- ios - 重新启动应用程序 swift 4 时,UserDefaults 有时不保留保存的值
- r - 如何在表格中构造 Web 数据
- python - Linux 上 VSCode 中 Python 的 VSCode-Python 大纲视图不起作用
- c# - 列表
> 使用 linq 操作数据