Reputation: 180
I am using [cell.textLabel setText: title]; which is working great, but i would like to add a few more in the same cell.
For example:
[cell.textLabel setText: title];
[cell.textLabel setText: venue];
[cell.textLabel setText: offer];
[cell.textLabel setText: title];
[cell.textLabel setText: venue];
[cell.textLabel setText: offer];
[cell.textLabel setText: title];
[cell.textLabel setText: venue];
[cell.textLabel setText: offer];
etc etc
But of course, this just overwrites the previous. So i just get the 'offer' in each cell.
How is something like this done? Please keep in mind, this is my very first app, one step up from 'hello world', so forgive me if this this seems a stupid question :)
thanks,
Upvotes: 0
Views: 259
Reputation: 180
Thanks for the info @Bhumeshwer katre ... Teach a man to fish. :)
I recommend anyone who stumbles on this question to follow this link, very easy to do and you will learn lots, if your a beginner like myself: http://www.appcoda.com/customize-table-view-cells-for-uitableview/
Upvotes: 0
Reputation: 13783
You can combine strings like this:
NSString *celltext;
celltext = title;
celltext = [celltext stringByAppendingString:@" "];
celltext = [celltext stringByAppendingString:venue];
celltext = [celltext stringByAppendingString:@" "];
celltext = [celltext stringByAppendingString:offer];
[cell.textLabel setText: celltext];
Alternative solution:
NSString *celltext;
celltext = [celltext stringByAppendingFormat:@"%@ %@ %@", title, venue, offer];
[cell.textLabel setText: celltext];
Upvotes: 1