0

I'm new to Objective-C and I couldn't find a direct solution for my problem where it is explained how to add string behind or in front of an array value . I try to get some text from an array and add some other string behind or infront of it (will be used in tableviewcell). In Android it's working just with + signs, that's why I couldn't handle it here. I try to do something like below:

"some text" +[arrayName objectAtIndex:indexPath.row] + "some text"
0

2 Answers 2

1

You need to use stringWithFormat to concatenate those values, or you can use NSMutableString as well

Use this

NSString* finalText = [NSString stringWithFormat:@"some text %@ some text",[arrayName objectAtIndex:indexPath.row]];

Another way

NSMutableString* finalString = [NSMutableString stringWithString:@"test Text"];
[finalString appendString:[arrayName objectAtIndex:indexPath.row]];
[finalString appendString:@"test Text 2"];
Sign up to request clarification or add additional context in comments.

Comments

0

Short:

[NSString stringWithFormat:@"%@/%@/%@", "some text", [arrayName objectAtIndex:indexPath.row], "some text"];

For further answers see: https://stackoverflow.com/a/510444/9310455

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.