title: Core Data - how to check if user exists in database?
body: <p>So I'm trying to create a simple (if such one exists) login process for my app, and I am getting an error with the below block of code.</p>
  
  <pre><code> NSManagedObject *context = _managedObjectContext;
  
  NSFetchRequest *request= [[NSFetchRequest alloc] init];
  NSEntityDescription *entity = [NSEntityDescription entityForName:@"Account"   inManagedObjectContext:context];
  NSPredicate *predicate =[NSPredicate predicateWithFormat:@"username==%@",self.textFieldUsername.text];
  [request setEntity:entity];
  [request setPredicate:predicate];
  
  NSError *error = nil;
  
  // Below line is giving me error
  
  NSArray *array = [managedObjectContext executeFetchRequest:request error:&amp;error];
  if (array != nil) {
      NSUInteger count = [array count]; // may be 0 if the object has been deleted.
      NSLog(@"Username may exist, %@",count);
  }
  
  else {
      NSLog(@"Username does not exist.");
  }
  </code></pre>
  
  <p>`</p>
  
  <p>The above code right now is ran when the user clicks the Login button.</p>
  
  <p>Xcode is giving me an error of:
  <em>No visible @interface for 'NSManagedObject' declares the selector 'executeFetchRequest:error.'</em></p>
  
  <p>When I read the above statement it just seems <em>greek</em> to me.  The name of the file I am working on is <em>ViewControllerWelcome.m</em> and can be viewed in it's entirety at the following <a href="http://pastie.org/4112771" rel="nofollow">link</a>. If it matters, I am using the stock boilerplate core data code.</p>
  
  <p>Bonus: How do I get objective-c code highlighting when I post on here (SO)?</p>