1234567891011121314151617181920212223242526 |
- //
- // String+Indexpath.swift
- // LMS
- //
- // Created by Suraj Kumar Mandal on 03/10/23.
- //
- import Foundation
- extension IndexPath {
- // Create a convenience initializer to parse a string into an IndexPath
- init?(string: String) {
- let components = string.components(separatedBy: ",")
- guard components.count == 2,
- let section = Int(components[0]),
- let row = Int(components[1]) else {
- return nil
- }
- self.init(row: row, section: section)
- }
- // Convert IndexPath to a string
- var stringValue: String {
- return "\(section),\(row)"
- }
- }
|