Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown and swift-playground-builder #6

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
25 changes: 25 additions & 0 deletions 10. Properties.playground/Documentation/section-0.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 1</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<h1 id="properties">Properties</h1>
<h2 id="things-to-know-">Things to know:</h2>
<ul>
<li>Properties store values in classes, structures and enumerations.</li>
</ul>
<hr>
<p>Here&#39;s a structure with a couple simple stored properties:</p>

</section>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions 10. Properties.playground/Documentation/section-10.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 11</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>Notice how we haven&#39;t used the importer yet, so it is nil:</p>

</section>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions 10. Properties.playground/Documentation/section-12.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 13</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>So now let&#39;s access it:</p>

</section>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions 10. Properties.playground/Documentation/section-14.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 15</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>And now we see the importer was created:</p>

</section>
</div>
</body>
</html>
22 changes: 22 additions & 0 deletions 10. Properties.playground/Documentation/section-16.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 17</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<h2 id="computed-properties">Computed Properties</h2>
<p>Computed properties don&#39;t store data, but rather use getters and setters for accessing values that are computed up on request.</p>
<p>Computed Properties are available for global as well as local variables.</p>
<p>We&#39;ll start with a few structures that we&#39;ll use to show how computed properties work.</p>

</section>
</div>
</body>
</html>
20 changes: 20 additions & 0 deletions 10. Properties.playground/Documentation/section-18.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 19</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>The following structure includes a computed property with a Point type named &#39;center&#39;. Notice that &#39;center&#39; is variable (not constant) which is a requirement of computed properties.</p>
<p>Every computed property must have a getter, but does not need a setter. If we provide a setter, we need to know the new value being assigned to the computed property. We&#39;ve called this value &#39;newCenter&#39;. Note that this value does not have a type annotation because the computed property already knows that it is a Point type. Providing a type annotation would be an error.</p>

</section>
</div>
</body>
</html>
20 changes: 20 additions & 0 deletions 10. Properties.playground/Documentation/section-2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 3</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>Structures must have all of their properties initialized upon instantiation.</p>
<p>This won&#39;t compile since the struct includes properties that havn&#39;t been initialized with default values:</p>

</section>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions 10. Properties.playground/Documentation/section-20.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 21</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>Here, we&#39;ll create a square from our Rect structure</p>

</section>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions 10. Properties.playground/Documentation/section-22.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 23</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>We can now get the center point, computed from the Rect&#39;s origin and size. Being a computed property, we can treat it just like any other peroperty.</p>

</section>
</div>
</body>
</html>
20 changes: 20 additions & 0 deletions 10. Properties.playground/Documentation/section-24.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 25</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>Since we provided a setter, we can also set the center point as if it is a stored property.
This will effectively update the Rect&#39;s origin and size based on the specified center point.</p>

</section>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions 10. Properties.playground/Documentation/section-26.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 27</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>We can see that the origin has been updated from (0, 0) to (10, 10):</p>

</section>
</div>
</body>
</html>
21 changes: 21 additions & 0 deletions 10. Properties.playground/Documentation/section-28.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 29</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>Shorthand Setter Declaration</p>
<p>The computed property&#39;s setter from the Rect structure provided a parameter on the setter named &#39;newCenter&#39;. If we don&#39;t specify this parameter, Swift will automatically generate an input value named &#39;newValue&#39; for us.</p>
<p>Here, AlternativeRect is the same declaration as Rect above, except that the setter uses Swift&#39;s default setter value, &#39;newValue&#39;:</p>

</section>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions 10. Properties.playground/Documentation/section-30.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 31</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>We can also have a read-only computed property by simply omitting the setter:</p>

</section>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions 10. Properties.playground/Documentation/section-32.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 33</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>Alternatively, Swift allows us to shorten the syntax of a read-only computed property by omitting the get{} construct and inserting the code for the getter directly into the property declaration:</p>

</section>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions 10. Properties.playground/Documentation/section-34.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 35</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>Let&#39;s declare our structure and read the &#39;volume&#39; property</p>

</section>
</div>
</body>
</html>
20 changes: 20 additions & 0 deletions 10. Properties.playground/Documentation/section-36.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 37</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>Since the &#39;volume&#39; property is read-only, if we tried to assign a value to it, it would would generate a compiler error.</p>
<p>The following line of code will not compile:</p>

</section>
</div>
</body>
</html>
23 changes: 23 additions & 0 deletions 10. Properties.playground/Documentation/section-38.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 39</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<h2 id="property-observers">Property Observers</h2>
<p>Property observers allow us to respond to changes in a property&#39;s value. We can declare an observer that contains our code that is run just before a property is set (optionally allowing us to alter the value being set) and an observer that is run just after a property has been modified.</p>
<p>Property observers are available for global as well as local variables.</p>
<p>These observers are not called when a property is first initialized, but only when it changes.</p>
<p>Similar to setters, each &#39;willSet&#39; and &#39;didSet&#39; will receive a parameter that represents (in the case of &#39;willSet&#39;) the value about to be assigned to the property and (in the case of &#39;didSet&#39;) the value that was previously stored in the property prior to modification.</p>

</section>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions 10. Properties.playground/Documentation/section-4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 5</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>In order to instantiate a FixedLengthRange struct, we must use the memberwise initializer. Note that this will initialize a constant property and a variable property inside the struct:</p>

</section>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions 10. Properties.playground/Documentation/section-40.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Section 41</title>
<meta id="xcode-display" name="xcode-display" content="render">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="content-wrapper">
<section class="section">
<p>Let&#39;s create an instance of StepCounter so we can try out our observer</p>

</section>
</div>
</body>
</html>
Loading