Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
zhangyongji
/
MRFramework
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
48fb719d
authored
Dec 04, 2019
by
Sarkizz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加系统版本获取逻辑
parent
946f0bc0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
MRFramework/MRFramework/FoundationManagers/DeviceInfo/MRDevice.swift
+57
-0
No files found.
MRFramework/MRFramework/FoundationManagers/DeviceInfo/MRDevice.swift
View file @
48fb719d
...
...
@@ -9,6 +9,58 @@
import
Foundation
import
KeychainAccess
/// 系统版本号封装
public
struct
MRSystemVersion
{
private
var
version
:
String
public
var
string
:
String
{
return
version
}
init
(
version
:
String
)
{
self
.
version
=
version
}
}
extension
MRSystemVersion
:
Equatable
{
public
static
func
==
(
lhs
:
MRSystemVersion
,
rhs
:
MRSystemVersion
)
->
Bool
{
return
lhs
.
version
==
rhs
.
version
}
}
extension
MRSystemVersion
:
MRCompareToString
{
public
static
func
==
(
lhs
:
MRSystemVersion
,
rhs
:
String
)
->
Bool
{
return
lhs
.
version
==
rhs
}
public
static
func
<
(
lhs
:
MRSystemVersion
,
rhs
:
MRSystemVersion
)
->
Bool
{
return
lhs
.
compare
(
with
:
rhs
.
version
)
==
.
orderedSame
}
public
static
func
>=
(
lhs
:
MRSystemVersion
,
rhs
:
String
)
->
Bool
{
let
rs
=
lhs
.
compare
(
with
:
rhs
)
return
rs
==
.
orderedSame
||
rs
==
.
orderedDescending
}
public
static
func
>
(
lhs
:
MRSystemVersion
,
rhs
:
String
)
->
Bool
{
return
lhs
.
compare
(
with
:
rhs
)
==
.
orderedDescending
}
public
static
func
<=
(
lhs
:
MRSystemVersion
,
rhs
:
String
)
->
Bool
{
let
rs
=
lhs
.
compare
(
with
:
rhs
)
return
rs
==
.
orderedSame
||
rs
==
.
orderedAscending
}
public
static
func
<
(
lhs
:
MRSystemVersion
,
rhs
:
String
)
->
Bool
{
return
lhs
.
compare
(
with
:
rhs
)
==
.
orderedAscending
}
public
func
compare
(
with
string
:
String
)
->
ComparisonResult
{
return
self
.
version
.
compare
(
string
)
}
}
/// 设备信息
public
final
class
MRDevice
{
...
...
@@ -19,6 +71,11 @@ public final class MRDevice {
return
UIDevice
.
current
.
modelVersion
}
/// 系统版本号
public
class
var
systemVersion
:
MRSystemVersion
{
return
MRSystemVersion
(
version
:
UIDevice
.
current
.
systemVersion
)
}
/// App的版本号
public
class
var
appShortVersion
:
String
?
{
return
Bundle
.
main
.
infoDictionary
?[
"CFBundleShortVersionString"
]
as?
String
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment