尽管我已经做了很多尝试..我无法将 NSArray 中的项目正确显示到 UILabel 中..
当我 NSLog 数组时,控制台会返回这个:
2013-01-19 14:34:32.799 bloom[2766:c07] (
"0.877"
)
这是我从网站获取并解析等的值。
问题是,当我在 UILabel 中显示它时,它显示的内容完全相同,我只需要显示不带引号的值。这是它的显示方式:
编辑:
这是我的代码:
- (void)configureView
{
// Update the user interface for the detail item.
if (self.detailItem) {
for (NSDictionary *valuesDatum in _detailItem) {
NSDictionary *itemAtIndex = (NSDictionary *)_detailItem;
self.title = [itemAtIndex objectForKey:@"SYMBOL"];
NSString *strUrl = @"http://www.bloomberg.com/quote/";
NSString *ativo = [itemAtIndex objectForKey:@"SYMBOL"];
NSString *consulta = [strUrl stringByAppendingString:ativo];
NSURL *url = [NSURL URLWithString:consulta];
NSData *webData = [NSData dataWithContentsOfURL:url];
NSString *xPathQuery = @"//span[@class=' price'] | //span[@class=' trending_up up'] | //span[@class=' trending_up up']/span | //table[@class='snapshot_table']/tr/td";
TFHpple *parser = [TFHpple hppleWithData:webData isXML:NO];
NSArray *array = [parser searchWithXPathQuery:xPathQuery];
valores = [[NSMutableArray alloc]init];
for (TFHppleElement *element in array) {
[valores addObject:[[element firstChild] content]];
}
novosValores = [[NSMutableArray alloc]init];
for (NSString *valuesDatum in valores) {
NSString *removeNewLine = [[valuesDatum componentsSeparatedByCharactersInSet: [NSCharacterSet newlineCharacterSet]] componentsJoinedByString:@" "];
NSString *removeSpace = [removeNewLine stringByReplacingOccurrencesOfString:@" " withString:@""];
NSString *removeSpaceOne = [removeSpace stringByReplacingOccurrencesOfString:@" " withString:@""];
NSString *trocaVirgulaPonto = [removeSpaceOne stringByReplacingOccurrencesOfString:@"," withString:@"."];
[novosValores addObject:trocaVirgulaPonto];
}
valoresFinais = [[NSMutableArray alloc]init];
for (NSString *valuesDatum in novosValores) {
NSArray *val = [valuesDatum componentsSeparatedByString:@" - "];
[valoresFinais addObject:val];
}
infos = [[NSMutableArray alloc]init];
for (NSArray *dados in valoresFinais) {
NSArray *arrayDados = [[NSArray alloc]initWithArray:dados];
for (NSString *teste in arrayDados) {
NSArray *arrayTeste = [teste componentsSeparatedByString:@","];
[infos addObject:arrayTeste];
}
}
NSLog(@"%@",[infos objectAtIndex:0]);
NSString *fff = [[NSString alloc] initWithFormat:@"%@", [infos objectAtIndex:0]];
[_detailDescriptionLabel setText:fff];
}
}
}
新编辑:
我有这个数组:
2013-01-19 15:43:05.055 bloom[3564:c07] (
"7.730",
"0.020",
"0.26%",
"7.750",
"7.650-7.800",
"2.333.100",
"7.710",
"3.730-8.810",
"+4.04%"
)
我只需要一个新数组,其中第 5 行和第 8 行的数据用“-”分隔。
所以有人有灯吗??
谢谢!!!