Parse-Swift icon indicating copy to clipboard operation
Parse-Swift copied to clipboard

Request: Make backingStore optional rather than force unwrapped

Open alessdiimperio opened this issue 2 years ago • 2 comments
trafficstars

New Feature / Enhancement Checklist

Current Limitation

when launching tests one doesn't necessarily want the entire app and all it's dependencies setup and initialized. So if we are running tests we generally skip certain setup functions.

However after migrating to ParseSwift from the ObjC SDK i realized that we were getting crashes only when testing. The reason for the crash was calling Installation.current which returns an optional Installation. However the backingStore is force unwrapped so even though the value is optional the underlying force unwrapped store crashes. Note the cause is that we don't initialize parse when running tests.

if the backingStore was optional instead of force unwrapped it wouldn't crash but instead just return nil.

Feature / Enhancement Description

change ! to ? and allow for the backingStore to be optional rather than force unwrapping it. at worst you'll have to add a few ? here and there but will allow for returning an optional value where an optional value is to be returned.

Example Use Case

running tests without having to initialize all dependencies

Alternatives / Workarounds

🤷

3rd Party References

force unwrapping is 👿 no bueno :P

alessdiimperio avatar Sep 27 '23 19:09 alessdiimperio

Thanks for opening this issue!

  • 🎉 We are excited about your ideas for improvement!

https://github.com/parse-community/Parse-Swift/pull/445

alessdiimperio avatar Sep 27 '23 20:09 alessdiimperio