Permalink
Browse files

new api's CWPrintLine() and CWPrintfLine()

  • Loading branch information...
1 parent 8543386 commit c953daeb524480f4eacafae1ec4ad2cbf0450802 @Machx committed Aug 16, 2012
Showing with 36 additions and 0 deletions.
  1. +14 −0 Source/CWFoundation.h
  2. +22 −0 Source/CWFoundation.m
View
@@ -72,3 +72,17 @@ const char *CWUUIDCStringPrependedWithString(NSString *preString);
@param block the block to be executed on the next runloop on the main thread
*/
void CWNextRunLoop(dispatch_block_t block);
+
+/**
+ Inspired by println in Go, Prints all the variables (space seperated) to NSLog()
+
+ @args all the variables you want printed to NSLog()
+ */
+void CWPrintLine(NSArray *args);
+
+/**
+ Inspired by println in Go, Prints all the variables (space seperated) with a newline appended to printf()
+
+ @args all the variables you want printed to printf()
+ */
+void CWPrintfLine(NSArray *args);
View
@@ -60,3 +60,25 @@ void CWNextRunLoop(dispatch_block_t block)
{
dispatch_async(dispatch_get_main_queue(), block);
}
+
+void CWPrintLine(NSArray *args)
+{
+ NSMutableString *printString = [[NSMutableString alloc] init];
+
+ [args cw_each:^(id obj, NSUInteger index, BOOL *stop) {
+ [printString appendFormat:@"%@ ",obj];
+ }];
+
+ NSLog(@"%@",printString);
+}
+
+void CWPrintfLine(NSArray *args)
+{
+ NSMutableString *printString = [[NSMutableString alloc] init];
+
+ [args cw_each:^(id obj, NSUInteger index, BOOL *stop) {
+ [printString appendFormat:@"%@ ",obj];
+ }];
+
+ printf("%s\n",[printString UTF8String]);
+}

0 comments on commit c953dae

Please sign in to comment.