iphone NSCondition - App is crashing when "wait" is called
I am working on iphone app. I created a custom cl开发者_运维知识库ass that derives from "NSCondition". The following piece of code is working fine with iPhone SDK 3.1.3
- (bool)waitForFinish {
@try {
[self lock];
while (!done) {
[self wait];
}
}
@finally {
[self unlock];
}
return success;
}
The app is crashing on iPhone SDK 4.0 at line "[self wait]" What might be the reason for crash in iPhone 4.0 SDK? I noticed that the loop "while(!done)" is running for 4 times and then its crashing.
//Adding more info
-(void)releaseUse {
[self lock];
@try {
done = 1;
[self broadcast];
}
@finally {
[self unlock];
}
[self notifyComplete];
}
The above function is called when a file is downloaded so that it will send a broadcast message to come out of wait state.
Apple says that in iPhone OS 4, it fixed a bug related to NSCondition. (I don't know what's the bug). I think it might be causing error in iPhone SDK 4 and not in iPhone SDK 3.1
精彩评论