剛開始使用RAC,我想知道如何在TableView中的單元格中異步加載圖像。 我正在嘗試在文檔中的示例,但說實話,我不太明白... 事情是,該項目是與RAC編寫的,所以我想做正確的事情。iOS使用RAC在UITableViewCell中加載圖像
我有什麼企圖?:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"tableCell";
CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.elementName.text = self.myListOfElements[indexPath.row].elementName;
RAC(cell.imageView, image) = [[finalImage map:^(NSURL *url) {
return [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.myListOfElements[indexPath.row].url]]];
}] deliverOn:RACScheduler.mainThreadScheduler];
}
但是,這是不工作... 是否有人知道正確的方式與RAC做到這一點?
不完全是答案,但感謝「顯示燈光」:) 在代碼中,您寫道,客戶端應該是一個信號,返回一個對象與您的數據。 –