我正在尝试将字符串解析为数组,在索引 1 处获取数组的一部分并将该字符串转换为浮点数。我有我的代码,但我收到错误“使用不兼容类型'NSString *_strong'的表达式初始化'float'。帮助!
NSString *csv = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://download.finance.yahoo.com/d/quotes.csv?s=AAPL&f=sl1d1t1c1ohgv&e=.csv"]];
NSArray *array = [csv componentsSeparatedByString: @","];
NSString *price = [array objectAtIndex:1];
[price floatValue];
float currentPrice = price;