Skip to content

Commit

Permalink
Merge pull request #259 from MortenGregersen/master
Browse files Browse the repository at this point in the history
Fixed deprecation warnings
  • Loading branch information
evermeer authored Jan 3, 2018
2 parents d0a6687 + beadbe4 commit 09e6acd
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions Source/EVReflection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -588,12 +588,12 @@ final public class EVReflection {
// If it was not set, then use the bundleIdentifier (which is the same as kCFBundleIdentifierKey)
if appName == "" {
appName = bundle.bundleIdentifier ?? ""
appName = appName.characters.split(whereSeparator: {$0 == "."}).map({ String($0) }).last ?? ""
appName = appName.split(whereSeparator: {$0 == "."}).map({ String($0) }).last ?? ""
}

// First character may not be a number
if appName.prefix(1) >= "0" && appName.prefix(1) <= "9" {
appName = "_" + String(appName.characters.dropFirst())
appName = "_" + String(appName.dropFirst())
}

// Clean up special characters
Expand Down Expand Up @@ -717,8 +717,8 @@ final public class EVReflection {
valueType = String(reflecting:type(of: theValue))
} else if mi.children.count == 0 {
valueType = String(reflecting:type(of: theValue))
var subtype: String = valueType.substring(from: (valueType.components(separatedBy: "<") [0] + "<").endIndex)
subtype = subtype.substring(to: subtype.characters.index(before: subtype.endIndex))
var subtype: String = String(valueType[(valueType.components(separatedBy: "<") [0] + "<").endIndex...])
subtype = String(subtype[..<subtype.index(before: subtype.endIndex)])
valueType = convertToInternalSwiftRepresentation(type: subtype)
return (NSNull(), valueType, false)
}
Expand All @@ -734,8 +734,8 @@ final public class EVReflection {
valueType = enumType
theValue = enumValue
} else if valueType.hasPrefix("Swift.ImplicitlyUnwrappedOptional<") { // Implicitly Unwrapped Optionals are actually fancy enums
var subtype: String = valueType.substring(from: (valueType.components(separatedBy: "<") [0] + "<").endIndex)
subtype = subtype.substring(to: subtype.characters.index(before: subtype.endIndex))
var subtype: String = String(valueType[(valueType.components(separatedBy: "<") [0] + "<").endIndex...])
subtype = String(subtype[..<subtype.index(before: subtype.endIndex)])
valueType = convertToInternalSwiftRepresentation(type: subtype)

if mi.children.count == 0 {
Expand Down Expand Up @@ -800,8 +800,8 @@ final public class EVReflection {
if type.components(separatedBy: "<").count > 1 {
// Remove the Array or Set prefix
let prefix = type.components(separatedBy: "<") [0] + "<"
var subtype = type.substring(from: prefix.endIndex)
subtype = subtype.substring(to: subtype.characters.index(before: subtype.endIndex))
var subtype = String(type[prefix.endIndex...])
subtype = String(subtype[..<subtype.index(before: subtype.endIndex)])
return prefix + convertToInternalSwiftRepresentation(type: subtype) + ">"
}

Expand All @@ -811,10 +811,10 @@ final public class EVReflection {
return parts[1]
}
let c = String(repeating:"C", count: parts.count - 1)
var rv = "_Tt\(c)\(parts[0].characters.count)\(parts[0])"
var rv = "_Tt\(c)\(parts[0].count)\(parts[0])"
parts.remove(at: 0)
for part in parts {
rv = "\(rv)\(part.characters.count)\(part)"
rv = "\(rv)\(part.count)\(part)"
}
return rv
}
Expand Down Expand Up @@ -1046,9 +1046,9 @@ final public class EVReflection {
}

// Step 1 - clean up keywords
if newKey.characters.first == "_" {
if keywords.contains(newKey.substring(from: newKey.characters.index(newKey.startIndex, offsetBy: 1))) {
newKey = newKey.substring(from: newKey.characters.index(newKey.startIndex, offsetBy: 1))
if newKey.first == "_" {
if keywords.contains(String(newKey[newKey.index(newKey.startIndex, offsetBy: 1)...])) {
newKey = String(newKey[newKey.index(newKey.startIndex, offsetBy: 1)...])
if tryMatch?[newKey] != nil {
return newKey
}
Expand Down Expand Up @@ -1129,17 +1129,17 @@ final public class EVReflection {
- returns: the underscore string
*/
internal static func camelCaseToUnderscores(_ input: String) -> String {
if input.characters.count == 0 {
if input.count == 0 {
return input
}

var p: NSString = ""
if let cachedVersion = camelCaseToUnderscoresCache.object(forKey: input as NSString) {
p = cachedVersion
} else {
var output: String = String(input.characters.first!).lowercased()
var output: String = String(input.first!).lowercased()
let uppercase: CharacterSet = CharacterSet.uppercaseLetters
for character in input.substring(from: input.characters.index(input.startIndex, offsetBy: 1)).characters {
for character in input[input.index(input.startIndex, offsetBy: 1)...] {
if uppercase.contains(UnicodeScalar(String(character).utf16.first!)!) {
output += "_\(String(character).lowercased())"
} else {
Expand All @@ -1162,8 +1162,8 @@ final public class EVReflection {
- returns: the pascalCase string
*/
internal static func PascalCaseToCamelCase(_ input: String) -> String {
if input.characters.count > 1 {
return String(describing: input.characters.first!).lowercased() + input.substring(from: input.characters.index(after: input.startIndex))
if input.count > 1 {
return String(describing: input.first!).lowercased() + input[input.index(after: input.startIndex)...]
}
return input.lowercased()
}
Expand All @@ -1177,8 +1177,8 @@ final public class EVReflection {
- returns: the pascalCase string
*/
internal static func CamelCaseToPascalCase(_ input: String) -> String {
if input.characters.count > 1 {
return String(describing: input.characters.first!).uppercased() + input.substring(from: input.characters.index(after: input.startIndex))
if input.count > 1 {
return String(describing: input.first!).uppercased() + input[input.index(after: input.startIndex)...]
}
return input.uppercased()
}
Expand Down Expand Up @@ -1302,8 +1302,8 @@ final public class EVReflection {

var useType = type
if type.hasPrefix("Swift.Optional<") {
var subtype: String = type.substring(from: (type.components(separatedBy: "<") [0] + "<").endIndex)
subtype = subtype.substring(to: subtype.characters.index(before: subtype.endIndex))
var subtype: String = String(type[(type.components(separatedBy: "<") [0] + "<").endIndex...])
subtype = String(subtype[..<subtype.index(before: subtype.endIndex)])
useType = subtype
}

Expand Down Expand Up @@ -1342,13 +1342,13 @@ final public class EVReflection {
var subtype = ""
if type.components(separatedBy: "<").count > 1 {
// Remove the Array prefix
subtype = type.substring(from: (type.components(separatedBy: "<") [0] + "<").endIndex)
subtype = subtype.substring(to: subtype.characters.index(before: subtype.endIndex))
subtype = String(type[(type.components(separatedBy: "<") [0] + "<").endIndex...])
subtype = String(subtype[..<subtype.index(before: subtype.endIndex)])

// Remove the optional prefix from the subtype
if subtype.hasPrefix("Optional<") {
subtype = subtype.substring(from: (subtype.components(separatedBy: "<") [0] + "<").endIndex)
subtype = subtype.substring(to: subtype.characters.index(before: subtype.endIndex))
subtype = String(subtype[(subtype.components(separatedBy: "<") [0] + "<").endIndex...])
subtype = String(subtype[..<subtype.index(before: subtype.endIndex)])
}
}

Expand Down

0 comments on commit 09e6acd

Please sign in to comment.