2015-02-03 6 views
0

cellForRowAtIndexPath 메서드에서 셀을 반환하는 데 문제가 있습니다. 계속 오류가 계속 발생합니다. TableViewCell is not convertible to void 이전에 셀을 어지럽히는 데이 오류가 발생하지 않았으므로이 점이 저에게 새로운 것입니다. 을 heres 내 cellForRowAtIndexPath 방법 :TableView 셀을 Void로 변환 할 수 없습니다.

override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!, object: PFObject?) -> PFTableViewCell! { 
    let cell = tableView.dequeueReusableCellWithIdentifier("CustomCell", forIndexPath: indexPath) as TableViewCell 
    cell.userName.text = object?.valueForKey("FBName") as? String 
    let userProfilePhotoURLString = object?.valueForKey("pictureURL") as? String 

    var pictureURL: NSURL = NSURL(string: userProfilePhotoURLString!)! 
    var urlRequest: NSURLRequest = NSURLRequest(URL: pictureURL) 
    NSURLConnection.sendAsynchronousRequest(urlRequest, queue: NSOperationQueue.mainQueue()) { (NSURLResponse response, NSData data,NSError error) -> Void in 
     if error == nil && data != nil { 
      cell.userImage.image = UIImage(data: data) 
     } 

    cell.ratingsView.show(rating: 4.0, text: nil) 

    return cell 
} 

답변

1

그게 당신이 sendAsynchronousRequesthandler 폐쇄에서 UITableViewCell을 반환 때문이다. 클로저의 반환 유형은 void입니다.

cellForRowAtIndexPath에서 비동기 요청을 수행하는 현재 접근 방식은 비동기 요청을 완료하기 전에 셀이 돌아 오면 오류가 발생합니다.

대신 비동기 요청을 수행하고 모델이 완료되면 모델을 업데이트 한 다음 테이블보기를 다시로드해야합니다.

관련 문제