ios - Filter Array of Custom Data Class With NSPredicate in Objective-C -
i have custom class of data named dataclass
here there detail.
@interface dataclass : nsobject @property (assign,nonatomic)nsinteger invoiceid; @property (assign,nonatomic)nsinteger aninvoiceid; @property (strong,nonatomic)nsstring *customername; @property (strong,nonatomic)nsstring *departmentname; @property (strong,nonatomic)nsstring *typenumberofinvoice; @property (strong,nonatomic)nsstring *invoicedate; @property (strong,nonatomic)nsstring *stocknumber; @property (strong,nonatomic)nsstring *vehicledetail; @property (strong,nonatomic)nsstring *ronumber; @property (assign,nonatomic)nsinteger amount; @property (strong,nonatomic)nsstring *color; @property (strong,nonatomic)nsstring *year; @property (strong,nonatomic)nsstring *location; @property (strong,nonatomic)nsstring *carvinnumber; @property (strong,nonatomic)nsstring *dealership; @property (strong,nonatomic)nsstring *technician; @property (strong,nonatomic)nsdata *imagedata; @property (strong, nonatomic)nsmutablearray *arrayoflocations;
in viewcontroller
class have textfield taking inputs , showing display according text. have nsmutablearray
named arrayofdata , filtereddataarray. arrayofdata contains objects of above dataclass
when ever tried using code error
'the left hand side or operator must either nsarray or nsset.'
nspredicate *atozpredicate = [nspredicate predicatewithformat:@"any invoiceid contains[cd] %@", searchtext]; filtereddataarray = [arrayofdata filteredarrayusingpredicate:atozpredicate]; [_tableview reloaddata];
if comparing integer never use contains. compare equal sign
nspredicate *atozpredicate = [nspredicate predicatewithformat:@"invoiceid == %d", [searchtext intvalue]]; filtereddataarray = [arrayofdata filteredarrayusingpredicate:atozpredicate]; [_tableview reloaddata];
Comments
Post a Comment