Count number of entries from NSFetchRequest
<p>I have a method which is void but I have to count the number of entries in it.</p>

<p>So is there any way I can do it??</p>

<p>I tried to implement it but its not working.</p>

<p>It's giving me a error at Nsfetch count.</p>

<p>The return is declared as null.</p>

<p>testcase1</p>

<pre><code>  {
    //startdate and end date are same and both are 1 day before
    NSTimeInterval secondsPerday=24*60*60;
    NSDate *startdate = [[NSDate alloc]initWithTimeIntervalSinceNow:-secondsPerday];
    NSDate *endate = [[NSDate alloc]initWithTimeIntervalSinceNow:-secondsPerday];

    TravelerAppDelegate *delegate =[[UIApplication sharedApplication]delegate];
    [delegate getWeatherforCity:@"#" state:@"#" country:@"#" startDate:startdate endDate:endate]; 

       NSManagedObjectContext *allone=[delegate managedObjectContext]; 
       NSEntityDescription *entity = [NSEntityDescription entityForName:@"Weather" inManagedObjectContext:allone];   
      //WeatherXMLParser *delegate = [[WeatherXMLParser alloc] initWithCity:@"#" state:@"#" country:@"#"];
      NSFetchRequest *request = [[NSFetchRequest alloc] init];  
      [request setEntity:[NSEntityDescription entityForName:@"Weather" inManagedObjectContext:allone]];
      [request setIncludesSubentities:NO];
      NSError *err;
      NSUInteger count = [allone countForFetchRequest:request error:&amp;err];
      if(count == NSNotFound) {
          //Handle error
      }

      [request release];
      return count;

   }
</code></pre>
