开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