Giter Site home page Giter Site logo

arrow's Introduction

Try it!

Download our starter iOS Project and see how our tools fit together in a typical iOS App:
Download Starter Project

Our mission

FreshOS is on a mission to provide iOS developers with simple tools to solve problems that 99% of us have. We believe developers should focus on valuable things like app logic, rather than casting the values of a JSON Parsing \o/. We thrive to make apis as simple as possible, yet flexible enough to handle 99% of use-cases. We believe in Unix-style libraries, that do one thing and do it well. Since we have control over those tools, they fit together nicely.

Solutions

AutoLayout - Stevia 🍃 Star

Write expressive autolayout code, readable and maintainable

Networking - ws ☁️ Star

Write concise networking code that leverages the power of Alamofire, promises and JSON Parsing

Async - then 🎬 Star

Make Async code delightful with Promises

Write minimalist JSON Parsing that infers type and doest get in the way of your models

Reduce Stress & Errors

Emit warnings and errors when Localizations are missing or unused

Emit warnings and errors when assets are missing or unused

Integrate Faster

Generate Swift code from Sketch designs

Who we are

<script src="//cdn.jsdelivr.net/github-cards/latest/widget.js"></script>
<script src="//cdn.jsdelivr.net/github-cards/latest/widget.js"></script> Let's not forget the 100+ people that contributed via pull requests, issues or even just talking to them :) This wouldn't be possible without them <3

Production ready

Our libraries have been Downloaded 175k+ times and already more than 3700+ Apps use freshOS tools!

Source : Cocoapods

Testimonials <3

Sketch to Swift is an amazing way to build quick prototypes. Always using to build small samples for my freelancing clients. Also using AssetChecker so I'm never messing up and breaking my code because I deleted or changed the name of an asset. I appreciate the work they put in freshOS and I'm glad AwesomeiOS has all of them
Lucas Farah - Admin @Awesome-iOS

Just want to say I love your different solutions. It's smart clean and easy to use.
Florent Douine - iOS Developer

Man I just wanted to tell you that Stevia, then, Arrow and ws is the most beautiful thing ever made! Really! This is beautiful!
Mauran Muthiah - Developer

This kind of libraries really is perfect. Very focused, obviously simple and useful, no magic, and small. They make development easier one step at a time.
Anonymous - HackerNews

Support/Contact

You can raise a github issue on the project you need support with or contact us at [email protected]

Hosting sponsored with 💚 by Muxu.Muxu

<script async defer src="https://buttons.github.io/buttons.js"></script>

arrow's People

Contributors

ankitspd avatar ezisazis avatar maxkonovalov avatar michalsrutek avatar peteallport avatar s4cha avatar viktorgardart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arrow's Issues

Release 3.0.3 not available on master

The latest tag 3.0.3 is missing from master branch and also from CocoaPods specs repo, it shows v.3.0.2 only. Because of this the ws pod fails to install:

[!] Unable to find a specification for Arrow3.0.3 depended upon by ws

Codable

TODO

Look for all differences with codable and list them.

Codable

  • 1 parsing fails all fails
  • Fine grained error handling
  • Need 1 custom parsing need to write all encodable method
  • Default parsing matching existing keys
  • No type inference (apart from dates)
  • Yields a new object
  • Quite verbose

Arrow

  • Best effort parsing, ignoring fails
  • No error handling (seldom used when getting data from a webservice)
  • No default parsing
  • Type inference out of the box (sy string identifier to an int for example)
  • Can parse and fill an existing object
  • Custom date parsing on a case per case basis
  • Very concise syntax

Having compared Arrow with Codable in a big iOS App, I still believe there's an advantage using Arrow.

@maxkonovalov I would love to know your feelings on Codable vs Arrow :)

Array of enums

Having trouble of parsing an array of enums.

var weekdays: [WeekDay]?

Response:

{
  "weekdays": [1, 3]
}

Parse:

self.weekdays <-- json["weekdays"]

Outcome is nil. :/

Value of type 'JSON' has no member 'collection'

Hi, I'm trying to iterate a JSON like so

if let collection = json.collection {
        for jsonEntry in collection {
            // things
        }
    }

and it says there is no member 'collection' in json. Checking the source code here shows that there actually is a 'collection'. I tried readding the libraries through Carthage as well but no dice.

How do I instantiate a model directly from a string containing json?

