ios - lldb - 如何覆盖字典中的值?
<p><p>所以我正在使用 lldb(无 Xcode)远程调试应用程序,并且我想修改字典中的值。
当我执行 'po $x0' 时,字典看起来像这样:</p>
<pre><code>{
amount = "2.00";
idNumber = 87677;
}
</code></pre>
<p>当我打印 2.00 的“类”时,我得到 NSDecimalNumber
我已经尝试访问它并且只能读取“金额”值:</p>
<pre><code>po [$x0 objectForKey:@"amount"]
2.95
</code></pre>
<p>我希望能够将金额值覆盖为 1.00 -- 我尝试这样做:</p>
<pre><code>e (NSString*)[$x0 objectForKey:@"amount"]
(NSString *) $24 = 0x00000001c2c22180
(lldb) memory write 0x00000001c2c22180 @"1.00"
error: '@1.00' is not a valid hex string value.
(lldb) memory write 0x00000001c2c22180 "1.00"
error: '1.00' is not a valid hex string value.
</code></pre>
<p>如何将 NSdecimal 数字写入“金额”字段?
它不会让我简单地做 $x0[@"amount"] = 1.00
谢谢!</p>
<p>编辑:我也试过这个:</p>
<pre><code>(lldb) p/x 0.10
(NSTaggedPointerString *) $26 = 0xa00000030312e304 @"0.10"
(lldb) memory write 0x00000001c2c22180 0xa00000030312e304
error: Value 0xa00000030312e304 is too large to fit in a 1 byte
unsigned integer value.
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>在 xcode 调试器控制台中设置断点。输入 <code>expr</code> 覆盖一个值。</p>
<p>例如,如果您想将值 (100) 的整数重写为 (200)。</p>
<pre><code>expr integer = 200
</code></pre>
<p>同样你可以用字典来做到这一点:</p>
<pre><code>expr dictionary[@"key"] = @"newvalue"
</code></pre></p>
<p style="font-size: 20px;">关于ios - lldb - 如何覆盖字典中的值?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/51813181/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/51813181/
</a>
</p>
页:
[1]