Parse.com:在TableViewCell中检索布尔值 [英] Parse.com : Retrieve Boolean Value in TableViewCell

查看:79
本文介绍了Parse.com:在TableViewCell中检索布尔值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Parse.com我在我的项目中使用。
在我的视图控制器中,我有一个搜索栏,它从一个类中获取数据,这个类与我需要的布尔值不同。

Parse.com I'm using in my project . In my view controller I have a searchbar that fetches data from a class different from the one in which there is a Boolean value that I need.

简而言之,每个单元格都包含一个按钮,当按下该按钮时,该按钮将创建一个布尔值,如上所述,该布尔值位于与主查询不同的另一个类中。

In a nutshell each cell contains a button that when pushed to disappear because is going to create a Boolean value that as I said above is in another class different from that of the main query .

为了帮助您理解:

搜索栏从类_USER获取数据,其中所有驻留注册用户应用

The search bar fetches the data from class " _USER " where all reside registered users app

按钮改为在朋友类中创建一个布尔值

The button instead goes into creating a boolean value in the Class " Friends "

我无法连接这两个动作......

I can not connect the two actions ...

我做了一些测试,但我无法得到我想要的结果..你能解释一下我怎么做才能解决这个问题吗?我不明白我的错误在哪里

I did some tests but I can not get the result I want .. Can you explain how I might do to fix this? I do not understand where is my mistake

这里我显示查询和cellForRowAtIndexPath

Here I show the query and the cellForRowAtIndexPath

- (Void) { retrieveFromParse
   
 
    PFQuery retrievePets * = [ PFQuery queryWithClassName : FF_USER_CLASS ] ;
    [ retrievePets orderByAscending : FF_USER_NOMECOGNOME ] ;
    
    [ retrievePets findObjectsInBackgroundWithBlock : ^ ( NSArray * objects , NSError * error ) {
        if ( error) {
            NSLog ( @ "% @ " , objects) ;
            allObjects = [ [ NSMutableArray alloc ] init ] ;
            for ( PFObject * object in objects) {
                [ allObjects addObject : object ] ;
                
            }
            
        }
        [ self.FFTableViewFindUser reloadData ] ;
    } ] ;
}






- ( UITableViewCell * ) tableView : ( UITableView * ) tableView cellForRowAtIndexPath : ( NSIndexPath * ) indexPath {
    static NSString * CellIdentifier = @ " CellFindUser " ;
    
    
    FFCellFindUser * cell = [ self.FFTableViewFindUser dequeueReusableCellWithIdentifier : CellIdentifier ] ;
    if ( cell) {
        cell = [ [ FFCellFindUser alloc ] initWithStyle : reuseIdentifier UITableViewCellStyleDefault : CellIdentifier ] ;
    }
    
    
       if (! isFiltered ) {
        
        
        PFObject * object = [ allObjects objectAtIndex : indexPath.row ] ;
        NSString * str = [object objectForKey : FF_USER_NOMECOGNOME ] ;

        cell.FFLabelCell_NomeCognome.text = str ;
        
        
        cell.FFIMGCell_FotoProfilo.image = [ UIImage imageNamed : @ " FFIMG_Camera "] ;
        [ cell.FFIMGCell_FotoProfilo.layer setMasksToBounds : YES] ;
        [ cell.FFIMGCell_FotoProfilo.layer setCornerRadius : 22.5f ] ;
        cell.FFIMGCell_FotoProfilo.file = [object objectForKey : FF_USER_FOTOPROFILO ] ;
        [ cell.FFIMGCell_FotoProfilo loadInBackground ] ;
        
       / / Cell.FFUserButton.tag = indexPath.row ;
       / / [ Cell.FFUserButton addTarget : self action: @ selector ( FFInviaRichiestaAmicizia :)
         / / ForControlEvents : UIControlEventTouchUpInside ] ;
          
           

/ / HERE I AM RECALLING THE BOOLEAN VALUE CLASS FRIENDSHIPS
         
  if ( [ [object objectForKey : @ " RICHIESTA_IN_ATTESA "] boolValue ] ) {
               
               [ cell.FFUserButton setHidden : YES] ;
           Else { }
               [ cell.FFUserButton setHidden : NO] ;
           }

}


推荐答案

你正在以错误的方式接近你的问题

You're approaching your problem in the wrong way by using

if ( [ [object objectForKey : @ " RICHIESTA_IN_ATTESA "] boolValue ] )

因为这意味着用户需要知道他们是否是当前的朋友用户。这是错误的方式。您当前的用户应该有一个当前朋友的列表(Parse中的对象ID或关系数组)。您的表视图控制器也应该有权访问当前用户。然后,您编写代码以显示/隐藏按钮:

because that means that the users need to know if they are the friend of the current user. This is the wrong way round. You current user should have a list of its current friends (either an array of object ids or relationships in Parse). Your table view controller should also have access to the current user. Then, you write the code to show / hide the buttons as:

注意: currentUserFriends 是一个用户数组根据当前用户的关系/信息构建的对象ID

Note: currentUserFriends is an array of user object ids built from the relationship / information on the current user

[cell.FFUserButton setHidden:([currentUserFriends containsObject: object.objectId])];

这篇关于Parse.com:在TableViewCell中检索布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