Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Screenshottr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
broman
Screenshottr
Commits
9831316d
Verified
Commit
9831316d
authored
6 years ago
by
Spotlight Deveaux
Browse files
Options
Downloads
Patches
Plain Diff
Better nil handling
parent
aedfcf10
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Screenshottr/PomfManager.swift
+22
-12
22 additions, 12 deletions
Screenshottr/PomfManager.swift
with
22 additions
and
12 deletions
Screenshottr/PomfManager.swift
+
22
−
12
View file @
9831316d
...
@@ -19,7 +19,7 @@ class PomfManager {
...
@@ -19,7 +19,7 @@ class PomfManager {
let
userInfo
:
[
AnyHashable
:
Any
]
=
[
let
userInfo
:
[
AnyHashable
:
Any
]
=
[
NSLocalizedDescriptionKey
:
NSLocalizedString
(
"Unsuccessful"
,
value
:
"Go to Settings and enter a Pomf upload url."
,
comment
:
""
)
,
NSLocalizedDescriptionKey
:
NSLocalizedString
(
"Unsuccessful"
,
value
:
"Go to Settings and enter a Pomf upload url."
,
comment
:
""
)
,
]
]
completionHandler
(
NSError
(
domain
:
"PomfErrorDomain"
,
code
:
1
,
userInfo
:
userInfo
as?
[
String
:
Any
]),
"https://
google.com
"
)
completionHandler
(
NSError
(
domain
:
"PomfErrorDomain"
,
code
:
1
,
userInfo
:
userInfo
as?
[
String
:
Any
]),
"https://
whats-th.is
"
)
return
return
}
}
...
@@ -49,27 +49,37 @@ class PomfManager {
...
@@ -49,27 +49,37 @@ class PomfManager {
let
description
:
String
=
parsedData
[
"description"
]
as!
String
let
description
:
String
=
parsedData
[
"description"
]
as!
String
let
userInfo
:
[
AnyHashable
:
Any
]
=
[
let
userInfo
:
[
AnyHashable
:
Any
]
=
[
NSLocalizedDescriptionKey
:
NSLocalizedString
(
"Unsuccessful"
,
value
:
description
,
comment
:
""
)
,
NSLocalizedDescriptionKey
:
NSLocalizedString
(
"Unsuccessful"
,
value
:
description
,
comment
:
""
)
,
NSLocalizedFailureReasonErrorKey
:
NSLocalizedString
(
"Unsuccessful"
,
value
:
description
,
comment
:
""
)
]
]
let
errorCode
:
Int
=
parsedData
[
"errorcode"
]
as!
Int
let
errorCode
:
Int
=
parsedData
[
"errorcode"
]
as!
Int
completionHandler
(
NSError
(
domain
:
"PomfErrorDomain"
,
code
:
errorCode
,
userInfo
:
userInfo
as?
[
String
:
Any
]),
"https://
google.com
"
)
completionHandler
(
NSError
(
domain
:
"PomfErrorDomain"
,
code
:
errorCode
,
userInfo
:
userInfo
as?
[
String
:
Any
]),
"https://
whats-th.is
"
)
return
return
}
}
// Attempt to get information returned over the uploaded file.
// Attempt to get information returned over the uploaded file.
let
test
:
[
NSDictionary
]
=
parsedData
[
"files"
]
as!
[
NSDictionary
]
let
test
=
parsedData
[
"files"
]
as!
[
NSDictionary
]
let
furtherTest
:
NSDictionary
=
test
[
0
]
if
let
fileName
:
String
=
test
[
0
][
"url"
]
as?
String
{
// https://discord.coffee/c58cec.png
if
let
pomfBaseDomain
=
defaults
.
string
(
forKey
:
"pomfBaseDomain"
)
{
let
fileName
=
furtherTest
.
object
(
forKey
:
"url"
)
as!
String
?
??
"c58cec.png"
completionHandler
(
nil
,
"
\(
pomfBaseDomain
)
!)/
\(
fileName
)
"
)
completionHandler
(
nil
,
"
\(
defaults
.
string
(
forKey
:
"pomfBaseDomain"
)
!
)
/
\(
fileName
)
"
)
}
else
{
let
userInfo
:
[
AnyHashable
:
Any
]
=
[
NSLocalizedDescriptionKey
:
NSLocalizedString
(
"Unsuccessful"
,
value
:
"Go to Settings and enter a Pomf base domain."
,
comment
:
""
)
,
]
completionHandler
(
NSError
(
domain
:
"PomfErrorDomain"
,
code
:
2
,
userInfo
:
userInfo
as?
[
String
:
Any
]),
"https://whats-th.is"
)
}
}
else
{
let
userInfo
:
[
AnyHashable
:
Any
]
=
[
NSLocalizedDescriptionKey
:
NSLocalizedString
(
"Unsuccessful"
,
value
:
"Could not parse returned filename."
,
comment
:
""
)
,
]
completionHandler
(
NSError
(
domain
:
"PomfErrorDomain"
,
code
:
3
,
userInfo
:
userInfo
as?
[
String
:
Any
]),
"https://whats-th.is"
)
}
}
}
}
}
case
.
failure
(
let
encodingError
):
case
.
failure
(
let
encodingError
):
print
(
encodingError
)
print
(
encodingError
)
completionHandler
(
encodingError
,
"https://
google.com/
"
)
completionHandler
(
encodingError
,
"https://
whats-th.is
"
)
}
}
}
}
)
)
}
}
}
}
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