{"id":344829,"date":"2023-02-01T15:01:03","date_gmt":"2023-02-01T15:01:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=344829"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=344829","title":{"rendered":"<span>NSPredicate: \u0441\u0442\u0430\u0440\u044b\u0439 API \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u0441\u044e\u0440\u043f\u0440\u0438\u0437\u0430\u043c\u0438<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/foundation\/nspredicate\" rel=\"noopener noreferrer nofollow\">NSPredicate\u00a0<\/a>\u2014 API, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u0445\u043e\u0434\u0430 Mac OS X Tiger \u0432 2005 \u0433\u043e\u0434\u0443 \u2014 \u0438 \u0442\u043e, \u0447\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u044f \u043e\u0436\u0438\u0434\u0430\u043b.  <\/p>\n<p>\u042f \u0432\u043d\u0435\u0434\u0440\u044f\u043b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 Apple Shortcuts \u0432 \u0441\u0432\u043e\u0435\u043c\u00a0<a href=\"https:\/\/douglashill.co\/reading-app\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f<\/a>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u043b\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u042f \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/appintents\/entitypropertyquery\" rel=\"noopener noreferrer nofollow\">EntityPropertyQuery<\/a>, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445, \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e. \u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u0447\u0435\u0442\u044b\u0440\u043d\u0430\u0434\u0446\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0435\u0439, \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435 iPad. \u0427\u0435\u0442\u044b\u0440\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0431\u044b\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043c\u043d\u043e\u0439. \u041e\u0434\u043d\u0430\u043a\u043e, \u043a\u043e\u0433\u0434\u0430 \u044f \u0438\u0441\u043a\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438, \u0433\u0434\u0435 \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u0431\u044b\u043b \u043d\u0435 \u00ab\u0414\u0443\u0433\u043b\u0430\u0441 \u0425\u0438\u043b\u043b\u00bb, \u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0445 \u0434\u0435\u0441\u044f\u0442\u0438, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u043b \u043b\u0438\u0448\u044c \u0434\u0432\u0435.<\/p>\n<p>\u0411\u044b\u043b\u043e \u044f\u0441\u043d\u043e, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0432 \u043f\u043e\u0438\u0441\u043a, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0431\u044b\u043b \u0443\u043a\u0430\u0437\u0430\u043d \u0430\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e author \u0431\u044b\u043b\u043e \u0440\u0430\u0432\u043d\u043e nil. (\u042f \u0431\u0443\u0434\u0443 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0440\u043c\u0438\u043d\u044b nil \u0438 null, \u0442.\u043a. \u043e\u043d\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0441\u0442\u0435\u043a\u0430\u0445.)<\/p>\n<h3>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h3>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"swift\">let maybeString: String? = nil let condition = maybeString != \u201ctest\"<\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e condition \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u043c. \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 ==, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u044f\u0432\u043d\u043e \u0431\u044b\u043b \u0431\u044b \u043b\u043e\u0436\u043d\u044b\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0437\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f != \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e. \u0425\u043e\u0440\u043e\u0448\u0438\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438: \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u044d\u0442\u043e \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0442\u0435\u0441\u0442 \u0432 playground, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f NSPredicate \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"swift\">class MyObject: NSObject {     @objc var author: String?     init(author: String?) {         self.author = author     } }  let array = [     MyObject(author: \"Douglas Hill\"),     MyObject(author: \"Someone else\"),     MyObject(author: nil), ]  (array as NSArray).filtered(using: NSPredicate(format: \"author != %@\", \"Douglas Hill\")) \/\/ [{NSObject, author \"Someone else\"}, {NSObject, nil}]<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u043f\u0440\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0431\u044b\u043b \u00ab\u0414\u0443\u0433\u043b\u0430\u0441 \u0425\u0438\u043b\u043b\u00bb, \u0432\u043a\u043b\u044e\u0447\u0430\u043b\u0438\u0441\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0433\u0434\u0435 \u0430\u0432\u0442\u043e\u0440 \u0431\u044b\u043b nil. \u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u044f \u0438 \u043e\u0436\u0438\u0434\u0430\u043b.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e\u0435 \u043f\u043e\u0434\u043e\u0437\u0440\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c SQLite, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u043e\u0439 \u0441\u0442\u0435\u043a Core Data. \u042f \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0432\u0435\u0442\u0435\u0440\u0430\u043d\u044b SQL \u0443\u0436\u0435 \u0437\u043d\u0430\u044e\u0442 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<p>\u0412-\u0442\u0440\u0435\u0442\u044c\u0438\u0445, \u044f \u043f\u0440\u043e\u0432\u0435\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u0441\u0432\u043e\u0435\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 Core Data \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Shortcuts \u0438 \u0443\u0432\u0438\u0434\u0435\u043b \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u0441 Shortcuts: \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0443(*\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443), \u043d\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0443 \u043a\u0430\u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044d\u0442\u043e\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0440\u0430\u0432\u0435\u043d nil.<\/p>\n<p>\u042f \u0432\u043a\u043b\u044e\u0447\u0438\u043b -com.apple.CoreData.SQLDebug 3, \u0438 \u044d\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c(*\u043d\u0435\u0437\u0430\u043c\u044b\u0441\u043b\u043e\u0432\u0430\u0442\u043e\u0441\u0442\u044c, \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443) \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 SQL. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442: author != &#171;Douglas Hill&#187; \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043a \u043a\u043e\u043c\u0430\u043d\u0434\u0435 SQL SELECT \u044d\u0442\u043e:<\/p>\n<p><strong><em>WHERE t0.ZAUTHOR&lt;> ?<\/em><\/strong><\/p>\n<p>\u0413\u0434\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c ? \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f:<\/p>\n<p><strong><em>SQLite bind[0] = &#171;Douglas Hill\u201d<\/em><\/strong><\/p>\n<p>\u042f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 SQL \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438) Core Data. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u043e\u044f \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 null &#8212; \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 SQL.<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, SQL \u043d\u0435 \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439(*\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439) \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b \u043b\u0435\u0433\u043a\u043e \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\/\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0434\u0435\u0442\u0430\u043b\u044c. \u042f \u043f\u0440\u043e\u0432\u0435\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u0438 \u0432\u0442\u043e\u0440\u0438\u0447\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043b\u0438 \u043c\u043e\u044e \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0443. NULL \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0432\u043d\u044b\u043c \u0438\u043b\u0438 \u043d\u0435\u0440\u0430\u0432\u043d\u044b\u043c \u0447\u0435\u043c\u0443-\u043b\u0438\u0431\u043e \u0432 SQL, \u0438\u043b\u0438, \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441 null \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0438 \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u043c\u0438, \u043d\u0438 \u043b\u043e\u0436\u043d\u044b\u043c\u0438.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439\u00a0<a href=\"https:\/\/stackoverflow.com\/questions\/5658457\/not-equal-operator-on-null\" rel=\"noopener noreferrer nofollow\">jsumrall\u00a0<\/a>\u043a \u0432\u043e\u043f\u0440\u043e\u0441\u0443 \u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0441\u0442\u0435\u043a\u0430 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0432\u043e\u0434\u0438\u0442 \u0438\u0442\u043e\u0433:<\/p>\n<p><strong>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 != \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0447\u0435\u0433\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 WHERE MyColumn != &#8216;somevalue&#8217; \u043d\u0435 \u0432\u0435\u0440\u043d\u0435\u0442 NULL.<\/strong>  <\/p>\n<h3>\u0427\u0435\u0433\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c?<\/h3>\n<p>\u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u044f \u0431\u044b \u043d\u0435 \u0441\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 null \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u043b\u0443\u0447\u0448\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u0442 NSPredicate \u044f \u0431\u044b \u043e\u0436\u0438\u0434\u0430\u043b \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (*\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438). \u041c\u0435\u043d\u044f \u0443\u0434\u0438\u0432\u0438\u043b\u043e \u0442\u043e, \u0447\u0442\u043e Core Data \u043d\u0435 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 SQL, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0441\u0442\u0435\u043a\u0430\u0445 Apple.<\/p>\n<p>\u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u044f \u0434\u0443\u043c\u0430\u044e, \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0438\u043d\u0430\u044f. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0442\u0430\u043a \u043e\u0441\u0442\u0440\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e null. \u0415\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e \u043e\u043d\u0438 \u0441\u0447\u0438\u0442\u0430\u044e\u0442 null \u0438 \u043f\u0443\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u043c\u043e\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0447\u0435\u0440\u0435\u0437 Shortcuts, \u044f \u0434\u0443\u043c\u0430\u044e, \u0431\u043e\u043b\u0435\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e, \u0447\u0442\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c, \u043d\u0435 \u0440\u0430\u0432\u043d\u044b\u043c \u043a\u0430\u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044d\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0440\u0430\u0432\u043d\u043e null.<\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f<\/h3>\n<p>\u042d\u0442\u0443 \u043a\u0440\u0438\u0432\u0438\u0437\u043d\u0443 \u043b\u0435\u0433\u043a\u043e \u0441\u0433\u043b\u0430\u0434\u0438\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 Core Data SQLite, \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c \u043d\u0435 \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u044b\u043c \u043a\u0430\u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e. \u041d\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"swift\">NSPredicate(format: \"%K != %@\", stringKey, nonNilValue)<\/code><\/pre>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e \u0441 nil\/null, \u0437\u0430\u0434\u0430\u0432\u0430\u044f \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"swift\">NSPredicate(format: \"%K != %@ OR %K == NIL\", stringKey, nonNilValue, stringKey)<\/code><\/pre>\n<p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/appintents\/notequaltocomparator\" rel=\"noopener noreferrer nofollow\">NotEqualToComparator<\/a>\u00a0\u0438\u0437 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 Apple App Intents (Shortcuts API):  <\/p>\n<pre><code class=\"swift\">private extension NotEqualToComparator&lt;EntityProperty&lt;String?>, String?, NSPredicate> {     \/\/\/ Creates a comparator for case- and diacritic-insensitive matching of an optional string property using an NSPredicate for Core Data objects. (My objects are articles.)     convenience init(keyPath: KeyPath&lt;ArticleEntity, EntityProperty&lt;String?>>) {         \/\/ Maps from Swift key paths to string keys.         let stringKey = Article.stringKey(from: keyPath)         self.init() { value in             if let value {                 return NSPredicate(format: \"%K !=[cd] %@ OR %K == NIL\", stringKey, value, stringKey)             } else {                 \/\/ Ignore this branch for now since Shortcuts doesn\u2019t have any UI that lets a nil value be passed here. My actual code is slightly different due to an interesting reason, but that\u2019s not the topic of this article.             }         }     } }<\/code><\/pre>\n<h3>\u0420\u0435\u0437\u044e\u043c\u0435<\/h3>\n<ul>\n<li>\n<p>\u0412 Swift \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u00a0<strong><em>nil != nonNilValue<\/em><\/strong>\u00a0\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, NSPredicate, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u0430\u043a NSPredicate (\u0444\u043e\u0440\u043c\u0430\u0442:\u00a0<strong><em>&#171;%K != %@&#187;, stringKey, nonNilValue<\/em><\/strong>), \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 stringKey, \u0440\u0430\u0432\u043d\u043e nil.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u0438\u0437 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 Core Data SQLite \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439, \u043a\u0430\u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 stringKey, \u0440\u0430\u0432\u043d\u043e nil. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e Core Data \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0441 SQL, \u0430 SQL \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0432\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0440\u0430\u0432\u043d\u043e null.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438, \u0441\u043e\u0437\u0434\u0430\u0432 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u043a\u0430\u043a\u00a0<strong><em>NSPredicate(format: &#171;%K != %@ OR %K == NIL&#187;, stringKey, nonNilValue, stringKey)<\/em><\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0440\u043e\u043a: \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u0432\u0441\u0435.<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/713250\/\"> https:\/\/habr.com\/ru\/post\/713250\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/foundation\/nspredicate\" rel=\"noopener noreferrer nofollow\">NSPredicate\u00a0<\/a>\u2014 API, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u0445\u043e\u0434\u0430 Mac OS X Tiger \u0432 2005 \u0433\u043e\u0434\u0443 \u2014 \u0438 \u0442\u043e, \u0447\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u044f \u043e\u0436\u0438\u0434\u0430\u043b.  <\/p>\n<p>\u042f \u0432\u043d\u0435\u0434\u0440\u044f\u043b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 Apple Shortcuts \u0432 \u0441\u0432\u043e\u0435\u043c\u00a0<a href=\"https:\/\/douglashill.co\/reading-app\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f<\/a>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u043b\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u042f \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/appintents\/entitypropertyquery\" rel=\"noopener noreferrer nofollow\">EntityPropertyQuery<\/a>, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445, \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e. \u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u0447\u0435\u0442\u044b\u0440\u043d\u0430\u0434\u0446\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0435\u0439, \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435 iPad. \u0427\u0435\u0442\u044b\u0440\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0431\u044b\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043c\u043d\u043e\u0439. \u041e\u0434\u043d\u0430\u043a\u043e, \u043a\u043e\u0433\u0434\u0430 \u044f \u0438\u0441\u043a\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438, \u0433\u0434\u0435 \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u0431\u044b\u043b \u043d\u0435 \u00ab\u0414\u0443\u0433\u043b\u0430\u0441 \u0425\u0438\u043b\u043b\u00bb, \u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0445 \u0434\u0435\u0441\u044f\u0442\u0438, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u043b \u043b\u0438\u0448\u044c \u0434\u0432\u0435.<\/p>\n<p>\u0411\u044b\u043b\u043e \u044f\u0441\u043d\u043e, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0432 \u043f\u043e\u0438\u0441\u043a, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0431\u044b\u043b \u0443\u043a\u0430\u0437\u0430\u043d \u0430\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e author \u0431\u044b\u043b\u043e \u0440\u0430\u0432\u043d\u043e nil. (\u042f \u0431\u0443\u0434\u0443 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0440\u043c\u0438\u043d\u044b nil \u0438 null, \u0442.\u043a. \u043e\u043d\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0441\u0442\u0435\u043a\u0430\u0445.)<\/p>\n<h3>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h3>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"swift\">let maybeString: String? = nil let condition = maybeString != \u201ctest\"<\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e condition \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u043c. \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 ==, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u044f\u0432\u043d\u043e \u0431\u044b\u043b \u0431\u044b \u043b\u043e\u0436\u043d\u044b\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0437\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f != \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e. \u0425\u043e\u0440\u043e\u0448\u0438\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438: \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u044d\u0442\u043e \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0442\u0435\u0441\u0442 \u0432 playground, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f NSPredicate \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"swift\">class MyObject: NSObject {     @objc var author: String?     init(author: String?) {         self.author = author     } }  let array = [     MyObject(author: \"Douglas Hill\"),     MyObject(author: \"Someone else\"),     MyObject(author: nil), ]  (array as NSArray).filtered(using: NSPredicate(format: \"author != %@\", \"Douglas Hill\")) \/\/ [{NSObject, author \"Someone else\"}, {NSObject, nil}]<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u043f\u0440\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0431\u044b\u043b \u00ab\u0414\u0443\u0433\u043b\u0430\u0441 \u0425\u0438\u043b\u043b\u00bb, \u0432\u043a\u043b\u044e\u0447\u0430\u043b\u0438\u0441\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0433\u0434\u0435 \u0430\u0432\u0442\u043e\u0440 \u0431\u044b\u043b nil. \u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u044f \u0438 \u043e\u0436\u0438\u0434\u0430\u043b.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e\u0435 \u043f\u043e\u0434\u043e\u0437\u0440\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c SQLite, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u043e\u0439 \u0441\u0442\u0435\u043a Core Data. \u042f \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0432\u0435\u0442\u0435\u0440\u0430\u043d\u044b SQL \u0443\u0436\u0435 \u0437\u043d\u0430\u044e\u0442 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<p>\u0412-\u0442\u0440\u0435\u0442\u044c\u0438\u0445, \u044f \u043f\u0440\u043e\u0432\u0435\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u0441\u0432\u043e\u0435\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 Core Data \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Shortcuts \u0438 \u0443\u0432\u0438\u0434\u0435\u043b \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u0441 Shortcuts: \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0443(*\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443), \u043d\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0443 \u043a\u0430\u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044d\u0442\u043e\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0440\u0430\u0432\u0435\u043d nil.<\/p>\n<p>\u042f \u0432\u043a\u043b\u044e\u0447\u0438\u043b -com.apple.CoreData.SQLDebug 3, \u0438 \u044d\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c(*\u043d\u0435\u0437\u0430\u043c\u044b\u0441\u043b\u043e\u0432\u0430\u0442\u043e\u0441\u0442\u044c, \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443) \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 SQL. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442: author != &#171;Douglas Hill&#187; \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043a \u043a\u043e\u043c\u0430\u043d\u0434\u0435 SQL SELECT \u044d\u0442\u043e:<\/p>\n<p><strong><em>WHERE t0.ZAUTHOR&lt;> ?<\/em><\/strong><\/p>\n<p>\u0413\u0434\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c ? \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f:<\/p>\n<p><strong><em>SQLite bind[0] = &#171;Douglas Hill\u201d<\/em><\/strong><\/p>\n<p>\u042f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 SQL \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438) Core Data. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u043e\u044f \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 null &#8212; \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 SQL.<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, SQL \u043d\u0435 \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439(*\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439) \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b \u043b\u0435\u0433\u043a\u043e \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\/\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0434\u0435\u0442\u0430\u043b\u044c. \u042f \u043f\u0440\u043e\u0432\u0435\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u0438 \u0432\u0442\u043e\u0440\u0438\u0447\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043b\u0438 \u043c\u043e\u044e \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0443. NULL \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0432\u043d\u044b\u043c \u0438\u043b\u0438 \u043d\u0435\u0440\u0430\u0432\u043d\u044b\u043c \u0447\u0435\u043c\u0443-\u043b\u0438\u0431\u043e \u0432 SQL, \u0438\u043b\u0438, \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441 null \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0438 \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u043c\u0438, \u043d\u0438 \u043b\u043e\u0436\u043d\u044b\u043c\u0438.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439\u00a0<a href=\"https:\/\/stackoverflow.com\/questions\/5658457\/not-equal-operator-on-null\" rel=\"noopener noreferrer nofollow\">jsumrall\u00a0<\/a>\u043a \u0432\u043e\u043f\u0440\u043e\u0441\u0443 \u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0441\u0442\u0435\u043a\u0430 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0432\u043e\u0434\u0438\u0442 \u0438\u0442\u043e\u0433:<\/p>\n<p><strong>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 != \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0447\u0435\u0433\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 WHERE MyColumn != &#8216;somevalue&#8217; \u043d\u0435 \u0432\u0435\u0440\u043d\u0435\u0442 NULL.<\/strong>  <\/p>\n<h3>\u0427\u0435\u0433\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c?<\/h3>\n<p>\u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u044f \u0431\u044b \u043d\u0435 \u0441\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 null \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u043b\u0443\u0447\u0448\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u0442 NSPredicate \u044f \u0431\u044b \u043e\u0436\u0438\u0434\u0430\u043b \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (*\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438). \u041c\u0435\u043d\u044f \u0443\u0434\u0438\u0432\u0438\u043b\u043e \u0442\u043e, \u0447\u0442\u043e Core Data \u043d\u0435 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 SQL, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0441\u0442\u0435\u043a\u0430\u0445 Apple.<\/p>\n<p>\u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u044f \u0434\u0443\u043c\u0430\u044e, \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0438\u043d\u0430\u044f. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0442\u0430\u043a \u043e\u0441\u0442\u0440\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e null. \u0415\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e \u043e\u043d\u0438 \u0441\u0447\u0438\u0442\u0430\u044e\u0442 null \u0438 \u043f\u0443\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u043c\u043e\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0447\u0435\u0440\u0435\u0437 Shortcuts, \u044f \u0434\u0443\u043c\u0430\u044e, \u0431\u043e\u043b\u0435\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e, \u0447\u0442\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c, \u043d\u0435 \u0440\u0430\u0432\u043d\u044b\u043c \u043a\u0430\u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044d\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0440\u0430\u0432\u043d\u043e null.<\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f<\/h3>\n<p>\u042d\u0442\u0443 \u043a\u0440\u0438\u0432\u0438\u0437\u043d\u0443 \u043b\u0435\u0433\u043a\u043e \u0441\u0433\u043b\u0430\u0434\u0438\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 Core Data SQLite, \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c \u043d\u0435 \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u044b\u043c \u043a\u0430\u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e. \u041d\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"swift\">NSPredicate(format: \"%K != %@\", stringKey, nonNilValue)<\/code><\/pre>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e \u0441 nil\/null, \u0437\u0430\u0434\u0430\u0432\u0430\u044f \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"swift\">NSPredicate(format: \"%K != %@ OR %K == NIL\", stringKey, nonNilValue, stringKey)<\/code><\/pre>\n<p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f\u00a0<a href=\"https:\/\/developer.apple.com\/documentation\/appintents\/notequaltocomparator\" rel=\"noopener noreferrer nofollow\">NotEqualToComparator<\/a>\u00a0\u0438\u0437 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 Apple App Intents (Shortcuts API):  <\/p>\n<pre><code class=\"swift\">private extension NotEqualToComparator&lt;EntityProperty&lt;String?>, String?, NSPredicate> {     \/\/\/ Creates a comparator for case- and diacritic-insensitive matching of an optional string property using an NSPredicate for Core Data objects. (My objects are articles.)     convenience init(keyPath: KeyPath&lt;ArticleEntity, EntityProperty&lt;String?>>) {         \/\/ Maps from Swift key paths to string keys.         let stringKey = Article.stringKey(from: keyPath)         self.init() { value in             if let value {                 return NSPredicate(format: \"%K !=[cd] %@ OR %K == NIL\", stringKey, value, stringKey)             } else {                 \/\/ Ignore this branch for now since Shortcuts doesn\u2019t have any UI that lets a nil value be passed here. My actual code is slightly different due to an interesting reason, but that\u2019s not the topic of this article.             }         }     } }<\/code><\/pre>\n<h3>\u0420\u0435\u0437\u044e\u043c\u0435<\/h3>\n<ul>\n<li>\n<p>\u0412 Swift \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u00a0<strong><em>nil != nonNilValue<\/em><\/strong>\u00a0\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, NSPredicate, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u0430\u043a NSPredicate (\u0444\u043e\u0440\u043c\u0430\u0442:\u00a0<strong><em>&#171;%K != %@&#187;, stringKey, nonNilValue<\/em><\/strong>), \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 stringKey, \u0440\u0430\u0432\u043d\u043e nil.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u0438\u0437 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 Core Data SQLite \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439, \u043a\u0430\u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 stringKey, \u0440\u0430\u0432\u043d\u043e nil. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e Core Data \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0441 SQL, \u0430 SQL \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0432\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0440\u0430\u0432\u043d\u043e null.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438, \u0441\u043e\u0437\u0434\u0430\u0432 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u043a\u0430\u043a\u00a0<strong><em>NSPredicate(format: &#171;%K != %@ OR %K == NIL&#187;, stringKey, nonNilValue, stringKey)<\/em><\/strong>.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0440\u043e\u043a: \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u0432\u0441\u0435.<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/713250\/\"> https:\/\/habr.com\/ru\/post\/713250\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-344829","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/344829","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=344829"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/344829\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=344829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=344829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=344829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}