lib/cocoa: add services to `NSString` to convert to Nit strings
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 16 Nov 2015 21:01:17 +0000 (16:01 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 9 Feb 2016 19:41:47 +0000 (14:41 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/cocoa/foundation.nit

index 06c8ffd..c476df9 100644 (file)
@@ -30,6 +30,11 @@ end
 # Created using `Text::to_nsstring`.
 extern class NSString in "ObjC" `{ NSString * `}
        super NSObject
+
+       # Get an UTF8 encoded `char*` copy of `self`
+       fun utf8_string: NativeString in "ObjC" `{ return (char *)[self UTF8String]; `}
+
+       redef fun to_s do return utf8_string.to_s
 end
 
 redef class NativeString