var predicate = [nspredicate]() //this three is or predicate.append(nspredicate(format: "item_parent_ID = %i",1)) predicate.append(nspredicate(format: "item_parent_ID = %i",3)) predicate.append(nspredicate(format: "item_parent_ID = %i",5)) // but this one is and predicate.append(nspredicate(format: "price_date CONTAINS[cd] %@",'timestamp')) var compound = NSCompoundPredicate.orPredicateWithSubpredicates(predicate)
OR运算符的前三个约束,日期的最后一个约束是AND
我花了很多时间来做这件事,我是快速发展的新手,我不习惯于目标C,这就是为什么我很难转换为我在客观c中写的快速翻译.
如果可能的话,快速写下答案,任何评论和建议都将是一个很大的帮助.提前致谢
obj c – source #1
obj c – source #2
var orList = [nspredicate]()//this three is ororList.append(nspredicate(format: "item_parent_ID = %i",1))orList.append(nspredicate(format: "item_parent_ID = %i",3)) orList.append(nspredicate(format: "item_parent_ID = %i",5))let orPredicate = NSCompoundPredicate.orPredicateWithSubpredicates(orList)// but this one is andlet other = nspredicate(format: "price_date CONTAINS[cd] %@",'timestamp')let compound = NSCompoundPredicate.andPredicateWithSubpredicates([orPredicate,other])总结
以上是内存溢出为你收集整理的AND和OR结合NSPredicate. IOS斯威夫特全部内容,希望文章能够帮你解决AND和OR结合NSPredicate. IOS斯威夫特所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)