Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

andyiapan

macrumors newbie
Original poster
Feb 28, 2010
29
0
if i have NSString *a;
a[0] = @"hello,";
a[1] = @"i am peter,";
a[2] = @"how are you?";

how can i display all text in Label.text?

Label.text = a[0] + a[1] + a[2];

Output:
hello,i am peter,how are you?
in Label

THXXXX
 
I think you are confused. NSString *a should be pointing at a single NSString object. Not at an array of NSStrings.
 
Thx yr suggestion, i want to use a for loop, but still can't find the solution:(

for(int i = 0; i < 3; i++)
XX = XX + a;
label1.text = XX
 
You cannot combine NSString objects with the + operator. This is not Java with dodgy special-case overrides for one type of object. Open the NSString documentation and search for append methods...
 
You will want to look at the string appendwithformat methods that is contained in the NSString class.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.