如何以从左到右的格式将 NSMutable 数组打印到 UILabel 中,并在对象之间包含间距?
我有一个计算器,在它的控制器中我有一个存储对象的 NSMutable 数组。它是一个 RPN 计算器,例如,如果我输入 357(按 Enter)、589(按操作键 +),则对象将以以下格式推入数组中: NSMutableArray *completeOperations([0]:357, [1]:589 ,[2]:+) - 不确定这在语法上是否正确,但我只是想传达这个想法。所以我想做的就是将此数组打印到 UILabel 中,属性:fullPerformDisplay,格式为 357 589 + =。如图所示,当我打印对象时,我需要在对象之间添加空格,并且需要以从左到右的格式打印。
I have a calculator and in its controller i have a NSMutable array which stores objects. It's a RPN calculator so for example if I type 357 (Hit Enter), 589 (Hit operation key +), then objects are pushed into the array in this format: NSMutableArray *completeOperations([0]:357, [1]:589, [2]:+) - not sure if this is syntactically correct but I'm just trying to get the idea across. So what I want to do is print this array into the UILabel, property: fullPerformDisplay, in the format 357 589 + =. As shown I need to add spaces in between the objects when I print them and it need to print in a left to right format.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果它们在数组中,您可以连接数组的组件并使用 [NSArray ComponentsJoinedByString:] 将其转换为字符串
If they are in an array you can join the components of an array and convert it to a string with [NSArray componentsJoinedByString:]