NSNotification stops method from working completely

I have this method:

- (void)reloadMessages:(NSNotification *)notification {
    NSLog(@"RECIEVED NEW MESSAGES TO MessagesRootViewController");

    // we need to get the threads from the database...
    NSFetchRequest *theReq = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Thread" inManagedObjectContext:managedObjectContext];
    [theReq setEntity:entity];

    threads = [[managedObjectContext executeFetchRequest:theReq error:nil] retain];

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"New Message" message:@"New message" delegate:nil cancelButtonTitle:@"Thanks" otherButtonTitles:nil];
    [alert show];
    [alert release];

    [self.tableView reloadData];


If I call [self reloadMessages:nil] then the function works exactly as prescribed above.

If its called from an NSNotificationCenter notification: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadMessages:) name:@"newMessagesArrived" object:nil]; then it gets to [alert show] and stops with the screen dimmed as per this screenshot:

Any idea why this is happening?

If I take away the UIAlertView bit and just leave [self.tableView reloadData]; then it calls that function, but it stops at some point. NSLogging on the table view datasource methods reveals that the table view is updated with the correct number of rows (suggesting the core data request isn't causing a problem) but that cellForRowAtIndexPath isn't being called.

The program isn't crashing. Without the alert view the table view doesn't quite reload completely as above, but the view is still useable and moving the table view causes the rows to update appropriately (as does going to the contacts tab and back again).

If you need any more information then I can give you it.

Thanks for any help. :)



When you call the method from the NSNotificationCenter, the method is not on the GUI thread. You have to execute the AlertDialog show and TableView reloading on the GUI thread using performSelectorOnMainThread

Need Your Help

go backwards through img slider jQuery

javascript jquery

Hi I made a little img slider using jQuery with prev and next buttons. The slider advances automatically, the next button also works, but the prev button is wonky... Here's a link to the jsfiddle s...

“The application does not have a valid signature” XCode 4.3

iphone objective-c ios xcode xcode4.3

I'm getting the weirdest error today. "The application does not have a valid signature"