Permalink
Browse files

make NSBlock additions AppStore-safe, header fixes

  • Loading branch information...
1 parent 047cc26 commit fd2333b47d905e00a92a3d7a2e4105787b2127f2 @mpw committed Feb 4, 2013
View
29 DrawingContext/MPWAbstractCGContext.m
@@ -9,6 +9,7 @@
#import "MPWAbstractCGContext.h"
#import "MPWDrawingContext.h"
#import <CoreText/CoreText.h>
+#include <objc/runtime.h>
@protocol DrawingContextRealArray <NSObject>
@@ -21,19 +22,9 @@ -(float)realAtIndex:(int)anIndex;
#if NS_BLOCKS_AVAILABLE
-@interface NSBlock : NSObject
-@end
-@implementation NSBlock(value)
-
--(void)drawOnContext:aContext
-{
- ((DrawingBlock)self)(aContext);
-}
-
-@end
-
@implementation MPWDrawingCommands
+
-(id)initWithBlock:(DrawingBlock)aBlock
{
self=[super init];
@@ -64,6 +55,19 @@ -(void)dealloc
@implementation MPWAbstractCGContext
+#if NS_BLOCKS_AVAILABLE
++(void)initialize
+{
+ static int initialized=NO;
+ if ( !initialized) {
+ Class blockClass=NSClassFromString(@"NSBlock");
+ IMP theImp=imp_implementationWithBlock( ^(id blockSelf, id aContext){ ((DrawingBlock)blockSelf)(aContext); } );
+ class_addMethod(blockClass, @selector(drawOnContext:), theImp, "v@:@");
+ initialized=YES;
+ }
+}
+#endif
+
-(int)object:inArray toFloats:(float *)floatArray maxCount:(int)maxCount
{
int arrayLength = 1;
@@ -348,8 +352,8 @@ -(void)setAlpha:(float)newAlpha {}
#endif
@end
-#if 0
+#if 0
#import <MPWFoundation/MPWFoundation.h>
@implementation MPWAbstractCGContext(testing)
@@ -382,4 +386,3 @@ +(void)testGetFloats
@end
#endif
-
View
2 DrawingContext/MPWView.h
@@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
-#import <EGOS/MPWDrawingContext.h>
+#import "MPWDrawingContext.h"
@interface MPWView : NSView {
View
2 DrawingContext/MPWView_iOS.h
@@ -10,7 +10,7 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
-#import <EGOS/MPWDrawingContext.h>
+#import "MPWDrawingContext.h"
@interface MPWView : UIView {
View
BIN ...codeproj/project.xcworkspace/xcuserdata/marcel.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
View
2 IconPhoneApp/MPWAppDelegate.m
@@ -7,8 +7,8 @@
//
#import "MPWAppDelegate.h"
-#import <MPWFoundation/MPWFoundation.h>
#import <CoreText/CoreText.h>
+#import "AccessorMacros.h"
@implementation MPWAppDelegate

0 comments on commit fd2333b

Please sign in to comment.