Sunday, October 11, 2009

iPhone dev Stupidity 71: Loading ... 17% - How to Make progress b

1. iPhone threading and screen refreshs

    Use kind of server and inter PROCESS communicating. Quite complex.

    Use notification center as a mid man - but NOT working.
    Because a notification is despatched synchronously - UI still get no chance to update.

My solution (based on 2):
    Sending notification in a separate thread instead of notifying directly:

- (void) sendProgressNotification: (NSNumber *) percentDeltaValue{


[[NSNotificationCenter defaultCenter] postNotificationName:@"StepPercent" object: percentDeltaValue];


}




// post the progress info


- (void) stepPercentage: (int) percentDelta{


[NSThread detachNewThreadSelector: @selector(sendProgressNotification:) toTarget: self withObject: [NSNumber numberWithInt: percentDelta]];


}


No comments: