मुझे UIAlertView
अवरुद्ध करने की आवश्यकता है। क्योंकि मेरे पास काम है और मुझे UIAlertView
विकल्प वापस करने की आवश्यकता है। लेकिन समस्या यह है कि UIAlertView
के बाद दिखाया गया है कि मेरा फ़ंक्शन कोड आगे निष्पादित कर रहा है इसलिए मैं UIAlertView
पसंद नहीं कर सकता (मैं इसे प्रतिनिधि तरीकों से कर सकता हूं, लेकिन मुझे फ़ंक्शन परिणाम वापस करने की आवश्यकता है)।UIAlertView ब्लॉकिंग
मैंने NSCondition
के साथ अवरुद्ध करने की कोशिश की। लेकिन कोड काम नहीं करता है।
condition = [NSCondition new];
result = 0 ;
[condition lock];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Fingerprint" message:@"test" delegate:window_self cancelButtonTitle:@"No" otherButtonTitles:@"Yes",nil];
[alert setDelegate:self];
[alert show];
while (result == 0) [condition wait];
[condition unlock] ;
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
[condition lock] ;
if (buttonIndex == 0)
{
result = 2;
}
else if (buttonIndex == 1)
{
result = 3 ;
}
[condition signal] ;
[condition unlock] ;
}
हो सकता है कि कैसे इस कोड को या किसी अन्य सुझाव ठीक करने के लिए? धन्यवाद
धन्यवाद। मैंने अपने फ़ंक्शन तर्क को फिर से डिजाइन किया। – kesrut