我创建了这个方法来只删除字符串末尾的空格而不是开头,虽然它完美地返回了字符串并完成了我需要的操作,但 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)];
}