[英]filterUsingPredicate in swift gives error “Void is not convertible to NSArray”
Hello I am not able to solve this error. 您好,我无法解决此错误。 please give me the relevant code for this
请给我相关的代码
var predicate = NSPredicate(format: "offerTitle LIKE[cd] %@", regionName);
var arrRegion : [NSArray] = arrOffers.filterUsingPredicate(predicate);
Second line gives error : " void convertible to NSArray
" 第二行给出错误:“
void convertible to NSArray
”
filterUsingPredicate
modifies a (mutable) array and does not return a result. filterUsingPredicate
修改 (可变)数组,并且不返回结果。 What you probably want is 您可能想要的是
var arrRegion : NSArray = arrOffers.filteredArrayUsingPredicate(predicate)
which does not modify the receiver, but returns the filtered array. 它不会修改接收器,但会返回过滤后的数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.