2013-03-22 72 views
0

我使用下面的方法,我想添加的內容之間的空間,我的學習,而第二字符串任何想法如何給空間感謝如何將兩個字符串之間給空間,同時concatnating

NSString *firstString [email protected]"Added Contnet To My Learning"; 
NSString *secondString = appDelegate.activity_Description; 
appDelegate.activity_Description = [firstString stringByAppendingString:secondString]; 
+0

http://stackoverflow.com/questions/16579543/how-to-concatenate-two-strings -in-iphone/16579565#16579565 – Rajneesh071 2013-05-16 06:00:26

回答

2

你可以這樣做。

NSString *firstString [email protected]"Added Contnet To My Learning"; 
NSString *secondString = appDelegate.activity_Description; 
appDelegate.activity_Description = [NSString stringWithFormat:@"%@ %@", firstString, secondString]; 
+0

或'[firstString stringByAppendingFormat:@「%@」,secondString];' – JustSid 2013-03-22 11:05:41

0

你嘗試連接兩個字符串?

NSString *firstString [email protected]"Added Contnet To My Learning "; 
// a space after the first string 
0

這裏是所有的方式,你可以用繩子做

//1st Way 
NSString *finalString = [NSString stringWithFormat:@"%@ %@",firstString,secondString]; 

//2nd Way 
NSString *finalString = [firstString stringByAppendingFormat:@" %@",secondString]; 

//3rd way 
NSArray *ary= [NSArray arrayWithObjects:firstString,secondString, nil]; 
NSString *finalString= [ary componentsJoinedByString:@" "]; 

關注這個how to concatenate two strings in iphone

相關問題