Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private init #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Pluralize.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 93198AF81A4FE442009D2787;
Expand Down Expand Up @@ -357,7 +358,7 @@
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -378,7 +379,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
8 changes: 8 additions & 0 deletions Pluralize.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
8 changes: 4 additions & 4 deletions Pluralize/Pluralize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class Pluralize {
var uncountables:[String] = []
var rules:[(rule: String, template: String)] = []

public init() {
private init() {
uncountables = [
"access", "accommodation", "adulthood", "advertising", "advice",
"aggression", "aid", "air", "alcohol", "anger", "applause",
Expand Down Expand Up @@ -134,7 +134,7 @@ public class Pluralize {
}

public class func apply(word: String) -> String {
guard !(sharedInstance.uncountables.contains(word.lowercased()) || word.characters.count == 0) else {
guard !(sharedInstance.uncountables.contains(word.lowercased()) || word.count == 0) else {
return word
}

Expand Down Expand Up @@ -166,7 +166,7 @@ public class Pluralize {

private class func regexReplace(input: String, pattern: String, template: String) -> String {
let regex = try! NSRegularExpression(pattern: pattern, options: .caseInsensitive)
let range = NSRange(location: 0, length: input.characters.count)
let range = NSRange(location: 0, length: input.count)
let output = regex.stringByReplacingMatches(in: input, options: [], range: range, withTemplate: template)
return output
}
Expand All @@ -193,6 +193,6 @@ extension String {

// Workaround to allow us to use `count` as an argument name in pluralize() above.
private var length: Int {
return self.characters.count
return self.count
}
}