Code Monkey home page Code Monkey logo

snippets-ios's Introduction

Firebase iOS Snippets

This repository holds code snippets used in iOS documentation on firebase.google.com.

Contributing

We love contributions! See CONTRIBUTING.md for guidelines.

snippets-ios's People

Contributors

andrewheard avatar chflorian avatar dpebot avatar jlara310 avatar kevinthecheung avatar kroikie avatar kts224 avatar markarndt avatar markduckworth avatar morganchen12 avatar obitodarky avatar paulb777 avatar peterfriese avatar puf avatar ryanwilson avatar samtstern avatar thatfiredev avatar ulukaya avatar yimajo 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  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

snippets-ios's Issues

Incrementing counter throws error

The following function doesn't work:

func incrementCounter(ref: DocumentReference, numShards: Int) {
        // Select a shard of the counter at random
        let shardId = Int(arc4random_uniform(UInt32(numShards)))
        let shardRef = ref.collection("shards").document(String(shardId))

        shardRef.updateData([
            "count": FieldValue.increment(Int64(1))
        ])
    }

The FieldValue.increment(Int64(1)) part throws the following error:

Unsupported type: FSTNumericIncrementFieldValue (found in field count) (FIRInvalidArgumentException)

Value of type 'NSObject' has no member 'data' -- custom objects

let docRef = db.collection("cities").document("BJ")
docRef.getDocument { (document, error) in
let result = Result {
try document.flatMap {
try $0.data(as: City.self)
}
}
switch result {
case .success(let city):
if let city = city {
print("City: \(city)")
} else {
print("Document does not exist")
}
case .failure(let error):
print("Error decoding city: \(error)")
}
}

System information (OS, Device, etc): macOS 10.15.3, Xcode 11.3.1

What steps will reproduce the problem:

  1. Use the snippet in a Firestore project

What is the expected result?
The snippet will cast the Firestore document to the given type

What happens instead of that?
Error: "Value of type 'NSObject' has no member 'data'

Code, logs, or screenshot that illustrate the problem:
Screen Shot 2020-03-12 at 10 22 37 PM

Add Travis CI for build verification

Code in this repository should be automatically verified for at least compilation, and correctness as a bonus. Travis would be ideal for consistency but whatever is easiest.

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.