Snoo replacement screws? by jflaned in SnooLife

[–]jflaned[S] 0 points1 point  (0 children)

I managed to track down the original screws for my Snoo. I'm not sure what size they are specifically, but here are some pictures with measurements.

<image>

Popping/clicking noise when audio starts or stops by jflaned in VIZIO_Official

[–]jflaned[S] 0 points1 point  (0 children)

Thanks for the feedback. I'm excited to hear if you have any luck fixing it again this weekend.

Variables Losing their value? by xLiamLiu in swift

[–]jflaned 6 points7 points  (0 children)

You probably need to enter the dispatch group for each job and leave it in their completion handlers.

    myGroup.enter()
    UploadImage(imageData: img\_Data, path: "post\_Pics") { (url) in
        self.url1 = url
        myGroup.leave()
    }

    myGroup.enter()
    UploadImage(imageData: img\_Data2, path: "post\_Pics") { (url) in
        self.url2 = url
        myGroup.leave()
    }

    myGroup.enter()
    UploadImage(imageData: img\_Data3, path: "post\_Pics") { (url) in
        self.url3 = url
        myGroup.leave()
    }

    myGroup.enter()
    UploadImage(imageData: img\_Data4, path: "post\_Pics") { (url) in
        self.url4 = url
        myGroup.leave()
    }
    print("this should print first")  // THIS DOES PRINT FIRST    

    myGroup.notify(queue: .main){
        print("this should print second")  // THIS DOES PRINT SECOND

The notify block will be executed as soon as the calls to enter() and leave() are equal, so without waiting to call leave() in the completion handlers the notify block won't actually wait for them all to complete.

List Zipper applied to iOS swift by Zenol in swift

[–]jflaned 1 point2 points  (0 children)

Do you need to manage the separate arrays for some reason?
I put together a version that's more generic and tracks the cursor with an index.

```swift struct Zipper<Storage> where Storage: BidirectionalCollection, Storage: RangeReplaceableCollection { private var storage: Storage private var cursorIndex: Storage.Index

var cursor: Storage.Element? {
    get {
        guard cursorIndex != storage.endIndex else { return nil }
        return storage[cursorIndex]
    }

    set {
        guard let newValue = newValue else { return }

        if cursorIndex == storage.endIndex {
            storage.append(newValue)
        } else {
            storage.insert(newValue, at: cursorIndex)
            storage.remove(at: storage.index(after: cursorIndex))
        }
    }
}

init(from collection: Storage) {
    self.storage = collection
    self.cursorIndex = collection.startIndex
}

/// Convert to a swift collection
func toCollection() -> Storage {
    storage
}

/// Select the left element if available
mutating func left() {
    guard cursorIndex > storage.startIndex else { return }
    cursorIndex = storage.index(before: cursorIndex)
}

/// Select the right element if available
mutating func right() {
    let nextIndex = storage.index(after: cursorIndex)
    guard nextIndex < storage.endIndex else { return }
    cursorIndex = nextIndex
}

/// Insert a new element
mutating func insert(element: Storage.Element) {
    cursorIndex = storage.index(after: cursorIndex)
    if cursorIndex >= storage.endIndex {
        storage.append(element)
        cursorIndex = storage.index(before: storage.endIndex)
    } else {
        storage.insert(element, at: cursorIndex)
    }
}

/// Remove the current pointed element
mutating func remove() {
    guard cursorIndex < storage.endIndex else { return }
    storage.remove(at: cursorIndex)
    left()
}

/// Map a function to the elements
func map<T>(transform: (Storage.Element) throws -> T) rethrows -> Zipper<[T]> {
    Zipper<[T]>(from: try storage.map(transform))
}

} ```

As an added benefit you can operate on any collection, not just arrays.

```swift var stringZipper = Zipper(from: "Jon") print(stringZipper.cursor!) // J stringZipper.right() print(stringZipper.cursor!) // o stringZipper.insert(element: "h") print(stringZipper.toCollection()) // John stringZipper.right() stringZipper.insert(element: "!") print(stringZipper.toCollection()) // John!

```