How to get the contents of an array to display on a uitextfield

浪尽此生 提交于 2019-12-13 20:36:42

问题


I'm trying to get the contents of an array to display on a uitextfield.

here's my code:

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

NSString * resultConditions = [arrayConditions description];

// conditionsDeal is the uitextfield self.conditionsDeal.text = resultConditions;

conditions are being pulled from a url like this:

"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",

Currently the only thing that displays in my uitextview is:

I need to remove the ( ( ) ) parentheses and format it neatly.

thanks for any help


回答1:


You want to join all the strings in the array like this:

self.conditionsDeal.text = [arrayConditions[@"conditions"] componentsJoinedByString:@"\n"];



回答2:


string = [string stringByReplacingOccurrencesOfString:@"}" withString:@""];
string = [string stringByReplacingOccurrencesOfString:@"{" withString:@""];
string = [string stringByReplacingOccurrencesOfString:@"\n" withString:@""];
string = [string stringByReplacingOccurrencesOfString:@"  " withString:@" "];


来源:https://stackoverflow.com/questions/14341256/how-to-get-the-contents-of-an-array-to-display-on-a-uitextfield

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!