i've through apple documentation , , cannot find simple code.
i accept down votes such question, predicate string return given entity entity's property equivalent given string.
i have company , product entities. @ moment, simple. company has name , other attributes. product has manufacturer , other attributes.
i want fetch products products manufacturer attribute equivalent name of company selected in company's view controller.
here method in data model handles updating products when company selected. uses title of product view controller because property assigned company name in didselectitematindexpath.
-(void)updateproducts { nsfetchrequest *reqprod = [[nsfetchrequest alloc] init]; nsentitydescription *entprod = [nsentitydescription entityforname:@"product" inmanagedobjectcontext:self.context]; [reqprod setentity:entprod]; nsstring *companytofilter = self.productsviewcontroller.title; reqprod.predicate = [nspredicate predicatewithformat:@"manufacturer %@", companytofilter]; nserror *errorprod = nil; self.productlist = [self.context executefetchrequest:reqprod error:&errorprod]; } the problem array returns 0 elements. know have product named iphone who's manufacturer apple. therefore, must predicate generating inaccurate sql.
again, spent way time search answer no avail. me , explain proper string predicate or direct me proper documentation?
predicates not sql, can output sql being used adding -com.apple.coredata.sqldebug 1 in startup options.
also, predicate format documented. short answers question john says: use contains instead of like.
Comments
Post a Comment