Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

First commit

  • Loading branch information...
commit c31b460939116fa6a6658c32559651394243e76e 1 parent fd4e3d1
@MugunthKumar authored
View
20 UIAlertViewCategory.xcodeproj/project.pbxproj
@@ -16,6 +16,7 @@
AB5E75621336DD7A0016813D /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB5E75601336DD7A0016813D /* MainWindow.xib */; };
AB5E75651336DD7A0016813D /* UIAlertViewCategoryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB5E75641336DD7A0016813D /* UIAlertViewCategoryViewController.m */; };
AB5E75681336DD7A0016813D /* UIAlertViewCategoryViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = AB5E75661336DD7A0016813D /* UIAlertViewCategoryViewController.xib */; };
+ AB5E75701336DDA20016813D /* UIAlertView+Block.m in Sources */ = {isa = PBXBuildFile; fileRef = AB5E756F1336DDA20016813D /* UIAlertView+Block.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -23,16 +24,18 @@
AB5E754E1336DD790016813D /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
AB5E75501336DD790016813D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
AB5E75521336DD790016813D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
- AB5E75561336DD7A0016813D /* UIAlertViewCategory-Info.plist */ = {isa = PBXFileReference; path = "UIAlertViewCategory-Info.plist"; sourceTree = "<group>"; };
+ AB5E75561336DD7A0016813D /* UIAlertViewCategory-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "UIAlertViewCategory-Info.plist"; sourceTree = "<group>"; };
AB5E75581336DD7A0016813D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
- AB5E755A1336DD7A0016813D /* UIAlertViewCategory-Prefix.pch */ = {isa = PBXFileReference; path = "UIAlertViewCategory-Prefix.pch"; sourceTree = "<group>"; };
+ AB5E755A1336DD7A0016813D /* UIAlertViewCategory-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIAlertViewCategory-Prefix.pch"; sourceTree = "<group>"; };
AB5E755B1336DD7A0016813D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
- AB5E755D1336DD7A0016813D /* UIAlertViewCategoryAppDelegate.h */ = {isa = PBXFileReference; path = UIAlertViewCategoryAppDelegate.h; sourceTree = "<group>"; };
+ AB5E755D1336DD7A0016813D /* UIAlertViewCategoryAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIAlertViewCategoryAppDelegate.h; sourceTree = "<group>"; };
AB5E755E1336DD7A0016813D /* UIAlertViewCategoryAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIAlertViewCategoryAppDelegate.m; sourceTree = "<group>"; };
AB5E75611336DD7A0016813D /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainWindow.xib; sourceTree = "<group>"; };
- AB5E75631336DD7A0016813D /* UIAlertViewCategoryViewController.h */ = {isa = PBXFileReference; path = UIAlertViewCategoryViewController.h; sourceTree = "<group>"; };
+ AB5E75631336DD7A0016813D /* UIAlertViewCategoryViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIAlertViewCategoryViewController.h; sourceTree = "<group>"; };
AB5E75641336DD7A0016813D /* UIAlertViewCategoryViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIAlertViewCategoryViewController.m; sourceTree = "<group>"; };
AB5E75671336DD7A0016813D /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/UIAlertViewCategoryViewController.xib; sourceTree = "<group>"; };
+ AB5E756E1336DDA20016813D /* UIAlertView+Block.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIAlertView+Block.h"; sourceTree = "<group>"; };
+ AB5E756F1336DDA20016813D /* UIAlertView+Block.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIAlertView+Block.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -86,6 +89,8 @@
AB5E75641336DD7A0016813D /* UIAlertViewCategoryViewController.m */,
AB5E75661336DD7A0016813D /* UIAlertViewCategoryViewController.xib */,
AB5E75551336DD7A0016813D /* Supporting Files */,
+ AB5E756E1336DDA20016813D /* UIAlertView+Block.h */,
+ AB5E756F1336DDA20016813D /* UIAlertView+Block.m */,
);
path = UIAlertViewCategory;
sourceTree = "<group>";
@@ -164,6 +169,7 @@
AB5E755C1336DD7A0016813D /* main.m in Sources */,
AB5E755F1336DD7A0016813D /* UIAlertViewCategoryAppDelegate.m in Sources */,
AB5E75651336DD7A0016813D /* UIAlertViewCategoryViewController.m in Sources */,
+ AB5E75701336DDA20016813D /* UIAlertView+Block.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -206,7 +212,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
- GCC_VERSION = com.apple.compilers.llvmgcc42;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
@@ -220,7 +226,7 @@
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_VERSION = com.apple.compilers.llvmgcc42;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
@@ -237,6 +243,7 @@
GCC_DYNAMIC_NO_PIC = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "UIAlertViewCategory/UIAlertViewCategory-Prefix.pch";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "UIAlertViewCategory/UIAlertViewCategory-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
@@ -250,6 +257,7 @@
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "UIAlertViewCategory/UIAlertViewCategory-Prefix.pch";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "UIAlertViewCategory/UIAlertViewCategory-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
VALIDATE_PRODUCT = YES;
View
33 UIAlertViewCategory/UIAlertView+Block.h
@@ -0,0 +1,33 @@
+//
+// UIAlertView+Block.h
+// UIAlertViewCategory
+//
+// Created by Mugunth on 21/03/11.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+typedef void (^DismissBlock)(int buttonIndex);
+typedef void (^CancelBlock)();
+
+@interface UIAlertView (Block) <UIAlertViewDelegate> {
+
+}
+
++ (void) alertViewWithTitle:(NSString*) title
+ message:(NSString*) message;
+
++ (void) alertViewWithTitle:(NSString*) title
+ message:(NSString*) message
+ cancelButtonTitle:(NSString*) cancelButtonTitle;
+
++ (void) alertViewWithTitle:(NSString*) title
+ onDismiss:(DismissBlock) dismissed
+ onCancel:(CancelBlock) cancelled
+ message:(NSString*) message
+ cancelButtonTitle:(NSString*) cancelButtonTitle
+ otherButtonTitles:(NSString*) otherButtons, ... NS_REQUIRES_NIL_TERMINATION;
+
+
+@end
View
78 UIAlertViewCategory/UIAlertView+Block.m
@@ -0,0 +1,78 @@
+//
+// UIAlertView+Block.m
+// UIAlertViewCategory
+//
+// Created by Mugunth on 21/03/11.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import "UIAlertView+Block.h"
+
+static DismissBlock _dismissBlock;
+static CancelBlock _cancelBlock;
+
+@implementation UIAlertView (Block)
+
++ (void) alertViewWithTitle:(NSString*) title
+ onDismiss:(DismissBlock) dismissed
+ onCancel:(CancelBlock) cancelled
+ message:(NSString*) message
+ cancelButtonTitle:(NSString*) cancelButtonTitle
+ otherButtonTitles:(NSString*) otherButtons, ...
+{
+
+ [_cancelBlock release];
+ _cancelBlock = [cancelled copy];
+
+ [_dismissBlock release];
+ _dismissBlock = [cancelled copy];
+
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
+ message:message
+ delegate:[self class]
+ cancelButtonTitle:cancelButtonTitle
+ otherButtonTitles:otherButtons, nil];
+ [alert show];
+ [alert release];
+}
+
++ (void) alertViewWithTitle:(NSString*) title
+ message:(NSString*) message
+{
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
+ message:message
+ delegate:nil
+ cancelButtonTitle:NSLocalizedString(@"Dismiss", @"")
+ otherButtonTitles: nil];
+ [alert show];
+ [alert release];
+}
+
++ (void) alertViewWithTitle:(NSString*) title
+ message:(NSString*) message
+ cancelButtonTitle:(NSString*) cancelButtonTitle
+{
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
+ message:message
+ delegate:nil
+ cancelButtonTitle:cancelButtonTitle
+ otherButtonTitles: nil];
+ [alert show];
+ [alert release];
+}
+
+
++ (void)alertView:(UIAlertView*) alertView didDismissWithButtonIndex:(NSInteger) buttonIndex
+{
+ if(buttonIndex != [alertView cancelButtonIndex])
+ {
+ _cancelBlock();
+ [_cancelBlock release];
+ }
+ else
+ {
+ _dismissBlock(buttonIndex);
+ [_dismissBlock release];
+ }
+}
+@end
View
17 UIAlertViewCategory/UIAlertViewCategoryViewController.m
@@ -7,6 +7,7 @@
//
#import "UIAlertViewCategoryViewController.h"
+#import "UIAlertView+Block.h"
@implementation UIAlertViewCategoryViewController
@@ -25,13 +26,25 @@ - (void)didReceiveMemoryWarning
#pragma mark - View lifecycle
-/*
+
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
+ [UIAlertView alertViewWithTitle:@"Test"
+ onDismiss:^(int buttonIndex)
+ {
+ NSLog(@"%d", buttonIndex);
+ }
+ onCancel:^()
+ {
+ NSLog(@"Cancelled");
+ }
+ message:@"Hello World"
+ cancelButtonTitle:@"Dismiss"
+ otherButtonTitles:@"First", @"Second", nil];
}
-*/
+
- (void)viewDidUnload
{
Please sign in to comment.
Something went wrong with that request. Please try again.