title: ios and coredata: NSPredicate does not work on fetch request
body: <p>I have the following class</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  #import &lt;CoreData/CoreData.h&gt;
  
  
  @interface Bankdaten : NSManagedObject
  
  @property (nonatomic, retain) NSString * blz;
  @property (nonatomic, retain) NSString * name;
  @property (nonatomic, retain) NSString * https;
  
  @end
  </code></pre>
  
  <p>and the implementation </p>
  
  <pre><code>#import "Bankdaten.h"
  
  @implementation Bankdaten
  
  @dynamic blz;
  @dynamic name;
  @dynamic https;
  
  @end
  </code></pre>
  
  <p>I checked that the data for this object is correctly save by core data in a corresponding table in my sqlite database. </p>
  
  <p>Now, I want to fetch a specific object by doing this request:</p>
  
  <pre><code>-(Bankdaten*) ladeBankdaten:(NSString*) blz
  {
      NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Bankdaten" inManagedObjectContext:moc];
      NSFetchRequest *request = [[NSFetchRequest alloc] init];
      [request setEntity:entityDescription];
  
      NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(blz == '%@')", blz];
      [request setPredicate:predicate];
  
      NSError *error = nil;
      NSArray *array = [moc executeFetchRequest:request error:&amp;error];
      if (array == nil) {
          NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
          abort();
      }
  
      if( [array count] == 0 )
          return nil;
      return [array objectAtIndex:0];
  }
  </code></pre>
  
  <p>The problem: In that case the array contains always zeros objects and so my method returns nil although the blz parameter must match a certain value in the database. So the fetch request should be positive. If I comment the line</p>
  
  <pre><code>[request setPredicate:predicate];
  </code></pre>
  
  <p>Such that there is no predicate set to this request the data is loaded fine therefore I think the predicate is somehow used wrong by me. What am I doing wrong here?</p>