@synthesize URL;
-- initWithURL:(NSURL *)url {
+- (id)initWithURL:(NSURL *)url {
if ((self = [super init]) != nil) {
- NSLog(@"initialising with URL with retain count %d", [url retainCount]);
self.URL = url;
}
return self;
}
-+ actionWithURL:(NSURL *)URL {
++ (id)actionWithURL:(NSURL *)URL {
return [[[self alloc] initWithURL:URL] autorelease];
}
- (NSString *)title {
- return [NSString stringWithFormat:@"Open %@", self.URL];
+ return [NSString localizedStringWithFormat:NSLocalizedString(@"OpenURLAction action title", @"Open URL"), self.URL];
}
- (NSString *)alertTitle {
- return @"Open URL";
+ return NSLocalizedString(@"OpenURLAction alert title", @"Open URL");
}
- (NSString *)alertMessage {
- return [NSString stringWithFormat:@"Open URL <%@>?", self.URL];
+ return [NSString localizedStringWithFormat:NSLocalizedString(@"OpenURLAction alert message", @"Open URL <%@>?"), self.URL];
}
- (NSString *)alertButtonTitle {
- return @"Open";
+ return NSLocalizedString(@"OpenURLAction alert button title", @"Open");
}
-- (void)performActionWithController:(UIViewController *)controller {
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
- message:[self alertMessage]
- delegate:self
- cancelButtonTitle:@"Cancel"
- otherButtonTitles:[self alertButtonTitle], nil];
- [alertView show];
- [alertView release];
+- (void)performActionWithController:(UIViewController *)controller
+ shouldConfirm:(bool)shouldConfirm {
+ if (shouldConfirm) {
+ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
+ message:[self alertMessage]
+ delegate:self
+ cancelButtonTitle:NSLocalizedString(@"OpenURLAction cancel button title", @"Cancel")
+ otherButtonTitles:[self alertButtonTitle], nil];
+ [alertView show];
+ [alertView release];
+ } else {
+ [self openURL];
+ }
}
- (void)openURL {