3

I have a text view in which I want to display NSArray *result as text of the text view.

For eg:

result={@"home",@"Office",@"Park",@"Market",nil};

textView text should be:

home
office
park
market

3 Answers 3

3
for(int i =0 ; i <[Array Count] ;i++)
{
  self.textView.text = [NSString stringWithFormat:@"%@ %@",self.textView.text, Array objectAtIndex:i];
}

Correct any spelling mistake.

Sign up to request clarification or add additional context in comments.

Comments

2

You can use componentsJoinedByString: method, like this:

NSString *text = [result componentsJoinedByString:@" "];

You can use a different separator instead of @" ".

Comments

0

You can use a for loop as such:

NSString *str =@"";

for (NSString *tmp in result) {
    str = [NSString stringWithFormat:@"%@ %@",str,tmp];
}

If you want each entry on a new line replace the space with "\n".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.