André Luiz André Luiz - 1 year ago 95
Swift Question

Find the item with the biggest value in a dictionary

I'm implementing some logic to get the closest Beacon and to do that I created a Dictionary where I insert some Measures. My problem is that I don't know how to get the item with the biggest value. Some code below:

struct objBeacon {
var accuracy : Float
var rssi : Float
var positionInList : Float

var readBeacons = [String:objBeacon]()

My goal is to get the item (objBeacon) with the biggest
value, how can I do that without looping through the list?

Answer Source

The simplest way is this


Hope this helps

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download