![](/img/trans.png)
[英]Use of unresolved identifier 'PFUser' - Swift/Xcode/Parse
[英]Use of unresolved identifier 'object' Xcode 6 Swift
我正在嘗試開發一種基於分析的社交網絡,並且在嘗試為每個“組”創建一個投票系統時遇到了一個問題。 在我的TableViewController中,使用PFQueryTableViewController,我收到錯誤“使用未解決的標識符'object'”。 這是我正在研究的部分
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as GroupTableViewCell
group:PFObject = self.timelineData.objectAtIndex(indexPath.row) as PFObject
cell.groupTextView.alpha = 0
cell.timeStampLabel.alpha = 0
cell.UserNameLabel.alpha = 0
cell.groupTextView.text = group.objectForKey("content") as String
var dataFormatter:NSDateFormatter = NSDateFormatter()
dataFormatter.dateFormat = "MM/DD/yyyy HH:mm"
cell.timeStampLabel.text = dataFormatter.stringFromDate(group.createdAt)
let score = object.valueForKey("count") as? Int
cell.count.text = "\(score)"
cell.groupTextView.text = object.valueForKey("content") as? String
var findUser:PFQuery = PFUser.query()
findUser.whereKey("objectId", equalTo: group.objectForKey("User").objectId)
findUser.findObjectsInBackgroundWithBlock {
(objects:[AnyObject]!, error:NSError!)->Void in
if error == nil{
let user:PFUser = (objects as NSArray).lastObject as PFUser
cell.UserNameLabel.text = user.username
UIView.animateWithDuration(0.5, animations: {
cell.groupTextView.alpha = 1
cell.timeStampLabel.alpha = 1
cell.UserNameLabel.alpha = 1
如果有人知道問題出在哪里,請幫助開發人員的初學者。
從注釋中添加另一個方法以實現完整性和格式設置:
override func objectAtIndexPath(indexPath: NSIndexPath!) -> PFObject! {
var object : PFObject? = nil
if(indexPath.row < self.objects.count) {
object = self.objects[indexPath.row] as? PFObject
}
return object
}
該行: let score = object.valueForKey("count") as? Int
let score = object.valueForKey("count") as? Int
使用object
,它在哪里聲明和設置?
似乎object
是在另一種方法中將廣告集聲明為局部變量,因此調用函數未知。
最好的猜測是應將object
聲明為類實例的屬性。
有兩個類似的陳述
cell.groupTextView.text = group.objectForKey("content") as String
和
cell.groupTextView.text = object.valueForKey("content") as? String
我相信第二個錯誤是從哪里來的。 刪除它應該沒問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.