Graph Story created Theo, an open-source framework written in Swift that provides an interface for interacting with Neo4j. Theo offers CRUD-style operations for nodes and relationships, and transaction support, in addition to standard Cypher queries.

To install, follow these steps:

  • Add it as a submodule to your existing project.git submodule add git@github.com:GraphStory/neo4j-ios.git
  • Open the Theo folder, and drag Theo.xcodeproj into the file navigator of your Xcode project.
  • In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
  • In the tab bar at the top of that window, open the "Build Phases" panel.
  • Expand the "Link Binary with Libraries" group, and add Theo.framework.
  • Click on the + button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add Theo.framework.

Use it in your code like so:

let theo: Client = Client(baseURL: "hostname.com", user: "username", pass: "password")

// create a node
let node = Node()
let randomString: String = NSUUID().UUIDString

node.setProp("propertyKey_1", propertyValue: "propertyValue_1" + randomString)
node.setProp("propertyKey_2", propertyValue: "propertyValue_2" + randomString)

theo.createNode(node, completionBlock: {(node, error) in
    print("new node \(node)")
});

// execute a Cypher query
let theo: Client = Client(baseURL: configuration.host, user: configuration.username, pass: configuration.password)
let cyperQuery: String = "MATCH (u:User {username: {user} }) WITH u MATCH (u)-[:FOLLOWS*0..1]->f WITH DISTINCT f,u MATCH f-[:LASTPOST]-lp-[:NEXTPOST*0..3]-p RETURN p.contentId as contentId, p.title as title, p.tagstr as tagstr, p.timestamp as timestamp, p.url as url, f.username as username, f=u as owner"
let cyperParams: Dictionary<String, AnyObject> = ["user" : "ajordan"]

theo.executeCypher(cyperQuery, params: cyperParams, completionBlock: {(cypher, error) in
    println("response from cyper \(cypher)")
})
Did this answer your question?