forked from codecat15/Youtube-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
Properties/Property observers/MyPlayground.playground/Contents.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import UIKit | ||
|
||
/* Hello there, thanks for downloading the code. I hope the video helped you in understanding property observer. Please do support the channel by subscribing to the video and sharing it with your friends and social media or with anyone who wants to learn swift and clean coding in swift ~codecat15 | ||
*/ | ||
|
||
struct Bank | ||
{ | ||
var accountBalance: Double | ||
{ | ||
didSet | ||
{ | ||
sendMessageToUser() | ||
} | ||
willSet (newAccountBalance) | ||
{ | ||
|
||
} | ||
} | ||
|
||
mutating func addMoney(amount: Double){ | ||
accountBalance += amount | ||
} | ||
|
||
mutating func withDrawMoney(amount: Double){ | ||
accountBalance -= amount | ||
} | ||
|
||
func sendMessageToUser() | ||
{ | ||
debugPrint("Account balance updated new balance = \(accountBalance)") | ||
} | ||
} | ||
|
||
var bank = Bank(accountBalance: 10000) | ||
bank.addMoney(amount: 5000) | ||
|
||
|
||
/*class Bank | ||
{ | ||
var accountBalance: Double | ||
{ | ||
didSet | ||
{ | ||
sendMessageToUser() | ||
} | ||
willSet (newAccountBalance) | ||
{ | ||
if(newAccountBalance >= 10000000) | ||
{ | ||
sendMessageToAuditor() | ||
} | ||
} | ||
} | ||
|
||
init(_openingBalance: Double) { | ||
accountBalance = _openingBalance | ||
} | ||
|
||
func addMoney(amount: Double){ | ||
accountBalance += amount | ||
} | ||
|
||
func withDrawMoney(amount: Double){ | ||
accountBalance -= amount | ||
} | ||
|
||
func sendMessageToUser() | ||
{ | ||
debugPrint("Account balance updated new balance = \(accountBalance)") | ||
} | ||
|
||
func sendMessageToAuditor() | ||
{ | ||
debugPrint("Please check this account, and make sure the transaction is authentic") | ||
} | ||
} | ||
|
||
let bank = Bank(_openingBalance: 10000) | ||
bank.addMoney(amount: 50000000)*/ |
4 changes: 4 additions & 0 deletions
4
Properties/Property observers/MyPlayground.playground/contents.xcplayground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<playground version='5.0' target-platform='ios'> | ||
<timeline fileName='timeline.xctimeline'/> | ||
</playground> |
7 changes: 7 additions & 0 deletions
7
...roperty observers/MyPlayground.playground/playground.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
...vers/MyPlayground.playground/playground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
Binary file added
BIN
+10.9 KB
...d/playground.xcworkspace/xcuserdata/ravirdixit.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
16 changes: 16 additions & 0 deletions
16
Properties/Property observers/MyPlayground.playground/timeline.xctimeline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Timeline | ||
version = "3.0"> | ||
<TimelineItems> | ||
<LoggerValueHistoryTimelineItem | ||
documentLocation = "file:///Users/ravirdixit/Desktop/MyPlayground.playground#CharacterRangeLen=1718&CharacterRangeLoc=12&EndingColumnNumber=0&EndingLineNumber=79&StartingColumnNumber=12&StartingLineNumber=0&Timestamp=599801075.443302" | ||
selectedRepresentationIndex = "0" | ||
shouldTrackSuperviewWidth = "NO"> | ||
</LoggerValueHistoryTimelineItem> | ||
<LoggerValueHistoryTimelineItem | ||
documentLocation = "file:///Users/ravirdixit/Desktop/MyPlayground.playground#CharacterRangeLen=1718&CharacterRangeLoc=12&EndingColumnNumber=0&EndingLineNumber=79&StartingColumnNumber=12&StartingLineNumber=0&Timestamp=599801075.443424" | ||
selectedRepresentationIndex = "0" | ||
shouldTrackSuperviewWidth = "NO"> | ||
</LoggerValueHistoryTimelineItem> | ||
</TimelineItems> | ||
</Timeline> |