Hi, sorry to ask such a dumb question, but I can't figure out how to do a simple decode from a string containing my json to my model object:

struct doh: Codable {
  var homer = ""
}
extension doh : ArrowParsable {
  public mutating func deserialize(_ json: JSON) {
    homer <-- json["homer"]
  }
}

now to create one:

let myJson = "{ \"homer\": \"simpson\"}"
var aSimpson = doh()
aSimpson.deserialize(JSON(myJson)!)

this doesn't work! How do I create a doh object from the myJson string?

Thanks.

Doesn't compile on Linux OS

Using a Docker container to build my app with a reference to Arrow module, I get the following error:

Dockerfile:
FROM swift:latest as builder
WORKDIR /app
COPY ./Sources Sources/
COPY Package.swift Package.swift
RUN swift build -c release
CMD ["s"]h

Error:
/app/.build/checkouts/Arrow/Sources/Arrow/Arrow.swift:10:8: error: no such module 'CoreGraphics'

Cannot cast json to other type

Hi,

I'm wondering me to how I can cast the json values!

createdUser.id = Int32((json["id"]?.data as? Int32)!)

does not work.

id <-- Int32((json["id"]?.data as? Int32)!)

does not work.

id <--json["id"]

does not work.

Each time I get this error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[User setId:]: unrecognized selector sent to instance 0x60400047d100'

So do you have an idea about that? I'm surprised that nobody got the present error by the past :)
My rest service returns id (so Int32 for me on swift) and some dates that I have to parse.

netsted values problem

netsted values:
value <-- json["user.name"]

How to deal with the following situation

{
    "user": {
        "name": "Joannis"
    }
}
{
    "user.name": "Joannis"
}

<== not working for me

Hi,

I'm trying to parse my custom models but <== json["customModel"] not working for me!

Example :

struct oneModel: ArrowParsable {

var customModel                = CustomMedel()

init() {
}
init(json: JSON) {
    customModel <== json["customModel"]
}

}


struct CustomModel: ArrowParsable {

var id                  = Int()
var title               = String()

init() {

}
init(json: JSON) {
    id              <-- json["id"]
    title           <-- json["title"]
}

}

But I can use json.valueForKeyPath without any problems!!!

Doesn't compile with snapshot 4-12

Hi,

the newest version of Arrow (2.0.1) doesn't compile with snapshot 4-12.

