Note that there are some explanatory texts on larger screens.

plurals
  1. PO-[CFString hash]: message sent to deallocated instance
    primarykey
    data
    text
    <p>I'm trying to fetch <code>EKEvent</code>s from the Event Store to populate a <code>UITableView</code> and display a month list view.</p> <p>Basically it works and I'm doing it like this:</p> <pre><code>- (void) reloadEvents { for ( NSString *entry in self.calendarA ) { NSMutableArray *tempArray = [[[NSMutableArray alloc] init] autorelease]; [tempArray addObjectsFromArray:[appDelegate.eventStore eventsMatchingPredicate:[appDelegate.eventStore predicateForEventsWithStartDate:[NSDate fromString:entry] endDate:[[NSDate fromString:entry] midnight] calendars:nil]]]; [tempArray addObjectsFromArray:[self initializeItems:[NSDate fromString:entry] withEndDate:[[NSDate fromString:entry] midnight]]]; [tempArray sortUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"startDate" ascending:YES] autorelease]]]; [[self.calendarD objectForKey:entry] addObjectsFromArray:tempArray]; } dispatch_async(dispatch_get_main_queue(), ^(void) { [self redrawTableCells]; }); } </code></pre> <p><code>reloadEvents</code> is called from within a</p> <pre><code>dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { [self reloadEvents]; }); </code></pre> <p>as fetching events happens synchronously and it locks the UI for that time, I'm using GCD. The <code>NSDate</code> parts are my own categories on <code>NSDate</code>. </p> <p>Now, when my view controller loads, events are fetched from the Event Store and displayed correctly. The view controller also listens for <code>EKEventStoreChangedNotification</code> and that's where my app crashes. When I change an event outside my app it receives a notification and tries to reload the event data, but then...</p> <blockquote> <p><code>*** -[CFString length]:</code> message sent to deallocated instance 0x666f530</p> </blockquote> <p><strong>EDIT</strong> I've changed <code>reloadEvents</code> to the following:</p> <pre><code>- (void) reloadEvents { NSArray *daysArray = [[self.calendarD allKeys] sortedArrayUsingSelector:@selector(compare:)]; for ( NSString *entry in daysArray ) { NSMutableArray *tempArray = [[NSMutableArray alloc] init]; [tempArray addObjectsFromArray:[appDelegate.eventStore eventsMatchingPredicate:[appDelegate.eventStore predicateForEventsWithStartDate:[NSDate fromString:entry] endDate:[[NSDate fromString:entry] midnight] calendars:nil]]]; [tempArray addObjectsFromArray:[self initializeItems:[NSDate fromString:entry] withEndDate:[[NSDate fromString:entry] midnight]]]; [tempArray sortUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"startDate" ascending:YES] autorelease]]]; [[self.calendarD objectForKey:entry] addObjectsFromArray:tempArray]; [tempArray release]; } dispatch_async(dispatch_get_main_queue(), ^(void) { [self redrawTableCells]; }); } </code></pre> <p>and with this, the app doesn't crash anymore. Seems like something changed <code>calendarA</code> and therefore the entry was already deallocated (which, after having found the cause of the problem, is absolutely logical).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload