如何在iphone中的URL中传递PickerValue

时间:2011-10-12 12:43:05

标签: iphone uipickerview nsurl

arrayNo = [[NSMutableArray alloc] init];             //pickerview radius array
//[arrayNo addObject:@" Radius "];

[arrayNo addObject:@" 10 "];
[arrayNo addObject:@" 15000 "];
[arrayNo addObject:@" 20000 "];
[pickerView selectRow:1 inComponent:0 animated:NO];
[addressField resignFirstResponder];
radius.text= [arrayNo objectAtIndex:[pickerView selectedRowInComponent:0]];

我想在半径

的以下网址中传递上述半径选择器
NSString *url = [NSString stringWithFormat:@"http://.............../phpsqlsearch_genxml.php?lat=%f&lng=%f&radius=%f",lati,longi,radius];

我尝试在按钮点击事件上使用以下代码但不能正常工作。

NSString * radius = [[[NSString alloc] initWithFormat:@"%f",[arrayNo objectAtIndex:[pickerView selectedRowInComponent:0]]]autorelease];

我应该为同样的代码编写什么代码...提前感谢

1 个答案:

答案 0 :(得分:0)

您可以将代码更改为

float radius = [arrayNo objectAtIndex:[pickerView selectedRowInComponent:0]] floatValue];
NSString *url = [NSString stringWithFormat:@"http://.............../phpsqlsearch_genxml.php?lat=%f&lng=%f&radius=%f",lati,longi,radius];

而且,您不需要最后一行NSString * radius = ...