Such situation. I have a GET request.
- (IBAction)sendGet:(id)sender { NSString *tmenu = _textFieldGet.text; NSString *urlString = [NSString stringWithFormat:@"http://example.ru/menu.php?tmenu=%@", tmenu]; NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; [theRequest addValue:@"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [theRequest setHTTPMethod:@"GET"]; NSURLConnection *connectionGet = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if(connectionGet){ } } Thus, I have a parameter that is taken from a text string in which the user enters a number from 1 to 4.
I also have a PickerView with 4 values. Yes, it looks silly, but I definitely need a categoryCollection as an Array.
categoryCollection = [[NSArray alloc] initWithObjects:@"Choose category", @"Group",@"Faculty", @"Teacher", @"Auditory",nil]; numberOfCategoryCollection = [[NSArray alloc]initWithObjects:@"0", @"1", @"2", @"3", @"4", nil]; NSDictionary *categoryDictionary=[[NSDictionary alloc] initWithObjects:categoryCollection forKeys:numberOfCategoryCollection]; After selecting any value, it is displayed in the textField .
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{ [_textFieldGet setText:[categoryCollection objectAtIndex:row] ]; // Отображает категорию в текстФилд} In the request, I need to pass exactly the number, and the textField is passed to the textField , not the key. How can I make the option name displayed for a user, and the key passed to the request? For these purposes, I created categoryDictionary , I thought, you can somehow use it.
Sorry if I explained it too intricately, these are my first steps in development. Thanks in advance for your help.