[SalesForce] Compile Error: Method does not exist or incorrect signature

Class

private List<Contact> RepCombinedAttachment;
Public List<CombinedAttachment> RepComAttachment;

public List<CombinedAttachment> getRepComAttachment() {
    return RepComAttachment;
} 
public CombinedAttachmentcont(ApexPages.StandardController controller) {

     ViewData();
 }
public void ViewData()
{
    RepCombinedAttachment = Database.query('Select (Select id, title, LastModifiedDate,
        createdby.name,RecordType From CombinedAttachments) from Contact where ID=:id');

    for (Contact c : RepCombinedAttachment)
    {
        for(CombinedAttachment temp : c.CombinedAttachments)
        {
            if(!temp.isEmpty())
            RepComAttachment.add(temp);
        }
    }
}

Error Message:

Compile Error: Method does not exist or incorrect signature: [CombinedAttachment].isEmpty()

Could someone please help me fix this issue.

Best Answer

for(CombinedAttachment temp : c.CombinedAttachments)
{
        //if(!temp.isEmpty())
        RepComAttachment.add(temp);
 }

isEmpty() is the list class method in order to check sobject. You may want to use any field is null or not

remove if(!temp.isEmpty())


Edit

in constructor

public CombinedAttachmentcont(ApexPages.StandardController controller) {
     RepCombinedAttachment = new List<Contact>();
     RepComAttachment = new  List<CombinedAttachment>();
     ViewData();
 }