Skip to content

Commit

Permalink
refactoring for avoiding warning
Browse files Browse the repository at this point in the history
  • Loading branch information
kosyloa committed May 9, 2024
1 parent f379731 commit 643fbc5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
11 changes: 11 additions & 0 deletions DXFeedFramework/Utils/Dictionary+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,14 @@ public extension NSMutableOrderedSet {
return changed
}
}

public extension NSMutableSet {
func removeIf(using: NSPredicate) -> Bool {
var changed = false
for (value) in filtered(using: using) {
remove(value)
changed = true
}
return changed
}
}
16 changes: 4 additions & 12 deletions Samples/QuoteTableApp/MarketDepthViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,9 @@ extension MarketDepthViewController: UITableViewDataSource {
return UITableViewCell()
}
let order = orderBook.buyOrders[indexPath.row]
cell.update(price: order.price,
size: order.size,
cell.update(order: order,
maxSize: maxBuy,
isAsk: true,
marketMaker: order.marketMaker,
source: order.eventSource,
scope: order.scope)
isAsk: true)
cell.selectionStyle = UITableViewCell.SelectionStyle.none
return cell
}
Expand All @@ -189,13 +185,9 @@ extension MarketDepthViewController: UITableViewDataSource {
return UITableViewCell()
}
let order = orderBook.sellOrders[indexPath.row]
cell.update(price: order.price,
size: order.size,
cell.update(order: order,
maxSize: maxSell,
isAsk: false,
marketMaker: order.marketMaker,
source: order.eventSource,
scope: order.scope)
isAsk: false)
cell.selectionStyle = UITableViewCell.SelectionStyle.none
return cell
}
Expand Down
14 changes: 8 additions & 6 deletions Samples/QuoteTableApp/OrderCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ class OrderCell: UITableViewCell {
sizeContentView.superview?.backgroundColor = .tableBackground
}

func update(price: Double,
size: Double,
func update(order: Order,
maxSize: Double,
isAsk: Bool,
marketMaker: String?,
source: IndexedEventSource,
scope: Scope) {
isAsk: Bool) {
let price = order.price
let size = order.size
let marketMaker = order.marketMaker
let source = order.eventSource
let scope = order.scope

priceLabel.text = formatter.string(from: NSNumber(value: price))
sizeLabel.text = formatter.string(from: NSNumber(value: size))
sizeContentView.backgroundColor = isAsk ? .green : .red
Expand Down

0 comments on commit 643fbc5

Please sign in to comment.