0
我創建此方法時,只從字符串的末尾刪除空格,而不是開頭,而它完美地返回字符串,並執行我所需的操作,xcode接口告訴我「表達式結果未使用「在」for(lengthofthestring; lengthofthestring> 0; lengthofthestring--)「行,可以任何人告訴我爲什麼,在我撕下我所有的頭髮!謝謝。 但它運行良好,(我不想從商店任何麻煩)在字符串方法中未使用的表達式結果
繼承人的代碼...
-(NSString *)removeEndSpaceFrom:(NSString *)strtoremove{
NSUInteger location = 0;
NSUInteger lengthofthestring = [strtoremove length];
unichar charBuffer[lengthofthestring];
[strtoremove getCharacters:charBuffer];
////////////// right here on the next line is where i'm getting the Expression result unused !!!
for (lengthofthestring ; lengthofthestring > 0; lengthofthestring--) {
if (![[NSCharacterSet whitespaceCharacterSet] characterIsMember:charBuffer[lengthofthestring - 1]]){
break;
}
}
return [strtoremove substringWithRange:NSMakeRange(location, lengthofthestring - location)];
}