Parse PFUser QueryWithPnetworkingicate No funciona

Estoy intentando implementar la funcionalidad de búsqueda del usuario y para lo cual bash utilizar NSPnetworkingicate pero no funciona.

Estoy intentando usar COMO la consulta.

Aquí está el código que estoy usando

NSPnetworkingicate *userPnetworkingicate = [NSPnetworkingicate pnetworkingicateWithFormat:@"(%@ CONTAINS[cd] %@) OR (%@ CONTAINS[cd] %@) AND %@ != %@",KEY_FirstName, sender.text,KEY_Lastname, sender.text,KEY_Id,[PFUser currentUser].objectId]; queryForUserSearch = [PFUser queryWithPnetworkingicate:userPnetworkingicate]; // I also tried this NSPnetworkingicate *userPnetworkingicate = [NSPnetworkingicate pnetworkingicateWithFormat:@"(%@ = %@) OR (%@ = %@) AND %@ != %@",KEY_FirstName, sender.text,KEY_Lastname, sender.text,KEY_Id,[PFUser currentUser].objectId]; queryForUserSearch = [PFUser queryWithPnetworkingicate:userPnetworkingicate]; 

Y estoy recibiendo error por debajo

motivo: 'Las consultas de Regex no son compatibles con [PFQuery queryWithClassName: pnetworkingicate:]. Intenta estructurar tus datos para que puedas usar una consulta equalTo o containedIn. '

También busco esto pero no funcionó para mí.

En primer lugar, su object, así es como configuró esto, un ejemplo:

Book.h

 #import <Foundation/Foundation.h> @interface Book : NSObject @property (strong, nonatomic)NSString *bookID; @property (strong, nonatomic)NSString *publishingYear; @property (strong, nonatomic)NSString *author; @property (strong, nonatomic)NSString *printHouse; @property (strong, nonatomic)NSString *title; @property (strong, nonatomic)NSString *ISBN; -(id)initWithBookObjectId:(NSString *)bookID publishingYear:(NSString *)publishingYear author:(NSString *)author printHouse:(NSString *)printHouse title:(NSString *)title ISBN:(NSString *)ISBN; - (id)initWithDictionary:(PFObject *)dic; @end 

Book.m

 #import "Book.h" #define NSHNullCheck(object) ([object isKindOfClass:[NSNull class]] ? nil : object) @implementation Book { NSDictionary * descriptionDict; } -(id)initWithBookObjectId:(NSString *)bookID publishingYear:(NSString *)publishingYear author:(NSString *)author printHouse:(NSString *)printHouse title:(NSString *)title ISBN:(NSString *)ISBN; { self = [super init]; if (self) { _bookID = bookID; _publishingYear = publishingYear; _author = author; _printHouse = printHouse; _title = title; _ISBN = ISBN;} return self; } - (id)initWithDictionary:(PFObject *)dic { self = [self initWithBookObjectId:dic.objectId publishingYear:NSHNullCheck([dic valueForKey:@"publishingYear"]) author:NSHNullCheck([dic valueForKey:@"author"]) printHouse:NSHNullCheck([dic valueForKey:@"printHouse"]) title:NSHNullCheck([dic valueForKey:@"title"]) ISBN:NSHNullCheck([dic valueForKey:@"ISBN"])]; descriptionDict = @{ @"sessionObjectId":_bookID, @"teacherAge":_publishingYear, @"teacherEmail":_author, @"teacherFacebookuniquekey":_printHouse, @"teacherFirstname":_title, @"teacherGender":_ISBN}; return self; } - (id)init { self = [self initWithBookObjectId:nil publishingYear:nil author:nil printHouse:nil title:nil ISBN:nil]; return self; } - (NSString *)description { return descriptionDict.description; } @end 

Almacenamiento de datos en el object Modelo: books es una matriz que contiene sus "objects de libro". El siguiente fragment de código entra en el lugar donde extraiga sus datos de la networking con una consulta de Parse.

 for (PFObject *object in objects) { //"objects" here is the NSArrray returned from the parse query! Book *book = [[Book alloc] initWithBookObjectId:object.objectId]; book.publishingYear = object[@"publishingYear"]; book.author = object[@"author"]; book.printHouse = object[@"printHouse"]; book.title = object[@"title"]; book.ISBN = object[@"isbn"]; [self.books addObject:book]; } if ([self.searchTerm isEqualToString:@""]) { self.filtenetworkingBooksArray = self.books; } else { NSPnetworkingicate *pnetworkingicate = [NSPnetworkingicate pnetworkingicateWithFormat:@"SELF.title contains[c] %@",self.searchTerm]; self.filtenetworkingBooksArray = [NSMutableArray arrayWithArray:[self.books filtenetworkingArrayUsingPnetworkingicate:pnetworkingicate]]; } [self.booksTable reloadData]; 

Entonces, así es como busca con PFObjects, primero necesita extraer los datos, savelos dentro de una subclass NSObject (un model de object de datos) y luego usar pnetworkingicados de expresiones regulares como lo haría en cualquier model de object con una function de búsqueda en IOS .

Hay este método:

 PFQuery *query = [PFQuery queryWithClassName:@"Post"] [query whereKey:@"hashtags" containsAllObjectsInArray:@[@"#parse", @"#ftw"]]; NSArray *parseFTWPosts = [query findObjects]; 

y luego este método:

 / Using PFQuery [query whereKey:@"playerName" notEqualTo:@"Michael Yabuti"]; [query whereKey:@"playerAge" greaterThan:@18]; // Using NSPnetworkingicate NSPnetworkingicate *pnetworkingicate = [NSPnetworkingicate pnetworkingicateWithFormat: @"playerName != 'Michael Yabuti' AND playerAge > 18"]; PFQuery *query = [PFQuery queryWithClassName:@"GameScore" pnetworkingicate:pnetworkingicate]; 

y luego este fragment:

 Specifying Constraints with NSPnetworkingicate To get the most out of PFQuery we recommend using its methods listed below to add constraints. However, if you prefer using NSPnetworkingicate, a subset of the constraints can be specified by providing an NSPnetworkingicate when creating your PFQuery. NSPnetworkingicate *pnetworkingicate = [NSPnetworkingicate pnetworkingicateWithFormat:@"playerName = 'Dan Stemkosk'"]; PFQuery *query = [PFQuery queryWithClassName:@"GameScore" pnetworkingicate:pnetworkingicate]; let pnetworkingicate = NSPnetworkingicate(format: "playerName = 'Dan Stemkosk'") var query = PFQuery(className: "GameScore", pnetworkingicate: pnetworkingicate) These features are supported: Simple comparisons such as =, !=, <, >, <=, >=, and BETWEEN with a key and a constant. Containment pnetworkingicates, such as x IN {1, 2, 3}. Key-existence pnetworkingicates, such as x IN SELF. BEGINSWITH expressions. Compound pnetworkingicates with AND, OR, and NOT. Sub-queries with "key IN %@", subquery. The following types of pnetworkingicates are not supported: Aggregate operations, such as ANY, SOME, ALL, or NONE. Regular expressions, such as LIKE, MATCHES, CONTAINS, or ENDSWITH. Pnetworkingicates comparing one key to another. Complex pnetworkingicates with many ORed clauses. 

y más aquí:

https://github.com/ParsePlatform/Docs/blob/master/en/ios/queries.mdown