I am calculating total number of file on particular path and showing that result in custom cell.
I am using NSThread for calculating file count in - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView
(inside the bundle) method. when i am calculating file count, its showing empty cell. i think its calling [super drawWithFrame:newFrame inView:controlView];
before NSThread
return the result.
Can anyone please help me out ?? Thanks :)
The very reason to use a thread for this is to not block the UI on the main thread. The reason that works is that is that the thread starts, and the thread-creation method then returns immediately so the main thread can get on with other business.
So yes, you get to [super drawWithFrame:inView:]
before the thread has finished. You're not supposed to wait for the thread to finish—that would defeat the purpose of using a thread.
You shouldn't be doing all this from the cell, anyway. You should be doing it from the table view's data source. Kick off your thread(s) (or, probably better, operations) shortly after you have your list of directories, and update the cells as the results come in.