Permalink
Browse files

Adding TODO macros (+ ObjcSubscripting support for older SDKs). Reorg…

…anizing repo.
  • Loading branch information...
AliSoftware committed Oct 2, 2012
1 parent 319570f commit bb47f42d74ecdabcd6ecd6f315a0a522f722eee1
View
@@ -0,0 +1,28 @@
+//
+// ObjcSubscriptingSupport.h
+//
+// Created by Olivier Halligon on 02/10/12.
+//
+//
+
+#import <Foundation/Foundation.h>
+
+#if __has_feature(objc_subscripting)
+#if (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED < 1070) /* Define this on OSX only if prior to 10.7 */ \
+|| (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < 60000) /* Define this on iOS only if prior to 6.0 */
+
+@interface NSArray(ObjcLiterals)
+-(id)objectAtIndexedSubscript:(NSUInteger)index;
+@end
+@interface NSMutableArray(ObjcLiterals)
+-(void)setObject:(id)anObject atIndexedSubscript:(NSUInteger)index;
+@end
+@interface NSDictionary(ObjcLiterals)
+-(id)objectForKeyedSubscript:(id)aKey;
+@end
+@interface NSMutableDictionary(ObjcLiterals)
+-(void)setObject:(id)anObject forKeyedSubscript:(id<NSCopying>)aKey;
+@end
+
+#endif
+#endif
View
@@ -0,0 +1,30 @@
+//
+// TODOMacros.h
+//
+// Created by Olivier Halligon on 02/10/12.
+//
+//
+
+#define GENERATE_PRAGMA(x) _Pragma(#x)
+
+/*
+ * Usage: Use TODO("some message") / FIXME("some message") / NOTE("some message") to generate appropriate warnings
+ */
+#define TODO(x) GENERATE_PRAGMA(message("[TODO] " #x))
+#define FIXME(x) GENERATE_PRAGMA(message("[FIXME] " #x))
+#define NOTE(x) GENERATE_PRAGMA(message("[NOTE] " #x))
+
+/* Usage example:
+ * view.frame = CGRectMake(0, 0, MAGIC_NUMBER(77), MAGIC_NUMBER(90));
+ * // will warn you that you should replace values 77 and 90 with constants later, because magic numbers are bad.
+ */
+#define MAGIC_NUMBER(x) (({ FIXME(Replace magic number x with constant) }), (x))
+
+/* Usage example: call this in some IBAction that you will implement later,
+ * to generate a warning at compile time AND display an alert at runtime if the user trigger the IBAction
+ */
+#define NOT_IMPLEMENTED(warningMessage...) [[[[UIAlertView alloc] initWithTitle:@"Not implemented" \
+ message:[NSString stringWithFormat:@"%s",__PRETTY_FUNCTION__] \
+ delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease] show]; \
+ TODO(Implement this - warningMessage)
+
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit bb47f42

Please sign in to comment.