ios - NSPredicate weird crash with NSString -


I went created a method for'm trying to get a Kordeta unit on the basis of his name, so , which accepts a name parameter (NSString), so this method:

  - (minus) Pegrgrashbannam: (NSString *) catName {NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init ]; NSLog (@ "category name:% @", catam); NSError * Error = Zero; NSEntityDescription * entity = [NSEntityDescription EntityForName: @ Managed Object Contains in "Grading": self.managedObjectContext]; [FetchRequest Set Entity: Entity]; NSPredicate * predicate = [NSPredicate predicateWithFormat: @ "categoria == '% @'", cat's name]; [FetchRequest set candidate: count]; // [fetchRequest setFetchLimit: 1]; NSArray * fetchedObjects = [[Self-managed object contaxes] executeFetchRequest: fetchRequest error: & amp; Error]; If (fetchedObjects.count> 0) {_categoriaAtual = [fetchedObjects objectAtIndex: 0]; } Else {NSLog (@ "Category not found"); }}  

So I can call in my code somewhere:

  [self pegarCategoryByName: @ "songs"];  

When I run I get NSLog: category name songs, category not found and they crash the app.

To the funny part is, if I use NSPredicate change Pegr range pass NSString, here for example:

  NSPredicate * predicate = [NSPredicate predicateWithFormat: @ "Categoria ==" song ""];  

Everything works fine

Do not engage % @ placeholder quotes predicate format:

  [NSPredicate predicateWithFormat: @" categoria ==% @ ", Cat name];  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -