String 字符串方法中未使用的表达式结果
我创建这个方法是为了只删除字符串末尾的空白,而不是开头的空白,虽然它完美地返回字符串并执行我需要的操作,但xcode接口在“for(lengthofthestring;lengthofthestring>0;lengthofthestring--)”行中告诉我“表达式结果未使用”,有人能告诉我原因吗,在我把头发都扯下来之前!!!谢谢 但它运行良好,(我不希望商店有任何麻烦) 这是密码String 字符串方法中未使用的表达式结果,string,whitespace,String,Whitespace,我创建这个方法是为了只删除字符串末尾的空白,而不是开头的空白,虽然它完美地返回字符串并执行我需要的操作,但xcode接口在“for(lengthofthestring;lengthofthestring>0;lengthofthestring--)”行中告诉我“表达式结果未使用”,有人能告诉我原因吗,在我把头发都扯下来之前!!!谢谢 但它运行良好,(我不希望商店有任何麻烦) 这是密码 -(NSString *)removeEndSpaceFrom:(NSString *)strtoremove{
-(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)];
}
我这样做了,但我仍然不知道上面的答案
-(NSString *)removeEndSpaceFrom:(NSString *)strtoremove{
NSUInteger location = 0;
unichar charBuffer[[strtoremove length]];
[strtoremove getCharacters:charBuffer];
int i = 0;
for ( i = [strtoremove length]; i >0; i--){
if (![[NSCharacterSet whitespaceCharacterSet] characterIsMember:charBuffer[i - 1]]){
break;
}
}
return [strtoremove substringWithRange:NSMakeRange(location, i - location)];
}