Open DamonChen117 opened 6 years ago
@DamonChen117 你的意思就是没有开始 然后导致所有章节ID 都加了1 对吧
` // 有前言 var isPreface:Bool = true
// 便利
for i in 0...count {
// 章节数量分析:
// count + 1 = 搜索到的章节数量 + 最后一个章节,
// 1 + count + 1 = 第一章前面的前言内容 + 搜索到的章节数量 + 最后一个章节
print("总章节数:\(count + 1) 当前解析到:\(i + 1)")
// range
var range = NSMakeRange(0, 0)
var location = 0
if i < count {
range = results[i].range
location = range.location
}
// 创建章节内容模型
let readChapterModel = DZMReadChapterModel()
// 书ID
readChapterModel.bookID = bookID
// 章节ID
readChapterModel.id = "\(i + NSNumber(value: isPreface).intValue)"
// 优先级
readChapterModel.priority = NSNumber(value: (i - NSNumber(value: !isPreface).intValue))
if i == 0 { // 开始
// 章节名
readChapterModel.name = "开始"
// 内容
readChapterModel.content = ContentTypesetting(content: content.substring(NSMakeRange(0, location)))
// 记录
lastRange = range
// 说不定没有内容 则不需要添加到列表
if readChapterModel.content.isEmpty {
isPreface = false
continue
}
}else if i == count { // 结尾`
是的,我本地是这么改的:
var id = 1 // 便利 for i in 0...count {
if i == 0 { ... } }else if i == count { ... } }else { ... }
// 章节ID readChapterModel.id = "(id)" // 优先级 readChapterModel.priority = NSNumber(value: id) id += 1
}
出现下面情况是所有的章节id都多加了1,导致倒数第二章节的无法翻页到最后章节。
// 说不定没有内容 则不需要添加到列表 if readChapterModel.content.isEmpty {continue}