playground code for project 24

This commit is contained in:
CypherPoet 2019-02-10 05:57:09 -05:00
parent 5a193c5f26
commit e08244cb3d
5 changed files with 59 additions and 3 deletions

View File

@ -0,0 +1,21 @@
import UIKit
extension Int {
mutating func increment() {
self += 1
}
var squared: Int {
return self * self
}
}
var myInt1 = 0
let myInt2 = 232
myInt1.increment()
//myInt2.plusOne()
//2.plusOne()

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios' executeOnSourceChanges='false'>
<timeline fileName='timeline.xctimeline'/>
</playground>

View File

@ -0,0 +1,27 @@
import UIKit
extension BinaryInteger {
func squared() -> Self {
return self * self
}
mutating func square() {
self *= self
}
}
var a: Int64 = 123_121
var b: UInt8 = 2
a.squared()
b.squared()
print(a)
print(b)
a.square()
b.square()
print(a)
print(b)

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios' executeOnSourceChanges='false'>
<timeline fileName='timeline.xctimeline'/>
</playground>

View File

@ -38,9 +38,9 @@
| 19 | 📱<br>[Capital Cities](/19-capital-cities) | MKMapView, MKAnnotation, MKPinAnnotationView, CLLocationCoordinate2D, dequeueReusableAnnotationView(), switching between different map styles | ✅ |
| 20 | 🎮<br>[Fireworks Night](/20-fireworks-night) | Timer, SKNode, SKAction.follow() and its awesome `orientToPath` option, motionBegan(), prefersStatusBarHidden, Timer.invalidate(), colorBlendFactor for SKSpriteNodes | ✅ |
| 21 | 🛠<br>[Local Notifications](/21-local-notifications) | UNUserNotificationCenter, UNNotificationRequest, UNNotificationAction, UNNotificationCategory, UNUserNotificationCenterDelegate, UNNotificationDefaultActionIdentifier | ✅ |
| 22 | 📱<br>[Detect-A-Beacon](/22-detect-a-beacon) | iBeacons, Core Location, CLBeaconRegion, CLLocationManager, startMonitoring(for:), startRangingBeacons(in:), `uuidgen`, CLBeaconRegion, CLProximity | 🚧 |
| 23 | 🎮<br>[Space Race](/23-space-race) | Per-Pixel Collision Detection, Advancing Particle Systems, Adjust Linear & Angular Damping, touchesEnded(), touchesMoved(), touchesBegan() | 🔴 |
| 24 | 🛠<br>[Swift Extensions](/24-swift-extensions/swiftextensions.playground) | `mutating`, Protocol-Oriented Programming, Methods as Verbs, Properties as State, ExSwift | 🔴 |
| 22 | 📱<br>[Detect-A-Beacon](/22-detect-a-beacon) | iBeacons, Core Location, CLBeaconRegion, CLLocationManager, startMonitoring(for:), startRangingBeacons(in:), `uuidgen`, CLBeaconRegion, CLProximity | |
| 23 | 🎮<br>[Space Race](/23-space-race) | per-pixel collision detection, advancing particle systems, adjust linear & angular damping, touchesEnded(), touchesMoved(), touchesBegan() | ✅ |
| 24 | 🛠<br>[Swift Extensions](/24-swift-extensions) | `mutating` methods, Protocol-Oriented programming, conventions regarding methods (generally, verbs) vs computed properties (generally, nouns/state), ExSwift | ✅ |
| 25 | 📱<br>[Selfie Share](/25-selfie-share) | MCSession, MCBrowswerViewController, showConnectionPrompt(), MCPeerID, MCAdvertiserAssistant, MCSessionDelegate, MCBrowserViewControllerDelegate, Data, data(using:), String.Encoding.utf8 | 🔴 |
| 26 | 🎮<br>[Marble Maze](/26-marble-maze) | categoryBitMask, collisionBitMask, contactTestBitMask, CMMotionManager, update() | 🔴 |
| 27 | 🛠<br>[Core Graphics](/27-core-graphics) | UIGraphicsImageRenderer, UIGraphicsImageRendererContext, CGContext, addRect(), addEllipse(), String.draw(with:), UIFont, NSMutableParagraphStyle() | 🔴 |