【发布时间】:2016-09-07 21:33:49
【问题描述】:
我有这个代码:
for notif in EnvironmentManager.notif {
if let type = notif.type {
switch type {
case .SitterAvailable:
self.manageNotif(notif, title: "Une sitter disponible", storyboardName: "searchGuard", vcName: "searchGuardNCSID")
case .OccasionalAdjustmentReminder:
self.manageNotif(notif, title: "Rappel", storyboardName: "searchGuard", vcName: "searchGuardNCSID")
case .GuardRequest:
self.manageNotif(notif, title: "Nouvelle garde urgente", storyboardName: "EmergencyGuardSitter", vcName: "EmergencyGuardSitterNavigationControllerSID")
case .NewReservationRequest:
self.manageNotif(notif, title: "Nouvelle garde", storyboardName: "GuardWebSitter", vcName: "WebGuardSitterNavigationControllerSID")
case .NewMessage:
self.manageNotif(notif, title: "Nouveau message", storyboardName: "MessageListSitter", vcName: "messageSitterViewNavigationControllerSID")
case .SoonReservationStartReminder:
self.manageNotif(notif, title: "Rappel", storyboardName: "GuardListSitter", vcName: "guardListSitterNavigationControllerSID")
case .ReservationAccepted:
self.manageNotif(notif, title: "Garde acceptée", storyboardName: "GuardListSitter", vcName: "guardListSitterNavigationControllerSID")
case .ReservationRefused:
self.manageNotif(notif, title: "Garde refusée", storyboardName: "GuardListSitter", vcName: "guardListSitterNavigationControllerSID")
case .NewMessageParent:
self.manageNotif(notif, title: "Nouveau Message", storyboardName: "MessageParent", vcName: "messageParentViewNavigationControllerSID")
}
}
}
我想知道如何针对反圈复杂度进行优化, 所以没有字符串数组或类似的东西,
当前复杂度等于 11
感谢帮助
【问题讨论】:
-
SOLID 和设计模式将成为您的朋友。
标签: ios swift cycle cyclomatic-complexity