Giter VIP home page Giter VIP logo

networkobjects's Introduction

NetworkObjects

Join the chat at https://gitter.im/colemancda/NetworkObjects Carthage compatible

NetworkObjects is a distributed object graph inspired by Apple's WebObjects. This framework compiles for OS X and iOS and serves as the foundation for building powerful Swift servers as well as serving as a cross-platform alternative to Cocoa's Distributed Objects. Powered by Core Data and Grand Central Dispatch, the framework comes with server and client classes which abstract away advanced networking code so the developer can focus on distributing Core Data entities over a network.

Auto-Generated REST Server

The Server class, as its name implies, broadcasts a Core Data managed object context over the network (via HTTP) in way that it can be incrementally accessed and modified. It will also ask the data source to keep track of unique identifiers (unsigned integer) assigned to an instance of an entity. This will create a schema as follows:

Method URL JSON Request Body JSON Response Body
POST /entityName Yes (Optional) Yes (ResourceID Only)
GET /entityName/id No Yes
PUT /entityName/id Yes No
DELETE /entityName/id No No

The JSON recieved from or sent to the server follows the following schema:

{
    "attributeName": attributeValue,
    "toOneRelationshipName": {"DestinationEntityName": resourceID}
    "toManyRelationshipName": [{"DestinationEntityName": resourceID1}, {"DestinationEntityName": resourceID2}, ...]
}

Nil values are ommited from the JSON Body in GET responses. In PUT or POST requests it is represented by the JSON null type.

Attribute Values are converted in the following way:

CoreData Value JSON Value
String String
Number Number
Date ISO8601 String
Data Base64 String
Transformable Base64 String
Nil Null (PUT, POST), Ommited from JSON body in GET

Optionally the Server can create function and search URLs for special requests

Method URL
POST /search/entityName
POST /entityName/id/functionName

Server Permissions / Access Control

By default the server provides no authentication, but the Server can use SSL and the can ask its delegate for access control based on HTTP headers, making authentication completely customizeable. In addition to HTTP, the Server's data source and delegate protocols are built to be agnostic to connection protocols, making it open to other protocols in the future (WebSockets support is planned).

There are two delegate protocol methods for access control:

func server(Server, statusCodeForRequest request: ServerRequest, managedObject: NSManagedObject?, context: NSManagedObjectContext?) -> ServerStatusCode
func server(Server, permissionForRequest request: ServerRequest, managedObject: NSManagedObject?, context: NSManagedObjectContext?, key: String?) -> ServerPermission

Client-side caching

The Store class is what clients will use to communicate with the server. A dateCached attribute can be optionally added at runtime for cache validation.

Deployment

The NetworkObjects framework is built as dynamically linked frameworks OS X and iOS. It requires Xcode 7 and a minimum operating system of iOS 8 or OS X 10.9.

Example

  • NetworkObjectsUI - iOS framework that provides view and controller classes for easily integrating NetworkObjects into your iOS app.
  • Pedido - Open Source suite of client / server apps for restaurant ordering system. Powered by NetworkObjects.

Support and Documentation

If you have any questions you can contact me on Twitter at @colemancda or send me an IM me on Gitter.

networkobjects's People

Contributors

colemancda avatar gitter-badger avatar

Watchers

Hunter.Hu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.