当我扫描条形码和我得到一些值,如果它等于= 2然后我需要==显示,并且如果它等于= 3然后我需要=并且如果该值是4,则无效显示量。
但扫描的条形码是整数值-当使用解码NSASCII
它仅仅显示直到值127
,它是显示无效的结果之后。 例如:如果我的条形码值= 9699
的结果值= jem
然后我的相加结果值= jem=
actualstring值= %å
ASC值id仅示出37
这里是我的代码:
- (void) readerView:(ZBarReaderView *)view didReadSymbols:(ZBarSymbolSet *)syms fromImage:(UIImage *)img
{
// do something useful with results -- cool thing is that you get access to the image too
for (ZBarSymbol *symbol in syms) {
[resultsBox setText:symbol.data];
if ([resultsBox.text length] == 2) {
addedresult.text = [resultsBox.text stringByAppendingString:@"=="];
} else if ([resultsBox.text length] == 3) {
addedresult.text = [resultsBox.text stringByAppendingString:@"="];
} if ([resultsBox.text length] >= 4) {
addedresult.text = @"Invalid";
}
[Base64 initialize];
NSString *myString = [[NSString alloc]initWithString:addedresult.text];
NSData * data = [Base64 decode:myString];
NSString * actualString = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@"%@",actualString);
labeltext.text= actualString;
int asc = [actualString characterAtIndex:0];
label.text = [NSString stringWithFormat:@"%d", asc];
[actualString release];
break;
}
}