Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
fix syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
RayPan committed Dec 18, 2016
1 parent 81e373c commit bc4d173
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
8 changes: 4 additions & 4 deletions Gank.lu.xcodeproj/project.pbxproj
Expand Up @@ -307,18 +307,18 @@
BE3078AF1C38272500B007EA = {
CreatedOnToolsVersion = 7.2;
DevelopmentTeam = BG63VCU95W;
LastSwiftMigration = 0800;
LastSwiftMigration = 0820;
};
BE3078C31C38272500B007EA = {
CreatedOnToolsVersion = 7.2;
DevelopmentTeam = BG63VCU95W;
LastSwiftMigration = 0800;
LastSwiftMigration = 0820;
TestTargetID = BE3078AF1C38272500B007EA;
};
BE3078CE1C38272500B007EA = {
CreatedOnToolsVersion = 7.2;
DevelopmentTeam = BG63VCU95W;
LastSwiftMigration = 0800;
LastSwiftMigration = 0820;
TestTargetID = BE3078AF1C38272500B007EA;
};
};
Expand Down Expand Up @@ -402,7 +402,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
C7352F21A16693FCA7116475 /* [CP] Embed Pods Frameworks */ = {
Expand Down
4 changes: 2 additions & 2 deletions Gank.lu/CategoryViewController.swift
Expand Up @@ -54,7 +54,7 @@ class CategoryViewController: UITableViewController {
func pullToRefresh(){
loadingMore = false
page = 1
GankHttp.shareInstance.fetchGankWithCategory(category: category, page: page){
GankHttp.shareInstance.fetchGankWithCategory(category, page: page){
success,result in
if success{
self.page += 1
Expand All @@ -71,7 +71,7 @@ class CategoryViewController: UITableViewController {
func pullToLoadMore(){
loadingMore = true
tableView.mj_footer.beginRefreshing()
GankHttp.shareInstance.fetchGankWithCategory(category: category, page: page){
GankHttp.shareInstance.fetchGankWithCategory(category, page: page){
success,result in
if success{
self.page += 1
Expand Down
16 changes: 8 additions & 8 deletions Gank.lu/GankHttpClient.swift
Expand Up @@ -8,25 +8,25 @@

import Alamofire
protocol GankHttpDelegate{
func gankDataReceived(json:AnyObject)
func gankDataReceived(_ json:AnyObject)
func gankFetchFailed()
}

protocol GirlHttpDelegate{
func girlDataReceived(json:AnyObject)
func girlDataReceived(_ json:AnyObject)
func girlFetchFailed()
}
class GankHttp {
let baseUrl = "http://gank.io/api/"
let requestNumber = 20
private static let singleInstance = GankHttp()
fileprivate static let singleInstance = GankHttp()
var delegate:GankHttpDelegate?
var girlDelegate:GirlHttpDelegate?
class var shareInstance : GankHttp {
return singleInstance
}

func fetchGirlData(page:Int){
func fetchGirlData(_ page:Int){
let requestUrl = (baseUrl + "data/福利/\(requestNumber)/\(page)").addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)
print(requestUrl ?? "")

Expand All @@ -38,11 +38,11 @@ class GankHttp {
return
}
print("Debug",response)
self.girlDelegate?.girlDataReceived(json: json as AnyObject)
self.girlDelegate?.girlDataReceived(json as AnyObject)
}
}

func fetchGankDataAtYear(year:Int,month:Int,day:Int){
func fetchGankDataAtYear(_ year:Int,month:Int,day:Int){
let requestUrl = (baseUrl + "day/\(year)/\(month)/\(day)").addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)
print(requestUrl ?? "")
Alamofire.request(requestUrl!, method: .get).responseJSON(){
Expand All @@ -51,11 +51,11 @@ class GankHttp {
self.delegate?.gankFetchFailed()
return
}
self.delegate?.gankDataReceived(json: json as AnyObject)
self.delegate?.gankDataReceived(json as AnyObject)
}
}

func fetchGankWithCategory(category:String,page:Int,complete:@escaping (_ success:Bool,_ result:AnyObject?)->Void){
func fetchGankWithCategory(_ category:String,page:Int,complete:@escaping (_ success:Bool,_ result:AnyObject?)->Void){
let url = (baseUrl + "data/\(category)/\(requestNumber)/\(page)").addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)
debugPrint(url ?? "")
Alamofire.request(url!, method: .get).responseJSON{response in
Expand Down
6 changes: 3 additions & 3 deletions Gank.lu/GankViewController.swift
Expand Up @@ -32,7 +32,7 @@ class GankViewController: UIViewController ,GankHttpDelegate{
showProgress()
let date = DateUtil.stringToDate((girl?.publishedAt)!)
let components = DateUtil.componentsFromDate(date)
GankHttp.shareInstance.fetchGankDataAtYear(year: components.year!, month: components.month!, day: components.day!)
GankHttp.shareInstance.fetchGankDataAtYear(components.year!, month: components.month!, day: components.day!)
}
func initTableView(){
topImageHeight = self.view.bounds.width * 0.65
Expand All @@ -54,15 +54,15 @@ class GankViewController: UIViewController ,GankHttpDelegate{
let date = DateUtil.stringToDate((girl?.publishedAt)!)
let components = DateUtil.componentsFromDate(date)
GankHttp.shareInstance.delegate = self
GankHttp.shareInstance.fetchGankDataAtYear(year: components.year!, month: components.month!, day: components.day!)
GankHttp.shareInstance.fetchGankDataAtYear(components.year!, month: components.month!, day: components.day!)
showProgress()
}
func showProgress(){
hud = MBProgressHUD.showAdded(to: self.view, animated: true)
hud!.labelText = "loading..."
hud!.dimBackground = true
}
func gankDataReceived(json: AnyObject) {
func gankDataReceived(_ json: AnyObject) {
debugPrint(json)
hud?.hide(true)
let resultJosn = JSON(json)
Expand Down
6 changes: 3 additions & 3 deletions Gank.lu/ViewController.swift
Expand Up @@ -73,16 +73,16 @@ class ViewController: UIViewController, GirlHttpDelegate {
func pullToRefresh(){
loadingMore = false
page = 1
GankHttp.shareInstance.fetchGirlData(page: page)
GankHttp.shareInstance.fetchGirlData(page)
}

func pullToLoadMore(){
loadingMore = true
tableView.mj_footer.beginRefreshing()
GankHttp.shareInstance.fetchGirlData(page: page)
GankHttp.shareInstance.fetchGirlData(page)
}

func girlDataReceived(json: AnyObject) {
func girlDataReceived(_ json: AnyObject) {
page += 1
let jsonResult = JSON(json)
if loadingMore {
Expand Down
1 change: 0 additions & 1 deletion Gank.luTests/Gank_luTests.swift
Expand Up @@ -7,7 +7,6 @@
//

import XCTest
@testable import Gank_lu

class Gank_luTests: XCTestCase {

Expand Down

0 comments on commit bc4d173

Please sign in to comment.