Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
ShorthandMaster
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lmj
ShorthandMaster
Commits
446c75f7
Commit
446c75f7
authored
Sep 29, 2020
by
lmj_521aiau@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
icloud 优化
parent
1a7e95d5
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
278 additions
and
277 deletions
+278
-277
SHMineViewController.swift
ShorthandMaster/Mine/SHMineViewController.swift
+14
-10
SHRecordModel.swift
ShorthandMaster/Record/Model/SHRecordModel.swift
+1
-0
Record.storyboard
ShorthandMaster/Record/Record.storyboard
+6
-6
SHRecordDetailsVC.swift
ShorthandMaster/Record/SHRecordDetailsVC.swift
+8
-5
SHRecordListViewController.swift
ShorthandMaster/Record/SHRecordListViewController.swift
+16
-87
SHRecordMoveFileVC.swift
ShorthandMaster/Record/SHRecordMoveFileVC.swift
+35
-24
SHRecordViewController.swift
ShorthandMaster/Record/SHRecordViewController.swift
+11
-15
SHAVAudioManager.swift
ShorthandMaster/Share/Managers/SHAVAudioManager.swift
+2
-1
SHCloudManager.swift
ShorthandMaster/Share/Managers/SHCloudManager.swift
+185
-129
No files found.
ShorthandMaster/Mine/SHMineViewController.swift
View file @
446c75f7
...
...
@@ -73,7 +73,7 @@ class SHMineViewController: SHBaseViewController {
}
func
sortType
(){
UIAlertController
.
showActionSheet
(
withTitle
:
""
,
message
:
""
,
cancelBtnTitle
:
"取消"
,
otherBtnTitles
:
sortTypes
)
{
(
index
)
in
UIAlertController
.
showActionSheet
(
withTitle
:
nil
,
message
:
nil
,
cancelBtnTitle
:
"取消"
,
otherBtnTitles
:
sortTypes
)
{
(
index
)
in
if
index
==
0
{
return
}
...
...
@@ -153,6 +153,7 @@ extension SHMineViewController:UITableViewDelegate, UITableViewDataSource{
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
tableView
.
deselectRow
(
at
:
indexPath
,
animated
:
true
)
switch
indexPath
.
section
{
case
0
:
sortType
()
...
...
@@ -178,7 +179,18 @@ extension SHMineViewController:UITableViewDelegate, UITableViewDataSource{
self
.
navigationController
?
.
pushViewController
(
webView
,
animated
:
true
)
break
case
3
:
SHStoreManager
.
restorePurchases
(
success
:
{
SHUserAccountManager
.
shared
.
getUserInfo
({
(
model
)
in
if
model
.
isMember
{
self
.
getUserInfo
()
MBProgressHUD
.
showSuccess
(
"恢复成功"
)
}
else
{
MBProgressHUD
.
showError
(
"恢复失败,请稍后再试"
)
}
},
failure
:
{
MBProgressHUD
.
showError
(
"恢复失败,请稍后再试"
)
})
},
toView
:
self
.
view
)
break
default
:
break
...
...
@@ -188,13 +200,5 @@ extension SHMineViewController:UITableViewDelegate, UITableViewDataSource{
default
:
break
}
// let webView = SHWebViewController()
// webView.url = SHUserAccountManager.shared.h5_urlDic["user"] as? String
// webView.title = "付费用户协议"
// self.navigationController?.pushViewController(webView, animated: true)
// let delete = UIStoryboard.init(name: "Mine", bundle: nil).instantiateViewController(withIdentifier: "SHDeleteDetailsViewController") as! SHDeleteDetailsViewController
// self.navigationController?.pushViewController(delete, animated: true)
}
}
ShorthandMaster/Record/Model/SHRecordModel.swift
View file @
446c75f7
...
...
@@ -32,6 +32,7 @@ class SHRecordModel: NSObject{
@objc
var
selected
:
Bool
=
false
@objc
var
icloud
:
Bool
=
false
@objc
var
processing
:
Bool
=
false
override
func
setValue
(
_
value
:
Any
?,
forUndefinedKey
key
:
String
)
{
...
...
ShorthandMaster/Record/Record.storyboard
View file @
446c75f7
...
...
@@ -193,13 +193,13 @@
<rect
key=
"frame"
x=
"0.0"
y=
"100"
width=
"414"
height=
"678"
/>
<subviews>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"点击右上角添加笔记"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"JlT-EC-bWg"
>
<rect
key=
"frame"
x=
"1
15.5"
y=
"395"
width=
"183.5"
height=
"24
"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"
20
"
/>
<rect
key=
"frame"
x=
"1
24.5"
y=
"396"
width=
"165.5"
height=
"21.5
"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"
18
"
/>
<color
key=
"textColor"
red=
"0.40000000000000002"
green=
"0.40000000000000002"
blue=
"0.40000000000000002"
alpha=
"0.84705882349999995"
colorSpace=
"calibratedRGB"
/>
<nil
key=
"highlightedColor"
/>
</label>
<imageView
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleAspectFit"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
image=
"recordlist_no_data"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"1ji-L1-Qj7"
>
<rect
key=
"frame"
x=
"123.5"
y=
"27
2
"
width=
"167"
height=
"103"
/>
<rect
key=
"frame"
x=
"123.5"
y=
"27
3
"
width=
"167"
height=
"103"
/>
</imageView>
</subviews>
<color
key=
"backgroundColor"
systemColor=
"systemBackgroundColor"
/>
...
...
@@ -334,13 +334,13 @@
<rect
key=
"frame"
x=
"0.0"
y=
"44"
width=
"414"
height=
"758"
/>
<subviews>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"这个笔记本里还没有笔记"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"QYS-Yf-f9g"
>
<rect
key=
"frame"
x=
"
95"
y=
"367"
width=
"224.5"
height=
"24
"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"
20
"
/>
<rect
key=
"frame"
x=
"
106"
y=
"368.5"
width=
"202"
height=
"21.5
"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"
18
"
/>
<color
key=
"textColor"
red=
"0.40000000000000002"
green=
"0.40000000000000002"
blue=
"0.40000000000000002"
alpha=
"0.84705882349999995"
colorSpace=
"calibratedRGB"
/>
<nil
key=
"highlightedColor"
/>
</label>
<imageView
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleAspectFit"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
image=
"recordlist_no_data"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"QrU-uf-U0R"
>
<rect
key=
"frame"
x=
"123.5"
y=
"24
4
"
width=
"167"
height=
"103"
/>
<rect
key=
"frame"
x=
"123.5"
y=
"24
5.5
"
width=
"167"
height=
"103"
/>
</imageView>
</subviews>
<color
key=
"backgroundColor"
systemColor=
"systemBackgroundColor"
/>
...
...
ShorthandMaster/Record/SHRecordDetailsVC.swift
View file @
446c75f7
...
...
@@ -128,11 +128,12 @@ class SHRecordDetailsVC: SHBaseViewController {
@objc
func
editClick
(
_
restore
:
Bool
){
self
.
markAlertViewShow
(
false
)
self
.
bottomView
?
.
cancel
=
true
if
restore
==
false
{
if
currentModel
.
dataSources
.
count
==
0
{
return
}
edit
=
!
edit
}
else
{
edit
=
false
...
...
@@ -210,7 +211,9 @@ extension SHRecordDetailsVC {
//MARK:icloud上传Models
func
icloundUpload
(
_
index
:
NSInteger
){
let
model
=
currentModel
.
dataSources
[
index
]
if
model
.
processing
==
true
{
return
}
var
contains
=
false
for
folderModel
in
SHCloudManager
.
shared
.
icloudFolderModels
{
if
currentModel
.
id
==
folderModel
.
id
{
...
...
@@ -219,10 +222,12 @@ extension SHRecordDetailsVC {
}
}
model
.
processing
=
true
if
contains
{
SHCloudManager
.
shared
.
addNewRecord
(
model
)
{
(
result
,
models
)
in
if
result
{
model
.
icloud
=
true
model
.
processing
=
false
SHCloudManager
.
shared
.
modifyFolder
(
self
.
currentModel
)
{
(
result
,
models
)
in
if
result
{
self
.
updateocloudUI
()
...
...
@@ -234,6 +239,7 @@ extension SHRecordDetailsVC {
SHCloudManager
.
shared
.
addNewRecord
(
model
)
{
(
result
,
models
)
in
if
result
{
model
.
icloud
=
true
model
.
processing
=
false
SHCloudManager
.
shared
.
addNewFolder
(
self
.
currentModel
)
{
(
result
,
models
)
in
if
result
{
self
.
updateocloudUI
()
...
...
@@ -310,11 +316,8 @@ extension SHRecordDetailsVC {
if
self
.
currentModel
.
dataSources
.
count
==
0
{
self
.
editClick
(
true
)
self
.
markAlertViewShow
(
false
)
self
.
bottomView
?
.
cancel
=
true
}
self
.
selectRecordModels
=
[]
// edit = false
DispatchQueue
.
main
.
async
{
self
.
tableView
?
.
reloadData
()
}
...
...
ShorthandMaster/Record/SHRecordListViewController.swift
View file @
446c75f7
...
...
@@ -158,56 +158,6 @@ class SHRecordListViewController: SHBaseViewController {
}
}
var
list
=
keyValueStore
.
object
(
forKey
:
"Folderlist"
)
as?
[
Dictionary
<
String
,
Any
>
]
if
list
==
nil
{
list
=
keyValueStore
.
object
(
forKey
:
"list"
)
as?
[
Dictionary
<
String
,
Any
>
]
}
list
=
nil
if
let
list
=
list
{
var
folderModel
=
SHRecordFolderModel
()
if
let
sub
=
list
.
first
{
folderModel
=
getDataDictWith
(
dict
:
sub
)
if
folderModel
.
id
.
length
==
0
{
folderModel
.
createDate
=
nowDate
folderModel
.
modifyDate
=
nowDate
folderModel
.
name
=
"未知"
;
folderModel
.
id
=
nowDate
.
milliStamp
for
dic
in
list
.
reversed
(){
var
model
=
SHRecordModel
()
model
=
getDataDictWith
(
dict
:
dic
)
folderModel
.
dataSources
.
append
(
model
)
}
let
modifyDateSortDataSources
=
folderModel
.
dataSources
.
sorted
{
(
model0
,
model1
)
->
Bool
in
return
model0
.
modifyDate
.
compare
(
model1
.
modifyDate
)
==
ComparisonResult
.
orderedDescending
}
folderModel
.
modifyDate
=
modifyDateSortDataSources
.
first
?
.
modifyDate
??
nowDate
let
modelDict
=
getDictWith
(
obj
:
folderModel
)
keyValueStore
.
set
([
modelDict
],
forKey
:
"Folderlist"
)
keyValueStore
.
synchronize
()
print
(
"synchronize ===
\(
keyValueStore
.
synchronize
()
)
"
)
}
}
// let modityList = keyValueStore.object(forKey: "Folderlist") as? [Dictionary<String, Any>]
// if let list = modityList {
// for dict in list.reversed(){
// var model = SHRecordFolderModel()
// model = getDataDictWith(dict: dict)
// if model.top == true {
// topDataSources.append(model)
// }else{
// dataSources.append(model)
// }
// }
// }
dataSources
=
dataSources
.
filterDuplicates
({
$0
.
id
})
topDataSources
=
topDataSources
.
filterDuplicates
({
$0
.
id
})
switch
CRUserDefaults
.
sortType
{
case
0
:
dataSources
.
sort
{
(
model0
,
model1
)
->
Bool
in
...
...
@@ -226,26 +176,6 @@ class SHRecordListViewController: SHBaseViewController {
}
break
}
}
else
{
switch
CRUserDefaults
.
sortType
{
case
0
:
dataSources
.
sort
{
(
model0
,
model1
)
->
Bool
in
return
model0
.
createDate
.
compare
(
model1
.
createDate
)
==
ComparisonResult
.
orderedDescending
}
topDataSources
.
sort
{
(
model0
,
model1
)
->
Bool
in
return
model0
.
createDate
.
compare
(
model1
.
createDate
)
==
ComparisonResult
.
orderedDescending
}
break
default
:
dataSources
.
sort
{
(
model0
,
model1
)
->
Bool
in
return
model0
.
modifyDate
.
compare
(
model1
.
modifyDate
)
==
ComparisonResult
.
orderedDescending
}
topDataSources
.
sort
{
(
model0
,
model1
)
->
Bool
in
return
model0
.
modifyDate
.
compare
(
model1
.
modifyDate
)
==
ComparisonResult
.
orderedDescending
}
break
}
}
dataSources
=
topDataSources
+
dataSources
...
...
@@ -260,7 +190,6 @@ class SHRecordListViewController: SHBaseViewController {
self
.
view
.
sendSubviewToBack
(
maskView
)
}
markCountLab
?
.
text
=
"笔记本总数:
\(
dataSources
.
count
)
"
}
@objc
func
mineCilck
(){
...
...
@@ -541,7 +470,7 @@ extension SHRecordListViewController: UITableViewDelegate, UITableViewDataSource
self
.
removeModel
(
indexPath
)
completionHandler
(
tru
e
)
completionHandler
(
fals
e
)
}
deleteAction
.
image
=
UIImage
.
init
(
named
:
"recordlist_delete"
)
deleteAction
.
backgroundColor
=
UIColor
.
init
(
hexStr
:
"E93425"
)
...
...
@@ -550,7 +479,7 @@ extension SHRecordListViewController: UITableViewDelegate, UITableViewDataSource
self
.
renameModel
(
indexPath
)
completionHandler
(
tru
e
)
completionHandler
(
fals
e
)
}
renameAction
.
image
=
UIImage
.
init
(
named
:
"recordlist_rename"
)
renameAction
.
backgroundColor
=
UIColor
.
init
(
hexStr
:
"BCBCBC"
)
...
...
ShorthandMaster/Record/SHRecordMoveFileVC.swift
View file @
446c75f7
...
...
@@ -151,7 +151,7 @@ class SHRecordMoveFileVC: SHBaseViewController {
}
}
}
MBProgressHUD
.
show
(
"正在
处理
中,请稍后..."
,
view
:
nil
)
MBProgressHUD
.
show
(
"正在
转移
中,请稍后..."
,
view
:
nil
)
let
list
=
CRUserDefaults
.
recordList
if
var
recordList
=
list
{
//增
...
...
@@ -183,14 +183,15 @@ class SHRecordMoveFileVC: SHBaseViewController {
}
SHCloudManager
.
shared
.
modifyFolder
(
self
.
currentModel
)
{
(
result
,
models
)
in
if
result
{
var
contains
=
false
for
folderModel
in
SHCloudManager
.
shared
.
icloudFolderModels
{
if
targetModel
.
id
==
folderModel
.
id
{
let
folderRecord
=
SHCloudManager
.
shared
.
icloudFolderModels
.
filter
({
$0
.
id
==
targetModel
.
id
})
.
first
if
folderRecord
!=
nil
{
contains
=
true
break
}
}
if
contains
{
SHCloudManager
.
shared
.
modifyFolder
(
targetModel
)
{
(
result
,
models
)
in
if
result
{
...
...
@@ -202,6 +203,17 @@ class SHRecordMoveFileVC: SHBaseViewController {
}
}
}
else
{
let
folderRecord
=
targetModel
.
dataSources
.
filter
({
$0
.
icloud
==
true
})
.
first
if
folderRecord
==
nil
{
self
.
saveSuccessCallBack
?(
self
.
currentModel
)
DispatchQueue
.
main
.
async
{
MBProgressHUD
.
hide
()
self
.
navigationController
?
.
dismiss
(
animated
:
true
,
completion
:
nil
)
}
return
}
SHCloudManager
.
shared
.
addNewFolder
(
targetModel
)
{
(
result
,
models
)
in
if
result
{
self
.
saveSuccessCallBack
?(
self
.
currentModel
)
...
...
@@ -214,7 +226,6 @@ class SHRecordMoveFileVC: SHBaseViewController {
}
}
}
}
}
//MARK: tableView delegate
...
...
ShorthandMaster/Record/SHRecordViewController.swift
View file @
446c75f7
...
...
@@ -263,10 +263,6 @@ class SHRecordViewController: SHBaseViewController{
func
saveContent
(){
// if currentTxt?.length == 0 {
// return
// }
let
nowDate
=
Date
()
let
model
=
SHRecordModel
()
model
.
recordingType
=
0
...
...
@@ -279,17 +275,17 @@ class SHRecordViewController: SHBaseViewController{
model
.
pcmPathFile
=
pcm_file_path
model
.
during
=
seconds
image_file_paths
=
[]
image_indexs
=
[]
let
images
=
[
"recordlist_no_data_search"
,
"recordlist_no_data"
]
for
(
index
,
imageStr
)
in
images
.
enumerated
(){
let
image
=
UIImage
.
init
(
named
:
imageStr
)
let
filePath
=
DocumentPath
+
image_file_path
+
"
\(
index
)
.jpeg"
let
imageData
=
image
!.
jpegData
(
compressionQuality
:
1
)
try
?
imageData
?
.
write
(
to
:
URL
(
fileURLWithPath
:
filePath
))
image_file_paths
.
append
(
image_file_path
+
"
\(
index
)
.jpeg"
)
image_indexs
.
append
(
index
)
}
//
image_file_paths = []
//
image_indexs = []
//
let images = ["recordlist_no_data_search", "recordlist_no_data"]
//
for (index, imageStr) in images.enumerated(){
//
let image = UIImage.init(named: imageStr)
//
let filePath = DocumentPath+image_file_path+"\(index).jpeg"
//
let imageData = image!.jpegData(compressionQuality: 1)
//
try? imageData?.write(to: URL(fileURLWithPath: filePath))
//
image_file_paths.append(image_file_path+"\(index).jpeg")
//
image_indexs.append(index)
//
}
model
.
imagesPath
=
[]
model
.
imagesIndex
=
[]
...
...
ShorthandMaster/Share/Managers/SHAVAudioManager.swift
View file @
446c75f7
...
...
@@ -177,6 +177,7 @@ class SHAVAudioManager: NSObject {
let
lowPassResults
=
pow
(
10
,
(
0.05
*
(
self
.
monitor
?
.
peakPower
(
forChannel
:
0
))
!
));
decibelsCallBack
?(
lowPassResults
)
// print("lowPassResults == \(lowPassResults)")
// print("decibels == \(decibels)")
if
decibels
>
-
44
{
if
recognitionTask
?
.
isCancelled
==
true
&&
self
.
state
==
SHRecordState
.
start
{
...
...
@@ -260,7 +261,7 @@ class SHAVAudioManager: NSObject {
return
$0
+
" "
+
$1
}}
)
if
recorderResult
.
hasSuffix
(
"
\n
"
)
{
if
recorderResult
.
hasSuffix
(
"
\n
"
)
||
recorderResult
.
length
==
0
{
recorderResult
=
recorderResult
+
processStr
}
else
{
recorderResult
=
recorderResult
+
" "
+
processStr
...
...
ShorthandMaster/Share/Managers/SHCloudManager.swift
View file @
446c75f7
...
...
@@ -41,6 +41,7 @@ class SHCloudManager: NSObject {
container
.
accountStatus
{
(
status
,
statusError
)
in
if
let
error
=
statusError
{
MBProgressHUD
.
showError
(
"未知错误,终止操作"
)
self
.
statusHandler
?(
false
)
print
(
"
\(
error
.
localizedDescription
)
"
)
}
else
{
...
...
@@ -48,7 +49,12 @@ class SHCloudManager: NSObject {
case
.
available
:
self
.
statusHandler
?(
true
)
break
;
case
.
noAccount
:
MBProgressHUD
.
showError
(
"请确认您的iCloid是否开启"
)
self
.
statusHandler
?(
false
)
break
;
default
:
MBProgressHUD
.
showError
(
"未知错误,终止操作"
)
self
.
statusHandler
?(
false
)
break
;
}
...
...
@@ -60,10 +66,12 @@ class SHCloudManager: NSObject {
completionHandler
=
handler
self
.
cheakAccountStatus
{
result
in
if
result
==
true
{
let
predicate
=
NSPredicate
.
init
(
value
:
true
)
let
query
=
CKQuery
.
init
(
recordType
:
recordFolderName
,
predicate
:
predicate
)
let
query
=
CKQuery
.
init
(
recordType
:
self
.
recordFolderName
,
predicate
:
predicate
)
dateBase
.
perform
(
query
,
inZoneWith
:
nil
)
{
(
records
,
queryError
)
in
self
.
dateBase
.
perform
(
query
,
inZoneWith
:
nil
)
{
(
records
,
queryError
)
in
if
let
error
=
queryError
{
print
(
"
\(
error
.
localizedDescription
)
"
)
...
...
@@ -71,7 +79,11 @@ class SHCloudManager: NSObject {
}
else
{
self
.
folderResults
=
records
??
[]
self
.
getAllRecordDataSource
(
handler
)
// self.cleanAllFolder()
// self.cleanAllFolder()
}
}
}
else
{
self
.
completionHandler
?(
false
,
[])
}
}
}
...
...
@@ -80,10 +92,12 @@ class SHCloudManager: NSObject {
completionHandler
=
handler
self
.
cheakAccountStatus
{
result
in
if
result
==
true
{
let
predicate
=
NSPredicate
.
init
(
value
:
true
)
let
query
=
CKQuery
.
init
(
recordType
:
recordName
,
predicate
:
predicate
)
let
query
=
CKQuery
.
init
(
recordType
:
self
.
recordName
,
predicate
:
predicate
)
dateBase
.
perform
(
query
,
inZoneWith
:
nil
)
{
(
records
,
queryError
)
in
self
.
dateBase
.
perform
(
query
,
inZoneWith
:
nil
)
{
(
records
,
queryError
)
in
if
let
error
=
queryError
{
print
(
"
\(
error
.
localizedDescription
)
"
)
...
...
@@ -92,7 +106,11 @@ class SHCloudManager: NSObject {
self
.
recordResults
=
records
??
[]
self
.
mapDataSource
()
self
.
completionHandler
?(
true
,
self
.
icloudFolderModels
)
// self.cleanAllRecord()
// self.cleanAllRecord()
}
}
}
else
{
self
.
completionHandler
?(
false
,
[])
}
}
}
...
...
@@ -197,7 +215,9 @@ class SHCloudManager: NSObject {
folderRecord
.
setValue
(
model
.
top
,
forKey
:
"top"
)
folderRecord
.
setValue
(
recordPaths
,
forKey
:
"recordPaths"
)
dateBase
.
save
(
folderRecord
)
{
(
subscription
,
saveError
)
in
self
.
cheakAccountStatus
{
result
in
if
result
==
true
{
self
.
dateBase
.
save
(
folderRecord
)
{
(
subscription
,
saveError
)
in
if
let
error
=
saveError
{
print
(
"
\(
error
.
localizedDescription
)
"
)
self
.
completionHandler
?(
false
,
[])
...
...
@@ -207,6 +227,10 @@ class SHCloudManager: NSObject {
self
.
completionHandler
?(
true
,
self
.
icloudFolderModels
)
}
}
}
else
{
self
.
completionHandler
?(
false
,
[])
}
}
}
func
addNewRecord
(
_
recordModel
:
SHRecordModel
,
handler
:
@escaping
CompletionHandler
){
...
...
@@ -217,7 +241,11 @@ class SHCloudManager: NSObject {
return
item
[
"pathFile"
]
==
recordModel
.
pathFile
})
.
first
if
recording
==
nil
{
if
recording
!=
nil
{
self
.
completionHandler
?(
false
,
[])
return
}
let
documentsFile
=
DocumentPath
.
appending
(
recordModel
.
pathFile
)
let
url
=
URL
.
init
(
fileURLWithPath
:
documentsFile
)
let
asset
=
CKAsset
.
init
(
fileURL
:
url
)
...
...
@@ -245,7 +273,9 @@ class SHCloudManager: NSObject {
}
record
.
setValue
(
imageAssets
,
forKey
:
"imagesAsset"
)
dateBase
.
save
(
record
)
{
(
subscription
,
saveError
)
in
self
.
cheakAccountStatus
{
result
in
if
result
==
true
{
self
.
dateBase
.
save
(
record
)
{
(
subscription
,
saveError
)
in
if
let
error
=
saveError
{
print
(
"
\(
error
.
localizedDescription
)
"
)
self
.
completionHandler
?(
false
,
[])
...
...
@@ -256,7 +286,8 @@ class SHCloudManager: NSObject {
}
}
}
else
{
self
.
completionHandler
?(
false
,
[])
}
}
}
...
...
@@ -276,8 +307,14 @@ class SHCloudManager: NSObject {
return
item
[
"id"
]
==
folderModel
.
id
})
.
first
dateBase
.
fetch
(
withRecordID
:
folderRecord
!.
recordID
)
{
(
record
,
fetchError
)
in
if
folderRecord
==
nil
{
self
.
completionHandler
?(
false
,
[])
return
}
self
.
cheakAccountStatus
{
result
in
if
result
==
true
{
self
.
dateBase
.
fetch
(
withRecordID
:
folderRecord
!.
recordID
)
{
(
record
,
fetchError
)
in
if
let
error
=
fetchError
{
print
(
"
\(
error
.
localizedDescription
)
"
)
self
.
completionHandler
?(
false
,
[])
...
...
@@ -302,6 +339,10 @@ class SHCloudManager: NSObject {
}
}
}
}
else
{
self
.
completionHandler
?(
false
,
[])
}
}
}
func
modifyRecord
(
_
recordModel
:
SHRecordModel
,
handler
:
@escaping
CompletionHandler
){
...
...
@@ -312,8 +353,9 @@ class SHCloudManager: NSObject {
return
item
[
"pathFile"
]
==
recordModel
.
pathFile
})
.
first
dateBase
.
fetch
(
withRecordID
:
recording
!.
recordID
)
{
(
record
,
fetchError
)
in
self
.
cheakAccountStatus
{
result
in
if
result
==
true
{
self
.
dateBase
.
fetch
(
withRecordID
:
recording
!.
recordID
)
{
(
record
,
fetchError
)
in
if
let
error
=
fetchError
{
print
(
"
\(
error
.
localizedDescription
)
"
)
self
.
completionHandler
?(
false
,
[])
...
...
@@ -340,6 +382,10 @@ class SHCloudManager: NSObject {
}
}
}
}
else
{
self
.
completionHandler
?(
false
,
[])
}
}
}
func
deleteFolder
(
_
folderModel
:
SHRecordFolderModel
,
handler
:
@escaping
CompletionHandler
){
...
...
@@ -355,7 +401,9 @@ class SHCloudManager: NSObject {
return
}
dateBase
.
delete
(
withRecordID
:
folderRecord
!.
recordID
)
{
(
recordID
,
deleteError
)
in
self
.
cheakAccountStatus
{
result
in
if
result
==
true
{
self
.
dateBase
.
delete
(
withRecordID
:
folderRecord
!.
recordID
)
{
(
recordID
,
deleteError
)
in
if
let
error
=
deleteError
{
print
(
"
\(
error
.
localizedDescription
)
"
)
...
...
@@ -370,6 +418,10 @@ class SHCloudManager: NSObject {
self
.
completionHandler
?(
true
,
self
.
icloudFolderModels
)
}
}
}
else
{
self
.
completionHandler
?(
false
,
[])
}
}
}
func
deleteRecord
(
_
recordModel
:
SHRecordModel
,
handler
:
@escaping
CompletionHandler
){
...
...
@@ -384,9 +436,9 @@ class SHCloudManager: NSObject {
self
.
completionHandler
?(
false
,
[])
return
}
dateBase
.
delete
(
withRecordID
:
record
!.
recordID
)
{
(
recordID
,
deleteError
)
in
self
.
cheakAccountStatus
{
result
in
if
result
==
true
{
self
.
dateBase
.
delete
(
withRecordID
:
record
!.
recordID
)
{
(
recordID
,
deleteError
)
in
if
let
error
=
deleteError
{
print
(
"
\(
error
.
localizedDescription
)
"
)
self
.
completionHandler
?(
false
,
[])
...
...
@@ -400,6 +452,10 @@ class SHCloudManager: NSObject {
self
.
completionHandler
?(
true
,
self
.
icloudFolderModels
)
}
}
}
else
{
self
.
completionHandler
?(
false
,
[])
}
}
}
func
deleteRecord
(
_
record
:
CKRecord
,
handler
:
@escaping
CompletionHandler
){
...
...
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