我跟随json回应。
{
bufferTime = 15;
cutOffTime = "02:00";
shiftId = 1;
shiftTime = "07:00";
tripType = PICKUP;
},
{
bufferTime = 15;
cutOffTime = "02:00";
shiftId = 2;
shiftTime = "09:00";
tripType = PICKUP;
},
我使用以下命令将响应存储在NSMutable数组中。
{
for (int i = 0; i < numberOfItems; i++) {
NSDictionary *dict = [res objectAtIndex:i];
[shiftIdArray addObject: [dict objectForKey:@"shiftId"]];
[shiftTimeArray addObject: [dict objectForKey:@"shiftTime"]];
[cutOffTimeArray addObject:[dict objectForKey:@"cutOffTime"]];
//NSLog(@"dict : %@",dict);
}
self.dpShiftTimePicker = [[DownPicker alloc] initWithTextField:self.txtShiftTime withData:shiftTimeArray];
[self.dpShiftTimePicker addTarget:self
action:@selector(dp_Selected2:)
forControlEvents:UIControlEventValueChanged];
}
-(void)dp_Selected2:(id)dp{
NSString* selectedValue = [self.dpShiftTimePicker text];
NSLog(@"selectedValue: %@",selectedValue);
}
我在我的编程器中传递了 shiftTimeArray ,这是我编程的。现在,在为例如 09:00 选择特定的 shiftTime 时,我希望得到它相应的 shiftId 和 cutOffTime < / strong>并存储在字符串中。请帮助。
答案 0 :(得分:0)
试试这个 -
- (void)dp_Selected2:(id)dp
{
NSString* selectedValue = [self.dpShiftTimePicker text];
NSString* selectedIDValue = [shiftIdArray objectAtIndex:[shiftTimeArray indexOfObject:selectedValue]];
NSString* selectedCutOFFValue = [cutOffTimeArray objectAtIndex:[shiftTimeArray indexOfObject:selectedValue]];
NSLog(@"selectedValue: %@",selectedValue);
}