如何在 iPhone 应用程序中的 mutableArray 中将三个对象添加到一个对象中?

发布于 2024-12-27 03:28:58 字数 342 浏览 2 评论 0原文

NSMutableArray * mutableArra = [[NSMutableArray alloc] init];
[mutableArra addObjectsFromArray:myArray];
NSLog(@"=====mutable aarrya ====::%@",mutableArra);

这是前面代码的结果:

2012年12月1日

如何将这三个对象添加到一个对象中,如下所示?

2012年1月12日

预先感谢您。

NSMutableArray * mutableArra = [[NSMutableArray alloc] init];
[mutableArra addObjectsFromArray:myArray];
NSLog(@"=====mutable aarrya ====::%@",mutableArra);

This is the result from the previous code:

01,12,2012

How can I add these three objects into one like the following?

01-12-2012

Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

在风中等你 2025-01-03 03:28:58

我不确定你想如何将这些可怜的对象“添加”到彼此,但如果你希望它们作为字符串连接起来,请尝试:

NSString *result = [myArray componentsJoinedByString:@"-"];

I'm not sure how do you want to "add" those poor objects to one another, but if you want them to be concatenated as a string, try:

NSString *result = [myArray componentsJoinedByString:@"-"];
挽清梦 2025-01-03 03:28:58

如果这是针对日期的,我建议您查看 NSDate,它会为您进行格式化。

If this is for dates, I would recommend looking into NSDate which will do the formatting for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文