Good day! I make an application to view the news, the preview of the news is shown in the table.
Thus I download the data:
NSURL *url=[NSURL URLWithString:path]; NSString *dataJSON=[NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:Nil]; NSData *data=[dataJSON dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary *rootDictionary=[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
And I safely pull out the values I need, and list them in the news preview table. Question: Is this approach correct? Or do you first need to save this data somewhere on the device and then add it to the table? At this stage, the table lags very strongly, each cell is loaded, and this slows down the scrolling. I do not know how to be.
I bring the information to the cell in the following way:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; CellForNews *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; id tempObject=[[NSObject alloc]init]; tempObject=[self.arrayOfNews objectAtIndex:indexPath.row]; cell.publishDate.text=tempObject[@"date"]; NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:tempObject[@"imgPath"]]]; cell.newsImage.image=[UIImage imageWithData:data]; cell.descriptionOfThenews.text=tempObject[@"description"]; cell.titleOfTheNews.text=tempObject[@"publish_title"]; return cell; }