@@ -508,6 +508,41 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
508508 }
509509 }
510510
511+ /**
512+ Save the address IP field history for future App sessions
513+ */
514+ private func saveHistory( ) {
515+ if container. viewContext. hasChanges {
516+ do {
517+ try container. viewContext. save ( )
518+ } catch {
519+ print ( " An error occurred while saving: \( error) " )
520+ }
521+ }
522+ }
523+
524+ /**
525+ Load in the address IP field the history of previous App sessions
526+ */
527+ private func loadHistory( ) {
528+ container = NSPersistentContainer ( name: " SubnetCalc " )
529+ container. loadPersistentStores { storeDescription, error in
530+ if let error = error {
531+ print ( " Unresolved error \( error) " )
532+ }
533+ }
534+ do {
535+ history = try container. viewContext. fetch ( AddrHistory . fetchRequest ( ) )
536+ //print("Got \(history.count) items")
537+ for item in history {
538+ //print(item.address)
539+ addrField. addItem ( withObjectValue: item. address)
540+ }
541+ } catch {
542+ print ( " Fetch history failed " )
543+ }
544+ }
545+
511546 //**********************
512547 //Private IPv6 functions
513548 //**********************
@@ -1743,42 +1778,7 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
17431778 saveHistory ( )
17441779 }
17451780 }
1746-
1747- /**
1748- Save the address IP field history for future App sessions
1749- */
1750- private func saveHistory( ) {
1751- if container. viewContext. hasChanges {
1752- do {
1753- try container. viewContext. save ( )
1754- } catch {
1755- print ( " An error occurred while saving: \( error) " )
1756- }
1757- }
1758- }
1759-
1760- /**
1761- Load in the address IP field the history of previous App sessions
1762- */
1763- private func loadHistory( ) {
1764- container = NSPersistentContainer ( name: " SubnetCalc " )
1765- container. loadPersistentStores { storeDescription, error in
1766- if let error = error {
1767- print ( " Unresolved error \( error) " )
1768- }
1769- }
1770- do {
1771- history = try container. viewContext. fetch ( AddrHistory . fetchRequest ( ) )
1772- //print("Got \(history.count) items")
1773- for item in history {
1774- //print(item.address)
1775- addrField. addItem ( withObjectValue: item. address)
1776- }
1777- } catch {
1778- print ( " Fetch history failed " )
1779- }
1780- }
1781-
1781+
17821782 /**
17831783 Auto invoked when the Main Windows has been resized
17841784 */
0 commit comments