A andyiapan macrumors newbie Original poster Mar 2, 2010 #1 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
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
robbieduncan Moderator emeritus Mar 2, 2010 #2 I think you are confused. NSString *a should be pointing at a single NSString object. Not at an array of NSStrings.
I think you are confused. NSString *a should be pointing at a single NSString object. Not at an array of NSStrings.
A andyiapan macrumors newbie Original poster Mar 2, 2010 #3 if i declare NSString *a[10]; can i do that?
robbieduncan Moderator emeritus Mar 2, 2010 #4 If you really want to. I would suggest you look at the NSString documentation for appending them: + won't work.
If you really want to. I would suggest you look at the NSString documentation for appending them: + won't work.
A andyiapan macrumors newbie Original poster Mar 2, 2010 #5 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
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
robbieduncan Moderator emeritus Mar 2, 2010 #6 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 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...
KoolStar macrumors demi-god Mar 2, 2010 #7 You will want to look at the string appendwithformat methods that is contained in the NSString class.
You will want to look at the string appendwithformat methods that is contained in the NSString class.
A andyiapan macrumors newbie Original poster Mar 2, 2010 #8 THanks bro, i use appendwithformat methods and it's worked😱