Permalink
Browse files

Added perform block support

  • Loading branch information...
1 parent 35ae662 commit da7ecc6d45db5630f0d297f0cf538aad6842cb47 @MugunthKumar committed Mar 25, 2011
@@ -6,6 +6,8 @@
// Copyright 2011 Steinlogic All rights reserved.
//
+typedef void (^VoidBlock)();
+
typedef void (^DismissBlock)(int buttonIndex);
typedef void (^CancelBlock)();
typedef void (^PhotoPickedBlock)(UIImage *chosenImage);
@@ -0,0 +1,18 @@
+//
+// NSObject+MKBlockAdditions.h
+// UIKitCategoryAdditions
+//
+// Created by Mugunth on 25/03/11.
+// Copyright 2011 Steinlogic. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "MKBlockAdditions.h"
+
+@interface NSObject (MKBlockAdditions) {
+
+}
+
+- (void) performBlock:(VoidBlock) block;
+
+@end
@@ -0,0 +1,30 @@
+//
+// NSObject+MKBlockAdditions.m
+// UIKitCategoryAdditions
+//
+// Created by Mugunth on 25/03/11.
+// Copyright 2011 Steinlogic. All rights reserved.
+//
+
+#import "NSObject+MKBlockAdditions.h"
+
+static VoidBlock _block;
+
+@implementation NSObject (MKBlockAdditions)
+
+- (void) performBlock:(VoidBlock) aBlock
+{
+ [_block release];
+ _block = [aBlock copy];
+
+ [self performSelector:@selector(callBlock)];
+}
+
+-(void) callBlock
+{
+ _block();
+ [_block release];
+ _block = nil;
+}
+
+@end
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
+ AB171ABE133CE804006867EB /* NSObject+MKBlockAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = AB171ABD133CE804006867EB /* NSObject+MKBlockAdditions.m */; };
AB5E754F1336DD790016813D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB5E754E1336DD790016813D /* UIKit.framework */; };
AB5E75511336DD790016813D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB5E75501336DD790016813D /* Foundation.framework */; };
AB5E75531336DD7A0016813D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB5E75521336DD790016813D /* CoreGraphics.framework */; };
@@ -21,6 +22,8 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
+ AB171ABC133CE804006867EB /* NSObject+MKBlockAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+MKBlockAdditions.h"; sourceTree = "<group>"; };
+ AB171ABD133CE804006867EB /* NSObject+MKBlockAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+MKBlockAdditions.m"; sourceTree = "<group>"; };
AB5E754A1336DD790016813D /* UIKitCategoryAdditions.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UIKitCategoryAdditions.app; sourceTree = BUILT_PRODUCTS_DIR; };
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; };
@@ -109,6 +112,8 @@
ABD7413613388D3400899EE2 /* UIActionSheet+MKBlockAdditions.m */,
ABD7413713388D3400899EE2 /* UIAlertView+MKBlockAdditions.h */,
ABD7413813388D3400899EE2 /* UIAlertView+MKBlockAdditions.m */,
+ AB171ABC133CE804006867EB /* NSObject+MKBlockAdditions.h */,
+ AB171ABD133CE804006867EB /* NSObject+MKBlockAdditions.m */,
);
path = MKAdditions;
sourceTree = "<group>";
@@ -178,6 +183,7 @@
ABD7412213388C9E00899EE2 /* UIKitCategoryAdditionsViewController.m in Sources */,
ABD7413913388D3400899EE2 /* UIActionSheet+MKBlockAdditions.m in Sources */,
ABD7413A13388D3400899EE2 /* UIAlertView+MKBlockAdditions.m in Sources */,
+ AB171ABE133CE804006867EB /* NSObject+MKBlockAdditions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -12,6 +12,7 @@
}
+-(IBAction) blockCallTapped:(id) sender;
-(IBAction) alertTapped:(id) sender;
-(IBAction) actionTapped:(id) sender;
-(IBAction) photoTapped:(id) sender;
@@ -9,6 +9,7 @@
#import "UIKitCategoryAdditionsViewController.h"
#import "UIAlertView+MKBlockAdditions.h"
#import "UIActionSheet+MKBlockAdditions.h"
+#import "NSObject+MKBlockAdditions.h"
@implementation UIKitCategoryAdditionsViewController
@@ -25,6 +26,14 @@ - (void)didReceiveMemoryWarning
// Release any cached data, images, etc that aren't in use.
}
+-(IBAction) blockCallTapped:(id) sender
+{
+ [self performBlock:^
+ {
+ NSLog(@"hi there!");
+ }
+ ];
+}
-(IBAction) alertTapped:(id) sender
{
@@ -73,6 +73,27 @@
<bytes key="NSWhite">MC41AA</bytes>
</object>
</object>
+ <object class="IBUIButton" id="406536409">
+ <reference key="NSNextResponder" ref="774585933"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{47, 250}, {219, 37}}</string>
+ <reference key="NSSuperview" ref="774585933"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView"/>
+ <bool key="IBUIOpaque">NO</bool>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <int key="IBUIContentHorizontalAlignment">0</int>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <reference key="IBUIFont" ref="312568317"/>
+ <int key="IBUIButtonType">1</int>
+ <string key="IBUINormalTitle">Alert</string>
+ <reference key="IBUIHighlightedTitleColor" ref="213847605"/>
+ <object class="NSColor" key="IBUINormalTitleColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
+ </object>
+ <reference key="IBUINormalTitleShadowColor" ref="503065298"/>
+ </object>
<object class="IBUIButton" id="644733448">
<reference key="NSNextResponder" ref="774585933"/>
<int key="NSvFlags">292</int>
@@ -100,7 +121,7 @@
<string key="NSFrame">{{47, 182}, {219, 37}}</string>
<reference key="NSSuperview" ref="774585933"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView"/>
+ <reference key="NSNextKeyView" ref="406536409"/>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
@@ -195,6 +216,15 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<int key="connectionID">13</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">blockCallTapped:</string>
+ <reference key="source" ref="406536409"/>
+ <reference key="destination" ref="372490531"/>
+ <int key="IBEventType">7</int>
+ </object>
+ <int key="connectionID">16</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -224,6 +254,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference ref="627234832"/>
<reference ref="364966097"/>
<reference ref="644733448"/>
+ <reference ref="406536409"/>
</object>
<reference key="parent" ref="0"/>
</object>
@@ -242,6 +273,11 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="object" ref="364966097"/>
<reference key="parent" ref="774585933"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">14</int>
+ <reference key="object" ref="406536409"/>
+ <reference key="parent" ref="774585933"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -251,6 +287,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>-1.CustomClassName</string>
<string>-2.CustomClassName</string>
<string>10.IBPluginDependency</string>
+ <string>14.IBPluginDependency</string>
<string>6.IBEditorWindowLastContentRect</string>
<string>6.IBPluginDependency</string>
<string>8.IBPluginDependency</string>
@@ -261,6 +298,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>UIKitCategoryAdditionsViewController</string>
<string>UIResponder</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>{{239, 654}, {320, 480}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -279,7 +317,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
- <int key="maxID">13</int>
+ <int key="maxID">16</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -293,13 +331,15 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<bool key="EncodedWithXMLCoder">YES</bool>
<string>actionTapped:</string>
<string>alertTapped:</string>
+ <string>blockCallTapped:</string>
<string>photoTapped:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
@@ -308,6 +348,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<bool key="EncodedWithXMLCoder">YES</bool>
<string>actionTapped:</string>
<string>alertTapped:</string>
+ <string>blockCallTapped:</string>
<string>photoTapped:</string>
</object>
<object class="NSMutableArray" key="dict.values">
@@ -321,6 +362,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
+ <string key="name">blockCallTapped:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
<string key="name">photoTapped:</string>
<string key="candidateClassName">id</string>
</object>

0 comments on commit da7ecc6

Please sign in to comment.