title: fetching core data values using predicate
body: <p>my sqlite have items in one of the entity and i wish to retrieve them out according to their categoryID </p>
  
  <blockquote>
    <p>e.g. categoryID 1 have 7 items and categoryID 2 have 5 items , when i clicked on an IBAction it will come to this method and retrieve according to my global.clickedTag</p>
  </blockquote>
  
  <p>but i'm unable to retrieve the values , any idea why? </p>
  
  <pre><code>-(NSMutableArray*)fetchItem:array{
  [self managedObjectContext];
  
      NSEntityDescription *entity = [NSEntityDescription entityForName:@"IItem" inManagedObjectContext:managedObjectContext];
      NSFetchRequest *request = [[NSFetchRequest alloc] init];
  
      //filter here
      NSPredicate * predicate  = [NSPredicate predicateWithFormat:@"categoryID == %i",myGlobal.clickedTag];
      [request setPredicate:predicate];
      [request setEntity:entity];
  
  
      NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"ID" ascending:YES];
      NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
      [request setSortDescriptors:sortDescriptors];
      [sortDescriptor release];
      NSError *error;
  
      NSMutableArray* mutableFetchCategory = [[managedObjectContext executeFetchRequest:request error:&amp;error] mutableCopy];
  
      if (!mutableFetchCategory) {
          // Handle the error.
      }
  
  
      if ([mutableFetchCategory count] &gt; 0) 
      {
  
          for (NSManagedObject *info in mutableFetchCategory)
          {
              if ([[info valueForKey:@"categoryID"]intValue] == myGlobal.clickedTag)
              {
              NSLog(@"ID: %@", [info valueForKey:@"ID"]);
              NSLog(@"category NAME/photo: %@", [info valueForKey:@"name"]);
              NSLog(@"categoryID : %@",[info valueForKey:@"categoryID"]);
  
              Item * i = [[Item alloc]initWithTitle:[info valueForKey:@"ID"] name:[info valueForKey:@"name"] description:[info valueForKey:@"desc"] thumbnail:[info valueForKey:@"thumbnail"] photo:[info valueForKey:@"photo"] categoryID:[info valueForKey:@"categoryID"]];
  
              [array addObject:i];
              NSLog(@"array count : %i",[array count]);
  
              }
          }
  
      }
      [mutableFetchCategory release];
      [request release];
      return array;
  </code></pre>
  
  <p>}</p>