→ swift build
Cloning https://github.com/s4cha/Arrow.git
Resolved version: 2.0.1
Compiling Swift Module 'Arrow' (2 sources)
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:34:33: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T>(inout left: T, right: JSON?) {
                    ~~~~~       ^
                                inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:43:33: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T>(inout left: T?, right: JSON?) {
                    ~~~~~       ^
                                inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:47:30: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
func parseType<T>(inout left:T?,right:JSON?) {
                  ~~~~~      ^
                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:65:51: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T: RawRepresentable>(inout left: T, right: JSON?) {
                                      ~~~~~       ^
                                                  inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:73:51: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T: RawRepresentable>(inout left: T?, right: JSON?) {
                                      ~~~~~       ^
                                                  inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:83:46: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T:ArrowParsable>(inout left:T, right: JSON?) {
                                  ~~~~~      ^
                                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:91:46: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T:ArrowParsable>(inout left:T?, right: JSON?) {
                                  ~~~~~      ^
                                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:101:46: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T:ArrowParsable>(inout left:[T], right: JSON?) {
                                  ~~~~~      ^
                                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:113:46: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T:ArrowParsable>(inout left:[T]?, right: JSON?) {
                                  ~~~~~      ^
                                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:127:30: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- (inout left: NSDate, right: JSON?) {
                 ~~~~~       ^
                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:135:30: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- (inout left: NSDate?, right: JSON?) {
                 ~~~~~       ^
                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:139:27: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
func parseDate(inout left:NSDate?,right:JSON?) {
               ~~~~~      ^
                          inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:163:30: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- (inout left: NSURL, right: JSON?) {
                 ~~~~~       ^
                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:171:30: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- (inout left: NSURL?, right: JSON?) {
                 ~~~~~       ^
                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:175:26: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
func parseURL(inout left:NSURL?, right:JSON?) {
              ~~~~~      ^
                         inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:187:32: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
func parseArray<T>(inout left: [T]?, right: JSON?) {
                   ~~~~~       ^
                               inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:196:33: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T>(inout left: [T], right: JSON?) {
                    ~~~~~       ^
                                inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:204:33: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T>(inout left: [T]?, right: JSON?) {
                    ~~~~~       ^
                                inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:66:17: error: 'RawValue' is not a member type of 'T'
    var temp: T.RawValue? = nil
              ~ ^
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:74:17: error: 'RawValue' is not a member type of 'T'
    var temp: T.RawValue? = nil
              ~ ^
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:85:17: error: type 'T' has no member 'init'
        var t = T.init()
                ^ ~~~~
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:93:17: error: type 'T' has no member 'init'
        var t = T.init()
                ^ ~~~~
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:150:27: error: value of type 'NSDateFormatter' has no member 'dateFromString'
            if let date = dateFormatter.dateFromString(s)  {
                          ^~~~~~~~~~~~~ ~~~~~~~~~~~~~~
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:34:33: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T>(inout left: T, right: JSON?) {
                    ~~~~~       ^
                                inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:43:33: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T>(inout left: T?, right: JSON?) {
                    ~~~~~       ^
                                inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:47:30: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
func parseType<T>(inout left:T?,right:JSON?) {
                  ~~~~~      ^
                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:65:51: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T: RawRepresentable>(inout left: T, right: JSON?) {
                                      ~~~~~       ^
                                                  inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:73:51: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T: RawRepresentable>(inout left: T?, right: JSON?) {
                                      ~~~~~       ^
                                                  inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:83:46: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T:ArrowParsable>(inout left:T, right: JSON?) {
                                  ~~~~~      ^
                                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:91:46: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T:ArrowParsable>(inout left:T?, right: JSON?) {
                                  ~~~~~      ^
                                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:101:46: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T:ArrowParsable>(inout left:[T], right: JSON?) {
                                  ~~~~~      ^
                                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:113:46: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T:ArrowParsable>(inout left:[T]?, right: JSON?) {
                                  ~~~~~      ^
                                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:127:30: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- (inout left: NSDate, right: JSON?) {
                 ~~~~~       ^
                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:135:30: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- (inout left: NSDate?, right: JSON?) {
                 ~~~~~       ^
                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:139:27: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
func parseDate(inout left:NSDate?,right:JSON?) {
               ~~~~~      ^
                          inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:163:30: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- (inout left: NSURL, right: JSON?) {
                 ~~~~~       ^
                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:171:30: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- (inout left: NSURL?, right: JSON?) {
                 ~~~~~       ^
                             inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:175:26: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
func parseURL(inout left:NSURL?, right:JSON?) {
              ~~~~~      ^
                         inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:187:32: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
func parseArray<T>(inout left: [T]?, right: JSON?) {
                   ~~~~~       ^
                               inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:196:33: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T>(inout left: [T], right: JSON?) {
                    ~~~~~       ^
                                inout
/Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/Packages/Arrow-2.0.1/Source/Arrow.swift:204:33: error: 'inout' before a parameter name is not allowed, place it before the parameter type instead
public func <-- <T>(inout left: [T]?, right: JSON?) {
                    ~~~~~       ^
                                inout
<unknown>:0: error: build had 1 command failures
error: exit(1): /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a.xctoolchain/usr/bin/swift-build-tool -f /Users/aevitas/Desktop/Projects/Swift/Server/league-downloader/.build/debug.yaml default

Is the plan to support Swift3?

Swift 4

Swift 4 is a game changer !
We'll have to look at how Arrow integrates in this new ecosystem.

Support optional data for custom models

Hi! In some cases optional vars for custom models are needed in addition to plain swift types.

For example:

struct Profile {
    var identifier = 0
    var stats: Stats? = nil
}

extension Profile: ArrowParsable {
    init(json: JSON) {
        identifier <-- json["id"]
        stats <== json["stats"] // error
    }
}

The current implementation gives the following error for the above code: Cannot convert value of type 'Stats?' to expected argument type 'inout _'.

Privacy Manifest

Hello,

At WWDC23 Apple announced that apps and SDKs that make use of certain "required reason" APIs etc will need to provide a privacy manifest.
Does UIView-Shimmer need to include this manifest?

Here are some useful references:

https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_data_use_in_privacy_manifests
https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api
https://developer.apple.com/videos/play/wwdc2023/10060/

Thanks

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.