migueldeicaza / SwiftGodot

New Godot bindings for Swift
https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot-tutorials/
MIT License
1.07k stars 70 forks source link

Wrap GDictionary in a typed collection the same way GArray is #511

Open rrenna opened 1 month ago

rrenna commented 1 month ago

Is your feature request related to a problem? Please describe. Not a problem, but this would be a nice enhancement and would improve consistency.

Describe the solution you'd like I would like a wrapper around Godot's GDictionary (similar to ObjectCollection being a typed wrapper around GArray), let's say ObjectDictionary<Key,Value>.

Describe alternatives you've considered Alternative currently is to deal with GDictionary directly, you could write your own extension which could attempt to unwrap the type you know you stored (but this isn't nearly as safe) similar to boolForKey(), intForKey(), etc in UserDefaults or make something like value<T>forKey() -> T?.

Additional context I would use this immediately and interacting with dictionaries is a common enough use case that this would probably see heavy use with most others.

EstevanBR commented 1 month ago

I can take a crack at this I suppose.