To start with, I will need to figure out how to get a binary representation of an integer. Then I will simply loop through the numbers higher and lower until I find an integer that has the same number of 1's or I hit Int.max or Int.min. I will then return these numbers in a tuple.
Once I had completed my function, I realized that I should have been using UInt instead of Int as the instructions said it should take in a positive integer, so I switched all my code to be working with UInts. I ended up making a couple extensions, that made finding the nubmer of "1"s in the binary representation much shorter to write. Then it was just a matter of creating two for loops, one going up, and one going down to find the next highest and lowest integers with the same number of "1"s in their binary string.
This is my result:
func sameNumberOfBinaryOnes(_ number: UInt) -> (higher: UInt?, lower: UInt?) {
let numBinaryOnes = number.numBinaryOnes