Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iosStudentsSpring2020
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Keleher
iosStudentsSpring2020
Commits
e2ebcdde
Commit
e2ebcdde
authored
5 years ago
by
keleher
Browse files
Options
Downloads
Patches
Plain Diff
auto
parent
89086016
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
VCLLoggingViewController.swift
+112
-0
112 additions, 0 deletions
VCLLoggingViewController.swift
with
112 additions
and
0 deletions
VCLLoggingViewController.swift
0 → 100644
+
112
−
0
View file @
e2ebcdde
//
// VCLLoggingViewController.swift
//
// Created by CS193p Instructor.
// Copyright © 2015-17 Stanford University. All rights reserved.
//
import
UIKit
class
VCLLoggingViewController
:
UIViewController
{
private
struct
LogGlobals
{
var
prefix
=
""
var
instanceCounts
=
[
String
:
Int
]()
var
lastLogTime
=
Date
()
var
indentationInterval
:
TimeInterval
=
1
var
indentationString
=
"__"
}
private
static
var
logGlobals
=
LogGlobals
()
private
static
func
logPrefix
(
for
loggingName
:
String
)
->
String
{
if
logGlobals
.
lastLogTime
.
timeIntervalSinceNow
<
-
logGlobals
.
indentationInterval
{
logGlobals
.
prefix
+=
logGlobals
.
indentationString
print
(
""
)
}
logGlobals
.
lastLogTime
=
Date
()
return
logGlobals
.
prefix
+
loggingName
}
private
static
func
bumpInstanceCount
(
for
loggingName
:
String
)
->
Int
{
logGlobals
.
instanceCounts
[
loggingName
]
=
(
logGlobals
.
instanceCounts
[
loggingName
]
??
0
)
+
1
return
logGlobals
.
instanceCounts
[
loggingName
]
!
}
private
var
instanceCount
:
Int
!
var
vclLoggingName
:
String
{
return
String
(
describing
:
type
(
of
:
self
))
}
private
func
logVCL
(
_
msg
:
String
)
{
if
instanceCount
==
nil
{
instanceCount
=
VCLLoggingViewController
.
bumpInstanceCount
(
for
:
vclLoggingName
)
}
print
(
"
\(
VCLLoggingViewController
.
logPrefix
(
for
:
vclLoggingName
)
)
(
\(
instanceCount
!
)
)
\(
msg
)
"
)
}
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
logVCL
(
"init(coder:) - created via InterfaceBuilder "
)
}
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
Bundle
?)
{
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
logVCL
(
"init(nibName:bundle:) - create in code"
)
}
deinit
{
logVCL
(
"left the heap"
)
}
override
func
awakeFromNib
()
{
logVCL
(
"awakeFromNib()"
)
}
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
logVCL
(
"viewDidLoad()"
)
}
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
logVCL
(
"viewWillAppear(animated =
\(
animated
)
)"
)
}
override
func
viewDidAppear
(
_
animated
:
Bool
)
{
super
.
viewDidAppear
(
animated
)
logVCL
(
"viewDidAppear(animated =
\(
animated
)
)"
)
}
override
func
viewWillDisappear
(
_
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
logVCL
(
"viewWillDisappear(animated =
\(
animated
)
)"
)
}
override
func
viewDidDisappear
(
_
animated
:
Bool
)
{
super
.
viewDidDisappear
(
animated
)
logVCL
(
"viewDidDisappear(animated =
\(
animated
)
)"
)
}
override
func
didReceiveMemoryWarning
()
{
super
.
didReceiveMemoryWarning
()
logVCL
(
"didReceiveMemoryWarning()"
)
}
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
logVCL
(
"viewWillLayoutSubviews() bounds.size =
\(
view
.
bounds
.
size
)
"
)
}
override
func
viewDidLayoutSubviews
()
{
super
.
viewDidLayoutSubviews
()
logVCL
(
"viewDidLayoutSubviews() bounds.size =
\(
view
.
bounds
.
size
)
"
)
}
override
func
viewWillTransition
(
to
size
:
CGSize
,
with
coordinator
:
UIViewControllerTransitionCoordinator
)
{
super
.
viewWillTransition
(
to
:
size
,
with
:
coordinator
)
logVCL
(
"viewWillTransition(to:
\(
size
)
, with: coordinator)"
)
coordinator
.
animate
(
alongsideTransition
:
{
(
context
:
UIViewControllerTransitionCoordinatorContext
!
)
->
Void
in
self
.
logVCL
(
"begin animate(alongsideTransition:completion:)"
)
},
completion
:
{
context
->
Void
in
self
.
logVCL
(
"end animate(alongsideTransition:completion:)"
)
})
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment