Commit dc38e614 authored by pete谢兆麟's avatar pete谢兆麟

代码修改

parent 87fa4d4a
......@@ -423,8 +423,7 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHMessageSessionCell.cellReuseIdentifier, for: indexPath) as! YHMessageSessionCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHMessageSessionCell.cellReuseIdentifier, for: indexPath) as? YHMessageSessionCell else { return UITableViewCell() }
if 0 <= indexPath.row && indexPath.row < msgArr.count {
let model = msgArr[indexPath.row]
cell.updateModel(model)
......
......@@ -23,7 +23,7 @@ class YHListViewModel: YHBaseViewModel {
callBackBlock(false, nil)
return
}
self.model = (result as! [YHHKEventModel])
self.model = (result as? [YHHKEventModel] ?? [])
callBackBlock(true, nil)
} else {
let error: YHErrorModel = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg)
......
......@@ -139,7 +139,7 @@ extension YHAboutGalaxyViewController: UITableViewDelegate, UITableViewDataSourc
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHAboutUsCell.cellReuseIdentifier, for: indexPath) as! YHAboutUsCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHAboutUsCell.cellReuseIdentifier, for: indexPath) as? YHAboutUsCell else { return UITableViewCell() }
let item = items[indexPath.row]
cell.item = item
return cell
......
......@@ -150,7 +150,9 @@ extension YHAboutUsViewController: UICollectionViewDelegateFlowLayout, UICollect
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHAboutUsAdvantageCell.cellReuseIdentifier, for: indexPath) as! YHAboutUsAdvantageCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHAboutUsAdvantageCell.cellReuseIdentifier, for: indexPath) as? YHAboutUsAdvantageCell else {
return UICollectionViewCell()
}
cell.advantateItem = items[indexPath.row]
return cell
......
......@@ -307,12 +307,11 @@ extension YHMyNewViewController: UITableViewDelegate, UITableViewDataSource {
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHMySectionGroupCell.cellReuseIdentifier, for: indexPath) as! YHMySectionGroupCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHMySectionGroupCell.cellReuseIdentifier, for: indexPath) as? YHMySectionGroupCell else { return UITableViewCell() }
if 0 <= indexPath.row, indexPath.row < functionGroupArr.count {
let group: YHFunctionGroupInfo = functionGroupArr[indexPath.row]
if group.type == .score {
let cell2 = tableView.dequeueReusableCell(withIdentifier: YHMyFunctionGroup2Cell.cellReuseIdentifier, for: indexPath) as! YHMyFunctionGroup2Cell
guard let cell2 = tableView.dequeueReusableCell(withIdentifier: YHMyFunctionGroup2Cell.cellReuseIdentifier, for: indexPath) as? YHMyFunctionGroup2Cell else { return UITableViewCell() }
cell2.updateGroup(group)
cell2.clickItem = {
[weak self] item in
......
......@@ -97,7 +97,8 @@ extension YHMyNotifySettingVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyPermissionCell.cellReuseIdentifier, for: indexPath) as! YHMyPermissionCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHMyPermissionCell.cellReuseIdentifier, for: indexPath) as? YHMyPermissionCell else { return UITableViewCell() }
if 0 <= indexPath.row && indexPath.row < items.count {
let item = items[indexPath.row]
cell.updateModel(item)
......
......@@ -180,8 +180,8 @@ extension YHMyPermissionSettingVC: UITableViewDelegate, UITableViewDataSource {
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHMyPermissionCell.cellReuseIdentifier, for: indexPath) as! YHMyPermissionCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHMyPermissionCell.cellReuseIdentifier, for: indexPath) as? YHMyPermissionCell else { return UITableViewCell() }
if 0 <= indexPath.row && indexPath.row < items.count {
let item = items[indexPath.row]
cell.updateModel(item)
......
......@@ -228,7 +228,8 @@ extension YHMySettingViewController: UITableViewDelegate, UITableViewDataSource
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHMySettingCell.cellReuseIdentifier, for: indexPath) as! YHMySettingCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHMySettingCell.cellReuseIdentifier, for: indexPath) as? YHMySettingCell else { return UITableViewCell() }
if 0 <= indexPath.row && indexPath.row < items.count {
let item: PersonalModuleItem = items[indexPath.row]
cell.titleLabel.text = item.title
......
......@@ -376,7 +376,8 @@ extension YHMyViewController: UITableViewDelegate, UITableViewDataSource {
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHPersonalCenterCell.cellReuseIdentifier, for: indexPath) as! YHPersonalCenterCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHPersonalCenterCell.cellReuseIdentifier, for: indexPath) as? YHPersonalCenterCell else { return UITableViewCell() }
let item: PersonalModuleItem = items[indexPath.row]
cell.updateItem(item: item)
return cell
......
......@@ -159,7 +159,7 @@ extension YHVipLevelRightViewController {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if tableView.tag == titleListTag {
let cell = tableView.dequeueReusableCell(withIdentifier: YHVipLevelRightTitleCell.cellReuseIdentifier, for: indexPath) as! YHVipLevelRightTitleCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHVipLevelRightTitleCell.cellReuseIdentifier, for: indexPath) as? YHVipLevelRightTitleCell else { return UITableViewCell() }
if 0 <= indexPath.section, indexPath.section < arr.count {
let a = arr[indexPath.section]
if 0 <= indexPath.row, indexPath.row < a.count {
......@@ -170,8 +170,8 @@ extension YHVipLevelRightViewController {
}
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: YHVipLevelRightInfoCell.cellReuseIdentifier, for: indexPath) as! YHVipLevelRightInfoCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHVipLevelRightInfoCell.cellReuseIdentifier, for: indexPath) as? YHVipLevelRightInfoCell else { return UITableViewCell() }
if 0 <= indexPath.section, indexPath.section < arr.count {
let a = arr[indexPath.section]
if 0 <= indexPath.row, indexPath.row < a.count {
......
......@@ -258,7 +258,7 @@ extension YHEditInterestViewController: UICollectionViewDelegate, UICollectionVi
let size = self.getwith(font: UIFont.systemFont(ofSize: 12), height: 24, string: model.name)
var width = size.width + 12*2.0
if !model.isNormal && !model.isSelect {
width = width + 22
width += 22
}
if width > 226.0 {
width = 226.0
......@@ -268,7 +268,7 @@ extension YHEditInterestViewController: UICollectionViewDelegate, UICollectionVi
// 返回自定义单元格
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHSearchInfoHistoryCell.cellReuseIdentifier, for: indexPath) as! YHEditInterestViewCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHSearchInfoHistoryCell.cellReuseIdentifier, for: indexPath) as? YHEditInterestViewCell else { return UICollectionViewCell() }
if indexPath.section == 0 {
cell.dataSource = normalItems[indexPath.item]
} else {
......@@ -307,7 +307,8 @@ extension YHEditInterestViewController: UICollectionViewDelegate, UICollectionVi
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == UICollectionView.elementKindSectionHeader {
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "YHEditInterestViewHeaderView", for: indexPath) as! YHEditInterestViewHeaderView
guard let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "YHEditInterestViewHeaderView", for: indexPath) as? YHEditInterestViewHeaderView else { return UICollectionReusableView() }
if indexPath.section == 0 {
headerView.label.text = "话题标签"
}
......
......@@ -98,8 +98,7 @@ extension YHMyFunctionGroup2Cell: UICollectionViewDelegate, UICollectionViewData
// 返回自定义单元格
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHMyFunctionGroupItem2Cell.cellReuseIdentifier, for: indexPath) as! YHMyFunctionGroupItem2Cell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHMyFunctionGroupItem2Cell.cellReuseIdentifier, for: indexPath) as? YHMyFunctionGroupItem2Cell else { return UICollectionViewCell()}
if 0 <= indexPath.item && indexPath.item < groupArr.count {
let item: PersonalModuleItem = groupArr[indexPath.item]
cell.updateItem(item)
......
......@@ -126,8 +126,7 @@ extension YHMySectionGroupCell: UICollectionViewDelegate, UICollectionViewDataSo
// 返回自定义单元格
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHMyFunctionGroupItemCell.cellReuseIdentifier, for: indexPath) as! YHMyFunctionGroupItemCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHMyFunctionGroupItemCell.cellReuseIdentifier, for: indexPath) as? YHMyFunctionGroupItemCell else { return UICollectionViewCell() }
if 0 <= indexPath.item && indexPath.item < groupArr.count {
let item: PersonalModuleItem = groupArr[indexPath.item]
cell.updateItem(item)
......
......@@ -37,7 +37,7 @@ class YHVipLevelRightHeaderView: UIView, UIScrollViewDelegate {
max = 3
}
for index in 0...3 {
let itemV = self.scrollView.viewWithTag(self.baseTag+index) as! YHVipLevelRightHeaderItemView
guard let itemV = self.scrollView.viewWithTag(self.baseTag+index) as? YHVipLevelRightHeaderItemView else { return }
itemV.lockImgV.isHidden = index <= max
}
}
......
......@@ -108,10 +108,10 @@ class YHVipLevelRightInfoCell: UITableViewCell {
func updateModel(_ model: YHVipLevelRightInfoModel) {
let v0 = self.contentView.viewWithTag(Self.baseTag+0) as! YHVipLevelRightInfoView
let v1 = self.contentView.viewWithTag(Self.baseTag+1) as! YHVipLevelRightInfoView
let v2 = self.contentView.viewWithTag(Self.baseTag+2) as! YHVipLevelRightInfoView
let v3 = self.contentView.viewWithTag(Self.baseTag+3) as! YHVipLevelRightInfoView
guard let v0 = self.contentView.viewWithTag(Self.baseTag+0) as? YHVipLevelRightInfoView else { return }
guard let v1 = self.contentView.viewWithTag(Self.baseTag+1) as? YHVipLevelRightInfoView else { return }
guard let v2 = self.contentView.viewWithTag(Self.baseTag+2) as? YHVipLevelRightInfoView else { return }
guard let v3 = self.contentView.viewWithTag(Self.baseTag+3) as? YHVipLevelRightInfoView else { return }
v0.clear()
v1.clear()
v2.clear()
......
......@@ -53,7 +53,7 @@ extension YHMyLikeViewModel {
self.arrHomeNewsData = result.data
} else {
self.arrHomeNewsData?.append(contentsOf: result.data)
curPageIndex = curPageIndex + 1
curPageIndex += 1
}
if let count = self.arrHomeNewsData?.count {
......@@ -107,7 +107,7 @@ extension YHMyLikeViewModel {
self.arrHomeNewsData = result.data
} else {
self.arrHomeNewsData?.append(contentsOf: result.data)
curPageIndex = curPageIndex + 1
curPageIndex += 1
}
if let count = self.arrHomeNewsData?.count {
......
......@@ -151,8 +151,6 @@ extension UIDevice {
name = "iPhoneXR"
} else if device == .iPhoneXS {
name = "iPhoneXS"
} else if device == .iPhoneXS {
name = "iPhoneXS"
} else if device == .iPhoneSE2 {
name = "iPhoneSE2"
} else if device == .iPhoneSE3 {
......
......@@ -40,9 +40,14 @@ extension String {
// 使用正则表达式替换
func regularReplace(pattern: String, with: String, options: NSRegularExpression.Options = []) -> String {
let regex = try! NSRegularExpression(pattern: pattern, options: options)
return regex.stringByReplacingMatches(in: self, options: [],
range: NSRange(location: 0, length: self.count),
withTemplate: with)
do {
let regex = try NSRegularExpression(pattern: pattern, options: options)
return regex.stringByReplacingMatches(in: self, options: [],
range: NSRange(location: 0, length: self.count),
withTemplate: with)
} catch {
return ""
}
}
}
......@@ -13,7 +13,7 @@ import ESTabBarController_swift
let picMaxSize: Int = 2 * 1024 * 1024
// MARK: - 工程中的 常量定义
let APP_NAME = Bundle.main.infoDictionary!["CFBundleName"] as! String
let APP_NAME = Bundle.main.infoDictionary!["CFBundleName"] as? String ?? ""
/// 打印
///
......@@ -127,7 +127,7 @@ func isIphoneX() -> Bool {
return k_Height_safeAreaInsetsBottom() > 0.0 // 底部安全区 > 0 时,
}
enum tabBarPageType: Int {
enum TabBarPageType: Int {
case home // 首页
case service // 服务
// case message //消息
......@@ -136,7 +136,7 @@ enum tabBarPageType: Int {
case AI // 港小宝
}
func goTabBarBy(tabType: tabBarPageType) {
func goTabBarBy(tabType: TabBarPageType) {
var tabIndex: Int = 0
switch tabType {
......
......@@ -129,7 +129,7 @@ extension YHRangeDatePickerView {
}
func calendar(_ calendar: FSCalendar, cellFor date: Date, at monthPosition: FSCalendarMonthPosition) -> FSCalendarCell {
let cell: YHRangeDatePickerCell = calendar.dequeueReusableCell(withIdentifier: YHRangeDatePickerCell.cellReuseIdentifier, for: date, at: monthPosition) as! YHRangeDatePickerCell
guard let cell: YHRangeDatePickerCell = calendar.dequeueReusableCell(withIdentifier: YHRangeDatePickerCell.cellReuseIdentifier, for: date, at: monthPosition) as? YHRangeDatePickerCell else { return FSCalendarCell() }
return cell
}
......
......@@ -237,7 +237,7 @@ class YHOSSManager: NSObject, URLSessionDelegate {
_ = error.description
callBackBlock(nil, YHErrorModel())
} else {
let string = result.result as! String
guard let string = result.result as? String else { return }
callBackBlock(string, YHErrorModel())
}
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment