Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
GMBase
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
GMBase
Commits
a9b29a01
Commit
a9b29a01
authored
Oct 16, 2017
by
汪洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加可以不去重的方法
parent
7011e4f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
13 deletions
+21
-13
WMFetchDataViewModel.h
GMBase/Classes/WMFetchDataViewModel.h
+4
-0
WMFetchDataViewModel.m
GMBase/Classes/WMFetchDataViewModel.m
+17
-13
No files found.
GMBase/Classes/WMFetchDataViewModel.h
View file @
a9b29a01
...
@@ -81,6 +81,10 @@
...
@@ -81,6 +81,10 @@
*/
*/
NSString
*
_deduplicationKey
;
NSString
*
_deduplicationKey
;
}
}
@property
(
nonatomic
,
copy
)
NSArray
*
notDeduplicate
;
// 去重时被去掉的数据总计。在上拉加载更多时,这个数目仍要被用上,否则在某种极端的情况下,startNum会与服务器对不上,导致出现没有数据返回
@property
(
nonatomic
,
assign
)
NSInteger
deleteCount
;
/** @brief 记录服务器返回的字段 message 用来显示空白文案*/
/** @brief 记录服务器返回的字段 message 用来显示空白文案*/
@property
(
nonatomic
,
strong
)
NSString
*
message
;
@property
(
nonatomic
,
strong
)
NSString
*
message
;
...
...
GMBase/Classes/WMFetchDataViewModel.m
View file @
a9b29a01
...
@@ -10,8 +10,7 @@
...
@@ -10,8 +10,7 @@
@implementation
WMFetchDataViewModel
@implementation
WMFetchDataViewModel
{
{
// 去重时被去掉的数据总计。在上拉加载更多时,这个数目仍要被用上,否则在某种极端的情况下,startNum会与服务器对不上,导致出现没有数据返回
NSInteger
_deleteCount
;
}
}
-
(
instancetype
)
init
{
-
(
instancetype
)
init
{
self
=
[
super
init
];
self
=
[
super
init
];
...
@@ -162,19 +161,24 @@
...
@@ -162,19 +161,24 @@
// NSMutableArray 不是线程安全的,不能使用并行枚举。参考https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html
// NSMutableArray 不是线程安全的,不能使用并行枚举。参考https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html
[
array
enumerateObjectsUsingBlock
:
^
(
id
_Nonnull
obj
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
[
array
enumerateObjectsUsingBlock
:
^
(
id
_Nonnull
obj
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
id
value
=
[
obj
valueForKey
:
_deduplicationKey
];
if
([
self
.
notDeduplicate
containsObject
:
obj
[
@"type"
]])
{
NSString
*
key
=
[
value
isKindOfClass
:[
NSString
class
]]
?
value
:
[
value
stringValue
];
id
object
=
buildBlock
(
obj
);
NSAssert
(
key
.
length
>
0
,
@"key 怎么会是一个空???!!!"
);
[
result
addObject
:
object
];
if
(
!
_deduplicationDic
[
key
])
{
}
else
{
if
([
obj
isKindOfClass
:[
NSDictionary
class
]])
{
id
value
=
[
obj
valueForKey
:
_deduplicationKey
];
id
object
=
buildBlock
(
obj
);
NSString
*
key
=
[
value
isKindOfClass
:[
NSString
class
]]
?
value
:
[
value
stringValue
];
[
result
addObject
:
object
];
NSAssert
(
key
.
length
>
0
,
@"key 怎么会是一个空???!!!"
);
if
(
!
_deduplicationDic
[
key
])
{
if
([
obj
isKindOfClass
:[
NSDictionary
class
]])
{
id
object
=
buildBlock
(
obj
);
[
result
addObject
:
object
];
}
else
{
[
result
addObject
:
obj
];
}
_deduplicationDic
[
key
]
=
@1
;
}
else
{
}
else
{
[
result
addObject
:
obj
]
;
self
.
deleteCount
++
;
}
}
_deduplicationDic
[
key
]
=
@1
;
}
else
{
_deleteCount
++
;
}
}
}];
}];
...
...
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