Giter VIP home page Giter VIP logo

spaghetti's Introduction

Spaghetti

A Cocoa framework for object mapping to and from not-so-RESTful web services.

Introduction

Connecting your app to a web server can be such a joy. Especially if that web server provides an API that was designed in cooperation with you and using the conventions of REST. Unfortunately this isn't always the case. Small design decision have big consequences for the implementation on the client side, leaving you with your super-RESTful framework that is a pain to connect to.

Spaghetti is a framework for connecting your app to a web server, but doesn't make too many assumptions on how RESTy that web server is. It consists of separate layers of abstraction that can be customized depending on the needs of the API. This makes it easy to connect to REST and less-than-horrible in other cases.

Features

  • Object mapping to and from Core Data, in-memory, or your custom object store.
  • Support JSON, XML, and URL encoded data formats.
  • Flexible key-path system for referencing attributes and relations.
  • HTTP-independent endpoint and call definitions.
  • Call scheduler.
  • Built-in statistics, validation, logging and debugging tools.
  • Example code and documentation.

Getting Started

Clone this repo and take a look at the demo code.

Overview

           +----------------+ +----------------+ +----------------+
Manage     |    Backend     | |    Schedule    | |    Operation   |
           +----------------+ +----------------+ +----------------+

           +----------------+ +----------------+ +----------------+
Calling    |    Endpoint    | |      Call      | |   Dialogue     |
           +----------------+ +----------------+ +----------------+

           +----------------+ +----------------+ +----------------+
Mapping    |     Mapping    | |      Path      | |    Transform   |
           +----------------+ +----------------+ +----------------+

           +----------------+ +----------------+ +----------------+
Store      |      Store     | |    ObjectID    | |   ObjectType   |
           +----------------+ +----------------+ +----------------+

           +----------------+ +----------------+
Utilities  |     Parser     | |      Path      |
           +----------------+ +----------------+

Service

At top we have a set loosely related classes that provide high-level functionality to manage and schedule operations.

Calling

The connection layer deals with creation and configuration of calls over the line.

Mapping

Mapping is the process of transforming data from a generic dictionary format to objects of custom classes.

Store

Utilities

The mapping and storing of data use a set of custom utilities that provide functionality not readily available in Apple's frameworks:

  • NWSParser provides a generic interface for turning data into a nested structure of dictionaries and array. Their output is recursively traversed during the mapping process.
  • NWSPath is an extension on the key path in KVC. It allows custom logic to be added to path definitions, for example to access array elements or provide constant values.

Build in XCode

The source comes with an XCode project file that should take care of building the library and running the demo app. To use Spaghetti in your project, you can build a static Framework using the SpaghettiUniveral target.

Documentation

Documentation generated and installed by running from the project root:

appledoc -p Spaghetti -v 0.1 -c Noodlewerk --company-id com.noodlewerk -o . .

See the appledoc documentation for more info.

License

Spaghetti is licensed under the terms of the BSD 2-Clause License, see the included LICENSE file.

Authors

spaghetti's People

Contributors

spacyricochet avatar farmertjes avatar jvdijk avatar

Stargazers

David Rico avatar Alex Kessinger avatar Julián Romero avatar  avatar Ra Kowalski avatar Phillip Calvin avatar Satoshi Namai avatar Michael Hood avatar Alex Shevchenko avatar  avatar Christopher Owen avatar Marcelo Moscone avatar  avatar Rafa Barberá avatar Javi avatar Bill So avatar Daniel Hejl avatar mayulu avatar Davide Cenzi avatar Eric Beekman avatar Tobias Klonk avatar Timo Haberkern avatar Leo avatar

Watchers

Leo avatar mayulu avatar Bill So avatar  avatar James Cloos avatar noodlewerk avatar  avatar  avatar Gyán Santokhi avatar  avatar  avatar

spaghetti's Issues

iOS7 crash when an NSFetchedResultsController updates according to the results of an NWSCall.

When an NSFetchedResultsController updates after a _managedObjectContextDidChange caused by a finished NWSCall, the app crashes. Strangely enough, this only happens after the first app launch. During the first launch, the entire app functions as normal. This includes performing the call multiple times.

To reproduce:
With project iWhisper, checkout develop branch.
Run for the first time. App functions as normal. Note the fact that tapping on one of the routes and going back causes a new call to be performed, during which the app doesn't crash.
Run for second time, enjoy the crash.

To make it stop:
Comment either the getRoutesWithOwner call in the IWRouteListTableViewController's viewWillAppear or return nil in the fetchedResultsControllerForTableViewDataSource: method.

Crash log:

Incident Identifier: 98AAD388-24E7-4905-89D3-821A0A2056ED
CrashReporter Key:   d2351b57f828cd0a24fb5e13c99f1fa50e03299e
Hardware Model:      iPod5,1
Process:             iWhisper [1436]
Path:                /var/mobile/Applications/8AB4BCC3-164F-40F4-A0EC-21FFC2C60162/iWhisper.app/iWhisper
Identifier:          com.iwhisper.iWhisper
Version:             37 (1.3)
Code Type:           ARM (Native)
Parent Process:      launchd [1]

Date/Time:           2013-08-15 16:38:03.785 +0200
OS Version:          iOS 7.0 (11A4449a)
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation                  0x2f62ff86 __exceptionPreprocess + 126
1   libobjc.A.dylib                 0x396036aa objc_exception_throw + 34
2   CoreFoundation                  0x2f56b712 -[__NSDictionaryM setObject:forKey:] + 814
3   CoreData                        0x2f3ad4f2 -[NSFetchedResultsController(PrivateMethods) _preprocessUpdatedObjects:insertsInfo:deletesInfo:updatesInfo:sectionsWithDeletes:newSectionNames:treatAsRefreshes:] + 1218
4   CoreData                        0x2f3abe3e -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] + 1590
5   CoreFoundation                  0x2f5f210c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 8
6   CoreFoundation                  0x2f566302 _CFXNotificationPost + 1714
7   Foundation                      0x2ff2b158 -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
8   CoreData                        0x2f3ab7e6 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 74
9   CoreData                        0x2f3ab77e -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] + 294
10  CoreData                        0x2f3c8ad8 -[NSManagedObjectContext(_NSInternalChangeProcessing) _postRefreshedObjectsNotificationAndClearList] + 108
11  CoreData                        0x2f3aa3f4 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 3852
12  CoreData                        0x2f3a34f4 _performRunLoopAction + 312
13  CoreFoundation                  0x2f5fb1c0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 16
14  CoreFoundation                  0x2f5f8b64 __CFRunLoopDoObservers + 280
15  CoreFoundation                  0x2f5f8ea6 __CFRunLoopRun + 726
16  CoreFoundation                  0x2f563cd2 CFRunLoopRunSpecific + 518
17  CoreFoundation                  0x2f563ab6 CFRunLoopRunInMode + 102
18  GraphicsServices                0x33fa92d6 GSEventRunModal + 134
19  UIKit                           0x31b6820c UIApplicationMain + 1132
20  iWhisper                        0x0007314c main (main.m:16)
21  libdyld.dylib                   0x39b27ab2 tlv_initializer + 2


<...snip...>

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.