SORU
25 NİSAN 2010, Pazar


PerformFetch çökmesini NSFetchedResultsController: cache kullanırken

NSFetchedResultsController kullanma tarihleri kullanarak kesitli olan nesneler, bir sürü görüntülemek için yapıyorum. Yeni bir kurulum, bu mükemmel bir şekilde çalışıyor ve tüm nesneleri, tablo görünümünde görüntülenir. Ancak, uygulamayı yeniden hizmete ne zaman bir kaza olsun. Ben NSFetchedResultsController başlatılıyor zaman bir önbellek belirtin ve her zaman mükemmel çalışıyor.

Benim NSFetchedResultsController yaratırım.

- (NSFetchedResultsController *)results {
    // If we are not nil, stop here
    if (results != nil)
        return results;

    // Create the fetch request, entity and sort descriptors
    NSFetchRequest *fetch = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Event" inManagedObjectContext:self.managedObjectContext];
    NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"utc_start" ascending:YES];
    NSArray *descriptors = [[NSArray alloc] initWithObjects:descriptor, nil];

    // Set properties on the fetch
    [fetch setEntity:entity];
    [fetch setSortDescriptors:descriptors];

    // Create a fresh fetched results controller
    NSFetchedResultsController *fetched = [[NSFetchedResultsController alloc] initWithFetchRequest:fetch managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"day" cacheName:@"Events"];
    fetched.delegate = self;
    self.results = fetched;

    // Release objects and return our controller
    [fetched release];
    [fetch release];
    [descriptor release];
    [descriptors release];
    return results;
}

Bu app çöküyor bu mesajlar

FATAL ERROR: The persistent cache of section information does not match the current configuration.  You have illegally mutated the NSFetchedResultsController's fetch request, its predicate, or its sort descriptor without either disabling caching or using  deleteCacheWithName:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FATAL ERROR: The persistent cache of section information does not match the current configuration.  You have illegally mutated the NSFetchedResultsController's fetch request, its predicate, or its sort descriptor without either disabling caching or using  deleteCacheWithName:'

Ben gerçekten özel bir şey yaptığıma inanmıyorum gibi bu neden olacağını söyleyerek bunu neden hiçbir ipucu var. Tek potansiyel sorun ben yeni bir nesne oluştururken, bu yapı hangi bölüm başlığı (gün).:

// Set the new format
[formatter setDateFormat:@"dd MMMM"];

// Set the day of the event
[event setValue:[formatter stringFromDate:[event valueForKey:@"utc_start"]] forKey:@"day"];

Belirttiğim gibi, bu tüm iyi eğer önbellek söz konusu ise orada çalışıyor. Herhangi bir yardım için teşekkür ederiz!

CEVAP
29 Temmuz 2010, PERŞEMBE


Apple 4.0 yeni iOS piyasaya ne zaman uygulamalarım biri ile benzer bir sorunu vardı. Arama:

fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:[self managedObjectContext] sectionNameKeyPath:nil cacheName:nil];

Ve nil için parametre cacheName değerini ayarlayın. Benim için çalıştı, sizin için umuyoruz. Bana haber ver.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • captainpuppys2000

    captainpuppy

    20 HAZİRAN 2013
  • Rickymon Tero

    Rickymon Ter

    1 Ocak 2007
  • ThisWeekYT

    ThisWeekYT

    14 Mart 2013