2010-09-23 53 views
-1

特定對象,我有這些詞不規則空間如何刪除陣列iPhone的SDK

"gbpjpy buy 132.00/15 131.95 update close at 132.40 close at 132.40 120+ gbpjpy buy 132.00/15 131.50 45 new 90 120+  gpbusd buy update HIT 40 PIPS HIT 110 PIPS gpbusd buy BREAK EVEN update HIT 100+ gpbusd buy 1.5500/25 1.5455 new 40 100+ gpbusd buy update CLOSE 0 TO 10 PIPS N gpbusd buy 1.5335/50 1.5320 new 40 80+ gpbusd buy update  15-20 PIPS CLOSE KEEP OPEN gpbusd buy 1.5530/50  1.5505 update HIT 80 KEEP OPEN gpbusd buy 1.5530/50 1.5465 new 40 80 100+" 

在此字符串也有不規則的空間?有誰能夠告訴正確的方法來消除這些空間之間的字符串?

+0

可以重新格式化您的請求...... – 2010-10-21 07:13:35

+0

對於複雜問題感到抱歉 – 2011-02-03 07:02:00

+0

我的主要問題是保持特定的東西,像不規則空間,符號等等來自一個字符串 – 2011-02-03 08:31:11

回答

5

,或者你可以做到這一點也[yourArray removeObjectAtIndex:index]; 看的NSArrayNSMutableArray的頭文件。

5
[yourArray removeObject:@"object"]; 

yourArray必須muttable

0

我自己找到了答案可能,這將有助於行吟詩人rpeople太:我的問題有代碼項目之間的不規則空間,這將刪除所有的空格和存放物品的排列

NSString *[email protected]"mango  apple banana grapes pineapple"; 
    NSRange match; 

    arr=[[NSMutableArray alloc]init]; 


while(str.length>0) 
{ 
match = [str rangeOfString: @" "]; 
    if(match.location>=str.length) 
    { 
     [arr addObject:str]; 
     break; 
    } 
NSString *str2=[str substringToIndex:match.location]; 
str=[str substringFromIndex:match.location+1]; 
    if(str2.length==0) 
    { 
     continue; 
    } 
[arr addObject:str2]; 
} 
NSLog(@"array is %@",arr); //here is your array