Skip to content

Commit 7ceb863

Browse files
author
15038777234
committed
修复一些变量作用域问题
1 parent 52d57be commit 7ceb863

5 files changed

Lines changed: 23 additions & 39 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,4 @@ pod 'ZHTableViewGroupSwift'
9494

9595
```swift
9696
self.dataSource?.clearData()
97-
```
97+
```

ZHTableViewGroupSwift.podspec

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,16 @@
99
Pod::Spec.new do |s|
1010
s.name = 'ZHTableViewGroupSwift'
1111
s.version = '0.1.0'
12-
s.summary = 'A short description of ZHTableViewGroupSwift.'
13-
14-
# This description is used to generate tags and improve search results.
15-
# * Think: What does it do? Why did you write it? What is the focus?
16-
# * Try to keep it short, snappy and to the point.
17-
# * Write the description between the DESC delimiters below.
18-
# * Finally, don't worry about the indent, CocoaPods strips it!
19-
20-
s.description = <<-DESC
21-
TODO: Add long description of the pod here.
22-
DESC
23-
24-
s.homepage = 'https://github.com/15038777234/ZHTableViewGroupSwift'
25-
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
12+
s.summary = 'ZHTableViewGroup为 UITableView 而生'
13+
s.homepage = 'https://github.com/josercc/ZHTableViewGroupSwift'
2614
s.license = { :type => 'MIT', :file => 'LICENSE' }
2715
s.author = { '15038777234' => '15038777234@163.com' }
28-
s.source = { :git => 'https://github.com/15038777234/ZHTableViewGroupSwift.git', :tag => s.version.to_s }
29-
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
30-
16+
s.source = { :git => 'https://github.com/josercc/ZHTableViewGroupSwift.git', :tag => s.version.to_s }
3117
s.ios.deployment_target = '8.0'
32-
3318
s.source_files = 'ZHTableViewGroupSwift/Classes/**/*'
34-
3519
# s.resource_bundles = {
3620
# 'ZHTableViewGroupSwift' => ['ZHTableViewGroupSwift/Assets/*.png']
3721
# }
38-
3922
# s.public_header_files = 'Pod/Classes/**/*.h'
4023
# s.frameworks = 'UIKit', 'MapKit'
4124
# s.dependency 'AFNetworking', '~> 2.3'

ZHTableViewGroupSwift/Classes/ZHTableViewCell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public class ZHTableViewCell: NSObject {
1818

1919
public var cellNumber:Int = 0
2020

21-
var configCompletionHandle:ZHTableViewCellCompletionHandle?
21+
private var configCompletionHandle:ZHTableViewCellCompletionHandle?
2222

23-
var didSelectRowCompletionHandle:ZHTableViewCellCompletionHandle?
23+
private var didSelectRowCompletionHandle:ZHTableViewCellCompletionHandle?
2424

2525
public var anyClass:AnyClass?
2626

ZHTableViewGroupSwift/Classes/ZHTableViewDataSource.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class ZHTableViewDataSource: NSObject {
2424
}
2525

2626
/// ZHTableViewGroup的数组
27-
public var groups:[ZHTableViewGroup] = []
27+
private var groups:[ZHTableViewGroup] = []
2828

2929
/// 初始化ZHTableViewDataSource数据源
3030
///
@@ -35,14 +35,14 @@ public class ZHTableViewDataSource: NSObject {
3535
}
3636

3737
/// 托管 UITableView 的对象
38-
var tableView:UITableView
38+
private var tableView:UITableView
3939

4040
public func reloadTableViewData() {
4141
self.registerClass()
4242
self.tableView.reloadData()
4343
}
4444

45-
func registerClass() {
45+
private func registerClass() {
4646
for group in self.groups {
4747
group.registerHeaderFooterCell(tableView: self.tableView)
4848
}
@@ -86,7 +86,7 @@ public class ZHTableViewDataSource: NSObject {
8686
/// - dataSource: ZHTableViewDataSource的数据源可以为 nil
8787
/// - section: 分组的索引
8888
/// - Returns: 对应分组对象可能为 nil
89-
class func groupForSection(dataSource:ZHTableViewDataSource?, section:Int) -> ZHTableViewGroup? {
89+
private class func groupForSection(dataSource:ZHTableViewDataSource?, section:Int) -> ZHTableViewGroup? {
9090
guard let dataSource = dataSource else {
9191
// 当用户还没有创建ZHTableViewDataSource对象返回 nil
9292
return nil
@@ -98,7 +98,7 @@ public class ZHTableViewDataSource: NSObject {
9898
return dataSource.groups[section]
9999
}
100100

101-
class func cellForIndexPath(dataSource:ZHTableViewDataSource?, atIndexPath indexPath:IndexPath) -> ZHTableViewCell? {
101+
private class func cellForIndexPath(dataSource:ZHTableViewDataSource?, atIndexPath indexPath:IndexPath) -> ZHTableViewCell? {
102102
guard let group = groupForSection(dataSource: dataSource, section: indexPath.section) else {
103103
return nil
104104
}
@@ -124,7 +124,7 @@ public class ZHTableViewDataSource: NSObject {
124124
return heightWithCustomHandle(height: cell.height, customCompletionHandle: customHeightCompletionHandle)
125125
}
126126

127-
class func heightWithCustomHandle(height:CGFloat, customCompletionHandle:ZHTableViewDataSourceCustomHeightCompletionHandle?) -> CGFloat {
127+
private class func heightWithCustomHandle(height:CGFloat, customCompletionHandle:ZHTableViewDataSourceCustomHeightCompletionHandle?) -> CGFloat {
128128
if height == CGFloat(NSNotFound) {
129129
guard let customCompletionHandle = customCompletionHandle else {
130130
return 0
@@ -151,7 +151,7 @@ public class ZHTableViewDataSource: NSObject {
151151
return heightForHeaderFooterInSection(dataSource: dataSource, section: section, customHeightCompletionHandle: customHeightCompletionHandle, headerFooterStyle: .footer)
152152
}
153153

154-
class func heightForHeaderFooterInSection(dataSource:ZHTableViewDataSource?, section:Int, customHeightCompletionHandle:ZHTableViewDataSourceCustomHeightCompletionHandle?, headerFooterStyle:ZHTableViewHeaderFooterStyle) -> CGFloat {
154+
private class func heightForHeaderFooterInSection(dataSource:ZHTableViewDataSource?, section:Int, customHeightCompletionHandle:ZHTableViewDataSourceCustomHeightCompletionHandle?, headerFooterStyle:ZHTableViewHeaderFooterStyle) -> CGFloat {
155155
guard let group = groupForSection(dataSource: dataSource, section: section) else {
156156
return 0
157157
}
@@ -179,7 +179,7 @@ public class ZHTableViewDataSource: NSObject {
179179
return viewHeaderFooterInSection(dataSource: dataSource, section: section, style: .footer)
180180
}
181181

182-
class func viewHeaderFooterInSection(dataSource:ZHTableViewDataSource?, section:Int, style:ZHTableViewHeaderFooterStyle) -> UITableViewHeaderFooterView? {
182+
private class func viewHeaderFooterInSection(dataSource:ZHTableViewDataSource?, section:Int, style:ZHTableViewHeaderFooterStyle) -> UITableViewHeaderFooterView? {
183183
guard let group = groupForSection(dataSource: dataSource, section: section) else {
184184
return nil
185185
}

ZHTableViewGroupSwift/Classes/ZHTableViewGroup.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ public typealias ZHTableViewGroupAddCellCompletionHandle = (_ cell:ZHTableViewCe
1212
public typealias ZHTableViewGroupAddHeaderFooterCompletionHandle = (_ headerFooter:ZHTableViewHeaderFooter) -> Void
1313

1414
public class ZHTableViewGroup: NSObject {
15-
public var cells:[ZHTableViewCell] = []
1615

17-
var header:ZHTableViewHeaderFooter?
16+
var cells:[ZHTableViewCell] = []
1817

19-
var footer:ZHTableViewHeaderFooter?
18+
public var header:ZHTableViewHeaderFooter?
2019

21-
public var cellCount:Int {
20+
public var footer:ZHTableViewHeaderFooter?
21+
22+
var cellCount:Int {
2223
get {
2324
var count:Int = 0
2425
for cell in self.cells {
@@ -53,7 +54,7 @@ public class ZHTableViewGroup: NSObject {
5354
/// - tableView: 对应的表格 可能为 nil
5455
/// - indexPath: 对应的 IndexPath 索引
5556
/// - Returns: UITableViewCell可能为 nil
56-
public func cellForTableView(tableView:UITableView?, atIndexPath indexPath:IndexPath) -> UITableViewCell? {
57+
func cellForTableView(tableView:UITableView?, atIndexPath indexPath:IndexPath) -> UITableViewCell? {
5758
guard let tableView = tableView else {
5859
// 当表格不存在返回 nil
5960
return nil
@@ -71,7 +72,7 @@ public class ZHTableViewGroup: NSObject {
7172
return cell
7273
}
7374

74-
public func headerFooterForStyle(tableView:UITableView?, style:ZHTableViewHeaderFooterStyle) -> UITableViewHeaderFooterView? {
75+
func headerFooterForStyle(tableView:UITableView?, style:ZHTableViewHeaderFooterStyle) -> UITableViewHeaderFooterView? {
7576
guard let tableView = tableView else {
7677
return nil
7778
}
@@ -93,7 +94,7 @@ public class ZHTableViewGroup: NSObject {
9394
return tableView.dequeueReusableHeaderFooterView(withIdentifier: identifier)
9495
}
9596

96-
public func registerHeaderFooterCell(tableView:UITableView) {
97+
func registerHeaderFooterCell(tableView:UITableView) {
9798
if let headerIdentifier = self.header?.identifier {
9899
tableView.register(self.header?.anyClass, forHeaderFooterViewReuseIdentifier: headerIdentifier)
99100
}
@@ -113,7 +114,7 @@ public class ZHTableViewGroup: NSObject {
113114
///
114115
/// - Parameter indexPath: IndexPath 的索引
115116
/// - Returns: ZHTableViewCell可能为 nil
116-
public func tableViewCellForIndexPath(indexPath:IndexPath) -> ZHTableViewCell? {
117+
func tableViewCellForIndexPath(indexPath:IndexPath) -> ZHTableViewCell? {
117118
guard indexPath.row < self.cellCount else {
118119
// 如果索引超出了总个数就返回 nil
119120
return nil

0 commit comments

Comments
 (0)