2

I have the following code which retrieves list of operating systems and list of their counts. I would like to get the count values and save them to an array:

let query = mdm.select(os,os.count)
                .filter(os != "")
                .group(os)

let results = try! db.prepare(query)

for items in results
{
    countArray.append(items[os])
    countOSArray.append(items[os.count]) // This does not work

}

I know how to get normal column results but how do you reference a column that returns a list of counts?

0

1 Answer 1

1

After some research the answer is as follows:

countOSArray.append("\(items[os.count])")

Since the count returns an int, the value must be converted to a string using the double quotes and \

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.