Last active
August 29, 2015 14:16
-
-
Save langford/1506f5629644a22c03b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AddressBook | |
import UIKit | |
typealias CThingPtr = UnsafeMutablePointer <ABRecordRef> | |
func cthing_dispose(o:CThingPtr?)->(){ | |
} | |
func cthing_create(cString:UnsafePointer<Int8>)->CThingPtr{ | |
return nil | |
} | |
func possible_cthing_create(cString:UnsafePointer<Int8>)->CThingPtr?{ | |
//I don't know what you need to do here for your particular Cthing to check for existance | |
return cthing_create(cString) | |
} | |
class Thing { | |
let thing:CThingPtr | |
convenience init?(url:NSURL) { | |
self.init(name:url.absoluteString!) | |
} | |
init?(name:String) { | |
if let path = NSBundle.mainBundle().URLForResource(name, withExtension: "thing")?.path , | |
cstring = path.cStringUsingEncoding(NSUTF8StringEncoding) , | |
aThing = possible_cthing_create(cstring) { | |
self.thing = aThing | |
}else{ | |
self.thing = nil | |
return nil | |
} | |
} | |
deinit { | |
cthing_dispose(thing) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment