简体   繁体   English

Swift中的filterUsingPredicate给出错误“无效不能转换为NSArray”

[英]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.

相关问题 斯威夫特:“ NSArray?” 不能转换为“ NSArray?” - Swift: 'NSArray?' is not convertible to 'NSArray?' Swift函数错误:'Float'不能转换为'Void' - Swift Function Error: 'Float' is not convertible to 'Void' “ NSArray无法转换为NSData”错误 - “NSArray is not convertible to NSData” error NSUserDefaults给Swift中的NSArray错误 - NSUserDefaults gives error with NSArray in Swift “ [AnyObject]?” 不能转换为'NSArray'(xcode,swift) - '[AnyObject]?' is not convertible to 'NSArray'(xcode,swift) Swift错误:'((AFHTTPRequestOperation!,NSError?)->不能转换为'((AFHTTPRequestOperation?,NSError)->无效? - Swift error : '(AFHTTPRequestOperation! , NSError? ) -> is not convertible to '((AFHTTPRequestOperation? , NSError) -> Void? NSArray给出NSZombie错误 - NSArray gives NSZombie error Swift中的代码块:返回错误“无法转换为” - block in Swift : return error “ is not convertible to ” 授权给HealthKit时错误'(_,_)-> Void'无法转换为'HealthManager' - error '(_, _) -> Void' is not convertible to 'HealthManager' when authorize to HealthKit “ [AnyObject]?无法转换为'NSArray' - "[AnyObject]? is not convertible to 'NSArray'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM