Skip to content

Commit

Permalink
resolved swiftlint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sajib-ghosh-iOS committed Feb 17, 2024
1 parent 44e3f9e commit e73508b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions PlistDesign/PlistDesign/Modules/Home/Controller/HomeVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ extension HomeVC: PlistHeaderCellProtocol {
extension HomeVC {

func plistItemTapped(item: Section, location: IndexPath) {
if item.sections.count > 0 {
if !item.sections.isEmpty {
if item.isOpened {
//Remove child
item.isOpened = false
Expand All @@ -177,7 +177,7 @@ extension HomeVC {
}

func plistItemTappedForSearch(item: Section, location: IndexPath) {
if item.sections.count > 0 {
if !item.sections.isEmpty {
if item.isOpened {
//Remove child
item.isOpened = false
Expand All @@ -198,7 +198,7 @@ extension HomeVC {
}

func collapseExpandedSections(parent: Section) {
if parent.sections.count > 0 {
if !parent.sections.isEmpty {
for section in parent.sections {
if (!section.isOpened) {
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class HomeViewModel {
for section in parent.sections {
childItems.add(section)
if section.isOpened {
childItems.addObjects(from: getChildItemsFor(parent: section) as! [Any])
childItems.addObjects(from: getChildItemsFor(parent: section) as? [Any] ?? [])
}
}
return childItems
Expand All @@ -51,7 +51,7 @@ class HomeViewModel {
for section in parent.sections {
section.isOpened = true
childItems.add(section)
childItems.addObjects(from: getAllChildItemsFor(parent: section) as! [Any])
childItems.addObjects(from: getAllChildItemsFor(parent: section) as? [Any] ?? [])
}
return childItems
}
Expand All @@ -63,18 +63,18 @@ class HomeViewModel {
section.isOpened = true
child.add(section)
if section.key.contains(searchText) || section.valueString.contains(searchText) {
childItems.addObjects(from: child as! [Any])
childItems.addObjects(from: child as? [Any] ?? [])
return childItems
}else if !section.isCollapsible {
print("Go back....\(section.key)")
child.removeAllObjects()
childItems.removeAllObjects()
collapseChild(childItems: childItems as! [Section])
collapseChild(childItems: childItems as? [Section] ?? [])
return childItems
}else{
child.addObjects(from: getChildItemsForSearch(parent: section, searchText: searchText) as! [Any])
child.addObjects(from: getChildItemsForSearch(parent: section, searchText: searchText) as? [Any] ?? [])
}
childItems.addObjects(from: child as! [Any])
childItems.addObjects(from: child as? [Any] ?? [])
}
return childItems
}
Expand All @@ -93,7 +93,7 @@ class HomeViewModel {
var section: Section!
for (key,value) in plistDict {
section = Section(isCollapsible: true, isOpened: false, key: key, level: 1, value: value)
convertDictToSections(value as! [String : Any], parentNode: section, level: 1)
convertDictToSections(value as? [String : Any] ?? [:], parentNode: section, level: 1)
}
sections.append(section)
}
Expand Down Expand Up @@ -140,7 +140,7 @@ class HomeViewModel {
func convertPlistToDictionary(_ plist: PlistRootModel) -> [String: Any]? {
var dict: [String: Any]?
if let jsonData = try? JSONEncoder().encode(plist){
let jsonString = String(data: jsonData, encoding: .utf8)!
let jsonString = String(data: jsonData, encoding: .utf8) ?? ""
if let data = jsonString.data(using: .utf8) {
let anyResult = try? JSONSerialization.jsonObject(with: data, options: [])
dict = anyResult as? [String: Any]
Expand Down

0 comments on commit e73508b

Please sign in to comment.