Saturday, November 7, 2026
HomeiOS Developmentios - Making a secure subscript slice of a binding array

ios – Making a secure subscript slice of a binding array

[ad_1]

I’ve a secure subscript extension on Array to offer me an ArraySlice from a Vary like this:

extension Array {
  subscript(secure vary: Vary<Index>) -> ArraySlice<Aspect>? {
    if vary.endIndex > endIndex {
      if vary.startIndex >= endIndex {
        return nil
      } else {
        return self[range.startIndex..<endIndex]
      }
    } else {
      return self[range]
    }
  }
}

I’ve a use case for needing a slice of a binding of an array such that I can do that:

let userSlice = $customers[safe: 0..<20]

This could return Slice<Binding<[User]>>. How can I alter the above code to work with a Binding of an Array?

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments