У меня небольшая проблема.Я создал UIAlertView для подкласса и назвал его UIDisclaimerAlertView.
Пока все хорошо, подкласс работает нормально.Но теперь я хотел использовать этот самый класс в качестве своего собственного делегата.Итак, в своем подклассе я использовал: self.delegate = self;
Я сделал это, потому что хотел, чтобы все это было в одном файле класса.
Теперь проблема, с которой я сталкиваюсь, заключается в том, что методы моих делегатов вызывают, но параметры(null)
.
Например:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"Trying: %@", buttonIndex);
}
Возвращает (ноль) каждый раз.Есть идеи почему?Я также попытался [super setDelegate: self];
(прямо сказать надклассу (UIAlertView)), и он делает то же самое.
Вот полный файл реализации:
#import "UIDisclaimerAlertView.h"
#import "PremierSoinsAppDelegate.h"
#import "BlocTexte.h"
@implementation UIDisclaimerAlertView
@synthesize dialogKey, plist, plistPath;
- (id)initWithKeyAndBlocTexteId:(NSString *)key BlocTexteId:(NSString *)blocTexteId
{
if (self = [super init])
{
// Fetching content
BlocTexte *blocTexte = [[BlocTexte alloc] init];
NSString *messageString = [[blocTexte getBlocTextes:blocTexteId] objectAtIndex:1];
// Setting superclass' properties
self.title = @"Disclaimer";
self.message = messageString;
[super setDelegate: self];
[self addButtonWithTitle: @"Ok"];
[self addButtonWithTitle: @"Toujours"];
// Setting plist key
self.dialogKey = key;
// Loading plist content
PremierSoinsAppDelegate *AppDelegate = (PremierSoinsAppDelegate *)[[UIApplication sharedApplication] delegate];
self.plistPath = [AppDelegate saveFilePath:@"disclaimers.plist"];
self.plist = [[NSMutableDictionary alloc] initWithContentsOfFile:self.plistPath];
[blocTexte release];
}
return self;
}
- (void)show {
[super show];
}
- (void)toujours
{
[self.plist setValue:@"1" forKey:self.dialogKey];
[self.plist writeToFile:self.plistPath atomically:YES];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"Trying: %@", buttonIndex);
}
@end