Я новичок в iOS, и перед вами стоит проблема, связанная с получением IndexPath.row вне метода cellforrowAtIndexPath i.e on didFinishLoading. Мой код как этотКак получить IndexPath.row в didFinishLoading в Objective C
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
loginStatus = [[NSString alloc] initWithBytes: [myNSMDataFromServer mutableBytes] length:[myNSMDataFromServer length] encoding:NSUTF8StringEncoding];
NSLog(@"loginStatus =%@",loginStatus);
NSError *parseError = nil;
NSDictionary *xmlDictionary = [XMLReader dictionaryForXMLString:loginStatus error:&parseError];
NSLog(@"JSON DICTIONARY = %@",xmlDictionary);
recordResult = [xmlDictionary[@"success"] integerValue];
NSLog(@"Success: %ld",(long)recordResult);
NSDictionary* Address=[xmlDictionary objectForKey:@"soap:Envelope"];
NSLog(@"Address Dict = %@",Address);
NSDictionary *new =[Address objectForKey:@"soap:Body"];
NSLog(@"NEW DICT =%@",new);
NSDictionary *LoginResponse=[new objectForKey:@"TFMComplaints_GetNewResponse"];
NSLog(@"Login Response DICT =%@",LoginResponse);
NSDictionary *LoginResult=[LoginResponse objectForKey:@"TFMComplaints_GetNewResult"];
NSLog(@"Login Result =%@",LoginResult);
if(LoginResult.count>0)
{
NSLog(@"Login Result = %@",LoginResult);
NSLog(@"Login Result Dict =%@",LoginResult);
NSString *teststr =[[NSString alloc] init];
teststr =[LoginResult objectForKey:@"text"];
NSLog(@"Test String Value =%@",teststr);
NSString *string = [LoginResult valueForKey:@"text"];
NSLog(@"Now String is =%@",string);
NSData *data =[string dataUsingEncoding:NSUTF8StringEncoding];
NSError* error;
NSArray *array = [NSJSONSerialization JSONObjectWithData:data options:NSUTF8StringEncoding error:&error];
NSIndexPath *selectedIndexPath = [closetbl indexPathForSelectedRow];
NSDictionary *firstObj = [array objectAtIndex:selectedIndexPath.row];
idarray=[[NSMutableArray alloc]init];
idarray=[firstObj valueForKey:@"Key"];
NSLog(@"Result Array =%@",idarray);
}
Я получаю только одно значение, которое на 0.
Заранее спасибо!
С какой целью u хотите это в didFinishLoading method? – ashmi123
Пожалуйста, объясните подробнее ..... –
NSDictionary * firstObj = [массив objectAtIndex: indexpath.row]; –