Skip to content

Commit

Permalink
Avoid crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
naoto.suzuki committed Dec 1, 2021
1 parent a86f4d6 commit 7d03dfe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions NohanaImagePicker/AssetDateSectionCreater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ final class AssetDateSectionCreater {
var assetsByDateIndex = 0
for asset in allAssets {
if assetsByDateIndex > 0 {
if assetsByDate[assetsByDateIndex - 1].0 == calender.dateComponents([.day, .year, .month], from: (asset.creationDate)!) {
if assetsByDate[assetsByDateIndex - 1].0 == calender.dateComponents([.day, .year, .month], from: (asset.creationDate ?? Date(timeIntervalSince1970: 0))) {
assetsByDate[assetsByDateIndex - 1].1.append(asset)
} else {
let value = (calender.dateComponents([.day, .year, .month], from: (asset.creationDate)!), [asset])
let value = (calender.dateComponents([.day, .year, .month], from: (asset.creationDate ?? Date(timeIntervalSince1970: 0))), [asset])
assetsByDate.append(value)
assetsByDateIndex += 1
}
} else if assetsByDate.count == assetsByDateIndex {
let value = (calender.dateComponents([.day, .year, .month], from: (asset.creationDate)!), [asset])
let value = (calender.dateComponents([.day, .year, .month], from: (asset.creationDate ?? Date(timeIntervalSince1970: 0))), [asset])
assetsByDate.append(value)
assetsByDateIndex += 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ class AssetListSelectableDateSectionController: UICollectionViewController, UICo
assetListDetailCurrentRow += dateSectionList[section].assetResult.count
}
}
if assetListDetailCurrentRow >= photoKitAssetList.count {
assetListDetailCurrentRow = photoKitAssetList.count - 1
}

let assetListDetailViewController = segue.destination as! AssetDetailListViewController
assetListDetailViewController.photoKitAssetList = photoKitAssetList
Expand Down

0 comments on commit 7d03dfe

Please sign in to comment.