title: Core Data and NSPredicate
body: <p>I'm looking for a way to use NSPredicate to set a "beginswith [cp]" condition to fetch objects. In the data model there is an one entity which contains 4 basic attributes. Name of first attribute is cityName. The goal is to find records for which cityName begins with given character, but I'm not sure how to format the predicate.
  This is part of my code for this</p>
  
  <pre><code>NSString * lastCharacter = [userCity substringFromIndex:[userCity length] -1];
  AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
  NSManagedObjectContext *context =
  [appDelegate managedObjectContext];
  
  NSEntityDescription *entityDesc =
  [NSEntityDescription entityForName:@"Cities"
              inManagedObjectContext:context];
  
  NSFetchRequest *request = [[NSFetchRequest alloc] init];
  [request setEntity:entityDesc];
  
  NSPredicate *pred = [NSPredicate predicateWithFormat:@"(cityName = beginswith [cp] %@ )", lastCharacter];
  [request setPredicate:pred];
  </code></pre>
  
  <p>but for this code I get following error:</p>
  
  <pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "(cityName = beginswith [cp] %@ )"'
  </code></pre>