Skip to content

Commit

Permalink
Merge pull request #1 from alphatroya/swift3
Browse files Browse the repository at this point in the history
Convert code to swift 3
  • Loading branch information
alphatroya authored Nov 5, 2016
2 parents ed28b6a + 17aa68a commit 3dc4dd8
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 18 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: objective-c
osx_image: xcode7.2
osx_image: xcode8
xcode_workspace: NetworkActivityIndicatorManager.xcworkspace
xcode_scheme: NetworkActivityIndicatorManager
xcode_sdk: iphonesimulator9.2
xcode_sdk: iphonesimulator9.3
script:
- carthage bootstrap --platform iOS
- xctool -workspace NetworkActivityIndicatorManager.xcworkspace -scheme NetworkActivityIndicatorManager -sdk iphonesimulator9.2 -destination 'platform=iOS Simulator,name=iPhone 6s' ONLY_ACTIVE_ARCH=NO clean test
- gem install xcpretty
- carthage bootstrap --platform iOS --use-submodules
- xcodebuild -workspace NetworkActivityIndicatorManager.xcworkspace -scheme NetworkActivityIndicatorManager -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.0' ONLY_ACTIVE_ARCH=NO clean test | xcpretty
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Quick/Nimble" "v3.2.0"
github "Quick/Quick" "v0.9.1"
github "Quick/Nimble" "v5.1.1"
github "Quick/Quick" "v0.10.0"
2 changes: 1 addition & 1 deletion Carthage/Checkouts/Nimble
Submodule Nimble updated 161 files
2 changes: 1 addition & 1 deletion Carthage/Checkouts/Quick
Submodule Quick updated 148 files
6 changes: 6 additions & 0 deletions NetworkActivityIndicatorManager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,11 @@
TargetAttributes = {
D4ACC0AF1C5E2CFE00396328 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0810;
};
D4ACC0B91C5E2CFE00396328 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0810;
};
};
};
Expand Down Expand Up @@ -593,6 +595,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -611,6 +614,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.alphatroya.NetworkActivityIndicatorManager;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -621,6 +625,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.alphatroya.NetworkActivityIndicatorManagerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -631,6 +636,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.alphatroya.NetworkActivityIndicatorManagerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,36 @@ public protocol ApplicationProtocol {
var networkActivityIndicatorVisible: Bool { get set }
}

public class NetworkActivityIndicatorManager {
open class NetworkActivityIndicatorManager {

private static var activitiesCount = 0
fileprivate static var activitiesCount = 0

var application: ApplicationProtocol

public init(withApplication application: ApplicationProtocol) {
self.application = application
}

public func addActivity() {
if self.dynamicType.activitiesCount == 0 {
open func addActivity() {
if type(of: self).activitiesCount == 0 {
application.networkActivityIndicatorVisible = true
}

self.dynamicType.activitiesCount += 1
type(of: self).activitiesCount += 1
}

public func removeActivity() {
if self.dynamicType.activitiesCount > 0 {
self.dynamicType.activitiesCount -= 1
open func removeActivity() {
if type(of: self).activitiesCount > 0 {
type(of: self).activitiesCount -= 1

if self.dynamicType.activitiesCount == 0 {
if type(of: self).activitiesCount == 0 {
application.networkActivityIndicatorVisible = false
}
}
}

func resetActivityCount() {
self.dynamicType.activitiesCount = 0
type(of: self).activitiesCount = 0
application.networkActivityIndicatorVisible = false
}
}

0 comments on commit 3dc4dd8

Please sign in to comment.