这是我的NSMutableArray
。它包含位置15的空格。当我将其存储在另一个NSMutableArray
中时,它会给出一个空值。
如何在该特定位置删除阵列中的这个空间?
(
12027,
31100,
27/02/2014,
4:00AM,
Infosys,
Seonc item_shilpa,
Client Visit,
1,
Tech,
Shilpa Test,
Scheduled,
0,
0,
Anushka,
3:15,
Service Title: 2338Service Type: One Time
,
Mysore
)
答案 0 :(得分:2)
试试这可能会对你有所帮助
NSCharacterSet *charsToTrim = [NSCharacterSet characterSetWithCharactersInString:@"() \n\""];
s = [s stringByTrimmingCharactersInSet:charsToTrim];
答案 1 :(得分:1)
试试这个
NSString *str=[arrMessage objectAtIndex:index];
str=[str stringByReplacingOccurrencesOfString:@"Srvice Title" withString:@"SrviceTitle"];
答案 2 :(得分:1)
NSString *string=[yourArray objectAtIndex:15];
NSCharacterSet *charsToTrim = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSString *newString = [string stringByTrimmingCharactersInSet:charsToTrim];
[yourArray replaceObjectAtIndex:15 withObject:newString];
答案 3 :(得分:1)
customerDetails=[customerDetails1 stringByReplacingOccurrencesOfString:@"\n" withString:@""];
此处customerDetails1
将数组转换为字符串。
customerDetails
是存储结果字符串的另一个字符串。
这对我有用。
答案 4 :(得分:0)
试试这个,
NSMutableArray *array = [[NSMutableArray alloc] init];
[yourArray enumerateObjectsUsingBlock:^(NSString *element, NSUInteger idx, BOOL *stop) {
element = [element stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[array addObject:element];
}];