Я получил правильный URL в методе loaddescriptiondata.
Моя проблема заключается в том, что после выполнения URL-адреса выполняется просмотр таблицы, а не загрузка соединения.
Почему это происходит?
Это мой код:
Операция разбора.m :
-(void)loadDescriptiondata:(NSString*)itemId{
isDescription = TRUE;
[self initilizeData];
NSString *stringToAppend = @"?method=showMenuItemDesc&res_id=";
NSString *append2=@"&groupcat=individual&app=iphone";
NSString *newURLAsString = [NSString stringWithFormat:@"%@%@%@%@",URL,stringToAppend,itemId,append2];
NSURL *url = [NSURL URLWithString:newURLAsString];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
urlConnection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
NSLog(@"url shop desp=%@",url);
}
Viewdidload
- (void)viewDidLoad{
parse = [[ParseOperation alloc]init];
categoryImageUrl =[[NSMutableArray alloc]init];
parse.delegate = self;
}
Mytableview
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"LazyTableCell";
// add a placeholder cell while waiting on table data
AsyncImageView *asyncImageView = nil;
UILabel *label = nil;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] ;
}
else {
asyncImageView = (AsyncImageView *) [cell.contentView viewWithTag:ASYNC_IMAGE_TAG];
label = (UILabel *) [cell.contentView viewWithTag:LABEL_TAG];
}
iId=[ids objectAtIndex:indexPath.row];
NSLog(@".....id... %@",iId);
[parse loadDescriptiondata:(NSString *)iId];
NSString *urlString = [categoryImageUrl objectAtIndex:indexPath.row];
urlString=[urlString stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSURL *url = [NSURL URLWithString:urlString];
[asyncImageView loadImageFromURL:url];
}
Отредактировано
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[responseData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[responseData appendData:data];
}
#pragma mark -
#pragma mark Process loan data
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
self.responseData = nil;
NSLog(@"Connected");
// NSLog(@"respond string %@",responseString);
NSArray *latestLoans = [responseString JSONValue] ;
categoryData = [[CategoryData alloc] init];
for(int i=0;i<[latestLoans count];i++)
{
NSString* shortTitle13 = [loan objectForKey:@"photourl"];
spiceType = [loan objectForKey:@"spicinesstype"];
img =[loan objectForKey:@"photourl"];
[array2 addObject:shortTitle13];
if(isDescription == TRUE){
[spiceTypeArray addObject:spiceType];
[spiceArrayID addObject:spiceID];
}
}
if(isDescription == TRUE){
[self.delegate didFinishParsingImageUrl:array2];//phot
}