0

我试图让数组的内容显示在 uitextfield 上。

这是我的代码:

NSArray *arrayConditions = [[NSArray alloc] initWithObjects:[item objectForKey:@"conditions"], nil];

NSString * resultConditions = [arrayConditions description];

// conditionsDeal 是 uitextfield self.conditionsDeal.text = resultConditions;

条件是从这样的 url 中提取的:

"results": [
{
  "conditions": [
    "Il coupon è valido per soggiorni fino al...",
    "I coupon sono cumulabili, possibilità...",
    "Coupon non cumulabile con altre promozioni...",
  ],
  "deadline": "2013-11-27T22:59:59.000Z",

目前在我的 uitextview 中显示的唯一内容是:

在此处输入图像描述

我需要删除 ( ( ) ) 括号并将其格式化。

谢谢你的帮助

4

2 回答 2

3

您想像这样连接数组中的所有字符串:

self.conditionsDeal.text = [arrayConditions[@"conditions"] componentsJoinedByString:@"\n"];
于 2013-01-15T15:54:08.620 回答
0
string = [string stringByReplacingOccurrencesOfString:@"}" withString:@""];
string = [string stringByReplacingOccurrencesOfString:@"{" withString:@""];
string = [string stringByReplacingOccurrencesOfString:@"\n" withString:@""];
string = [string stringByReplacingOccurrencesOfString:@"  " withString:@" "];
于 2013-01-15T16:21:00.090 回答