Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Dimitris Togias
2022-09-21 14:51:02 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ee52dbf6aaac59f43b69df648f3e2cd36f6f9fe3
ee52dbf6
1 parent
63c37bb9
add category title parsing & sorting of data
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
SwiftWarplyFramework/SwiftWarplyFramework/CampaignCategory.swift
SwiftWarplyFramework/SwiftWarplyFramework/MFYViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/CampaignCategory.swift
View file @
ee52dbf
...
...
@@ -11,11 +11,33 @@ public class CampaignCategory: Codable {
// attributes
public
var
name
:
String
?
public
var
index
:
Int
public
var
items
:
Array
<
swiftApi
.
CampaignItemModel
>
// initialization
public
init
(
_
name
:
String
)
{
self
.
name
=
name
self
.
index
=
100
self
.
items
=
[
swiftApi
.
CampaignItemModel
]()
}
public
init
(
_
name
:
String
,
index
:
Int
)
{
self
.
name
=
name
self
.
index
=
index
self
.
items
=
[
swiftApi
.
CampaignItemModel
]()
}
}
enum
CampaignCategoryFactory
{
static
func
create
(
withTitle
title
:
String
)
->
CampaignCategory
{
var
index
=
100
let
indexChr
:
Character
=
title
[
title
.
index
(
title
.
startIndex
,
offsetBy
:
1
)]
if
indexChr
.
isNumber
{
index
=
indexChr
.
wholeNumberValue
!
}
return
CampaignCategory
(
title
,
index
:
index
)
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/MFYViewController.swift
View file @
ee52dbf
...
...
@@ -97,6 +97,7 @@ import SwiftEventBus
}
newData
.
append
(
category
)
newData
=
newData
.
sorted
(
by
:
{
$0
.
index
>
$1
.
index
})
// reload
categories
=
newData
...
...
Please
register
or
login
to post a comment