Skip to content

Instantly share code, notes, and snippets.

@mchakravarty
Last active December 14, 2015 00:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mchakravarty/5001207 to your computer and use it in GitHub Desktop.
Save mchakravarty/5001207 to your computer and use it in GitHub Desktop.
{-# LANGUAGE TemplateHaskell, QuasiQuotes #-}
module TestInlineObjC (objc_initialise, dumpURL) where
import Language.C.Quote.ObjC
import InlineObjC
objc_import ["<Foundation/Foundation.h>"]
dumpURL :: String -> IO ()
dumpURL urlString
= do
{ urlData <- $(objc 'urlString [cexp|
[NSString stringWithContentsOfURL: [NSURL URLWithString: [NSString stringWithUTF8String: urlString]]
encoding: NSUTF8StringEncoding
error: NULL]
|])
; putStr urlData
}
objc_emit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment