Solution
The solution is renaming my iPhone and restarting the hotspot. I renamed it by go to Settings > General > About > Name.
section=0, numOfRows=10
Item: name=Shiny Mac, serialNumber=Optional("2A725A93"), valueInDollars=70, dateCreated=2017-10-05 09:37:41 +0000
row=0, section=0
2017-10-05 16:37:41.594 Homepwner[62092:2091530] *** Terminating app due to uncaught exception 'CALayerInvalid', reason: 'layer <CALayer: 0x600000036240> is a part of cycle in its layer tree'
*** First throw call stack:
(
0 CoreFoundation 0x0000000102251b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001018a1141 objc_exception_throw + 48
2 CoreFoundation 0x00000001022ba625 +[NSException raise:format:] + 197
3 QuartzCore 0x0000000108867ea2 _ZN2CA5Layer30ensure_transaction_recursivelyEPNS_11TransactionE + 102
4 QuartzCore 0x0000000108867eed _ZN2CA5Layer30ensure_transaction_recursivelyEPNS_11TransactionE + 177
5 QuartzCore 0x0000000108867eed _ZN2CA5Layer30ensure_transaction_recursivelyEPNS_11TransactionE + 177
6 QuartzCore 0x0000000108867eed _ZN2CA5Layer30ensure_transaction_recursivelyEPNS_11TransactionE + 177
7 QuartzCore 0x000000010886fb3a _ZN2CA5Layer15insert_sublayerEPNS_11TransactionEP7CALayerm + 394
8 QuartzCore 0x000000010886ff50 -[CALayer addSublayer:] + 180
9 UIKit 0x0000000102e1d7ad -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1322
10 UIKit 0x000000010311d9a0 -[UITableViewCell _addSubview:positioned:relativeTo:] + 357
11 UIKit 0x0000000102e0bcf8 -[UIView(Hierarchy) addSubview:] + 838
12 UIKit 0x000000010323b340 -[UITableViewCellLayoutManager layoutSubviewsOfCell:] + 2386
13 UIKit 0x000000010326db12 -[UITableViewCellLayoutManagerValue1 layoutSubviewsOfCell:] + 71
14 UIKit 0x00000001031271d7 -[UITableViewCell layoutSubviews] + 119
15 UIKit 0x0000000102e2155b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1268
16 QuartzCore 0x0000000108876904 -[CALayer layoutSublayers] + 146
17 QuartzCore 0x000000010886a526 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 370
18 UIKit 0x0000000102e0f334 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1108
19 UIKit 0x0000000102e1608e +[UIView(Animation) performWithoutAnimation:] + 90
20 UIKit 0x0000000102ecac29 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 1125
21 UIKit 0x0000000102ecacf8 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
22 UIKit 0x0000000102e9f639 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2845
23 UIKit 0x0000000102ed3ccc -[UITableView _performWithCachedTraitCollection:] + 111
24 UIKit 0x0000000102ebae7a -[UITableView layoutSubviews] + 233
25 UIKit 0x0000000102e2155b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1268
26 QuartzCore 0x0000000108876904 -[CALayer layoutSublayers] + 146
27 QuartzCore 0x000000010886a526 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 370
28 QuartzCore 0x000000010886a3a0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
29 QuartzCore 0x00000001087f9e92 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
30 QuartzCore 0x0000000108826130 _ZN2CA11Transaction6commitEv + 468
31 QuartzCore 0x0000000108826b37 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 115
32 CoreFoundation 0x00000001021f7717 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
33 CoreFoundation 0x00000001021f7687 __CFRunLoopDoObservers + 391
34 CoreFoundation 0x00000001021dc038 CFRunLoopRunSpecific + 440
35 UIKit 0x0000000102d5808f -[UIApplication _run] + 468
36 UIKit 0x0000000102d5e134 UIApplicationMain + 159
37 Homepwner 0x00000001012bf8a7 main + 55
38 libdyld.dylib 0x00000001060b065d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
import UIKit
class Item: NSObject {
var name: String
var valueInDollars: Int
var serialNumber: String?
let dateCreated: NSDate
init(_ name: String, _ serialNumber: String?, _ valueInDollars: Int) {
self.name = name
self.serialNumber = serialNumber
self.valueInDollars = valueInDollars
self.dateCreated = NSDate()
super.init()
}
convenience init(_ random: Bool = false) {
if random {
let adjectives = ["Fluffy", "Rusty", "Shiny"]
let nouns = ["Bear", "Spork", "Mac"]
let idx = Int(arc4random_uniform(UInt32(adjectives.count)))
let randomNoun = nouns[idx]
let randomAdjective = adjectives[idx]
let randomName = "\(randomAdjective) \(randomNoun)"
let randomSerialNumber = NSUUID().uuidString.components(separatedBy: "-").first!
let randomValueInDollars = Int(arc4random_uniform(100))
self.init(randomName, randomSerialNumber, randomValueInDollars)
return
}
self.init("", nil, 0)
}
func toString() -> String {
return "Item: name=\(name), serialNumber=\(String(describing: serialNumber)), valueInDollars=\(valueInDollars), dateCreated=\(dateCreated)"
}
}
class ItemStore {
var allItems = [Item]()
init() {
createItem(valueInDollars: 20)
createItem(valueInDollars: 30)
createItem(valueInDollars: 60)
createItem(valueInDollars: 70)
createItem(valueInDollars: 80)
}
func createItem() -> Item {
let item = Item(true)
allItems.append(item)
return item
}
func createItem(valueInDollars: Int) -> Item {
let item = Item(true)
item.valueInDollars = valueInDollars
allItems.append(item)
return item
}
func getGreaterThan50DollarsItems() -> [Item] {
var items = [Item]()
for item in allItems {
if item.valueInDollars > 50 {
items.append(item)
}
}
return items
}
func getLessThanOrEqualsTo50DollarsItems() -> [Item] {
var items = [Item]()
for item in allItems {
if item.valueInDollars <= 50 {
items.append(item)
}
}
return items
}
}
import UIKit
class ItemsViewController: UITableViewController {
var itemStore: ItemStore!
override func viewDidLoad() {
super.viewDidLoad()
let statusBarHeight = UIApplication.shared.statusBarFrame.height
let insets = UIEdgeInsets(top: statusBarHeight, left: 0, bottom: 0, right: 0)
tableView.contentInset = insets
}
override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
print("\nsection=\(section)")
switch section {
case 0:
return itemStore.getGreaterThan50DollarsItems().count
case 1:
return itemStore.getLessThanOrEqualsTo50DollarsItems().count
default:
return 0
}
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// let cell = UITableViewCell(style: UITableViewCellStyle.value1, reuseIdentifier: "UITableViewCell")
let cell = tableView.dequeueReusableCell(withIdentifier: "UITableViewCell")!
let items: [Item]
switch indexPath.section {
case 0:
items = itemStore.getGreaterThan50DollarsItems()
case 1:
items = itemStore.getLessThanOrEqualsTo50DollarsItems()
default:
items = [Item]()
}
let item = items[indexPath.row]
cell.textLabel?.text = item.name
cell.detailTextLabel?.text = "$\(item.valueInDollars)"
print("\n\(item.toString())")
print("\nrow=\(indexPath.row), section=\(indexPath.section)")
return cell
}
}
var itemStore = ItemStore()
let itemsController = window!.rootViewController as! ItemsViewController
itemsController.itemStore = itemStore