Browse Source

Fixing for Swift 3

Simon Fairbairn 9 years ago
parent
commit
b51f13054c

+ 1 - 0
.swift-version

@@ -0,0 +1 @@
+3.0

+ 9 - 7
SwiftyMarkdown.playground/Contents.swift

@@ -9,6 +9,15 @@ XCPlaygroundPage.currentPage.liveView = containerView
 let label = UITextView(frame: containerView.frame)
 let label = UITextView(frame: containerView.frame)
 containerView.addSubview(label)
 containerView.addSubview(label)
 
 
+var foundCharacters : String = ""
+var matchedCharacters : String = "\\Some string ''\\"
+if let hasRange = matchedCharacters.range(of: "\\") {
+	
+	let newRange  = hasRange.lowerBound..<hasRange.upperBound
+	foundCharacters = foundCharacters + matchedCharacters.substring(with: newRange)
+	
+	matchedCharacters.removeSubrange(newRange)
+}
 //
 //
 //public protocol FontProperties {
 //public protocol FontProperties {
 //	var fontName : String { get set }
 //	var fontName : String { get set }
@@ -311,10 +320,3 @@ containerView.addSubview(label)
 //	label.attributedText = md.attributedString()
 //	label.attributedText = md.attributedString()
 //}
 //}
 //
 //
-let matchedCharacters = "mynew\\Strings"
-if let hasRange = matchedCharacters.rangeOfString("\\") {
-	let newRange  = Range(start: hasRange.startIndex, end: hasRange.endIndex.advancedBy(1))
-	let range  = hasRange.startIndex...hasRange.endIndex
-	
-	
-}

+ 13 - 1
SwiftyMarkdown.xcodeproj/project.pbxproj

@@ -154,11 +154,12 @@
 			isa = PBXProject;
 			isa = PBXProject;
 			attributes = {
 			attributes = {
 				LastSwiftUpdateCheck = 0720;
 				LastSwiftUpdateCheck = 0720;
-				LastUpgradeCheck = 0720;
+				LastUpgradeCheck = 0800;
 				ORGANIZATIONNAME = "Voyage Travel Apps";
 				ORGANIZATIONNAME = "Voyage Travel Apps";
 				TargetAttributes = {
 				TargetAttributes = {
 					F4CE98801C8A921300D735C1 = {
 					F4CE98801C8A921300D735C1 = {
 						CreatedOnToolsVersion = 7.2.1;
 						CreatedOnToolsVersion = 7.2.1;
+						LastSwiftMigration = 0800;
 					};
 					};
 					F4CE988A1C8A921300D735C1 = {
 					F4CE988A1C8A921300D735C1 = {
 						CreatedOnToolsVersion = 7.2.1;
 						CreatedOnToolsVersion = 7.2.1;
@@ -243,8 +244,10 @@
 				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
 				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN_ENUM_CONVERSION = YES;
 				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INFINITE_RECURSION = YES;
 				CLANG_WARN_INT_CONVERSION = YES;
 				CLANG_WARN_INT_CONVERSION = YES;
 				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
 				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+				CLANG_WARN_SUSPICIOUS_MOVE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -291,8 +294,10 @@
 				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
 				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN_ENUM_CONVERSION = YES;
 				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INFINITE_RECURSION = YES;
 				CLANG_WARN_INT_CONVERSION = YES;
 				CLANG_WARN_INT_CONVERSION = YES;
 				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
 				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+				CLANG_WARN_SUSPICIOUS_MOVE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -312,6 +317,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 9.2;
 				IPHONEOS_DEPLOYMENT_TARGET = 9.2;
 				MTL_ENABLE_DEBUG_INFO = NO;
 				MTL_ENABLE_DEBUG_INFO = NO;
 				SDKROOT = iphoneos;
 				SDKROOT = iphoneos;
+				SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
 				TARGETED_DEVICE_FAMILY = "1,2";
 				TARGETED_DEVICE_FAMILY = "1,2";
 				VALIDATE_PRODUCT = YES;
 				VALIDATE_PRODUCT = YES;
 				VERSIONING_SYSTEM = "apple-generic";
 				VERSIONING_SYSTEM = "apple-generic";
@@ -323,6 +329,7 @@
 			isa = XCBuildConfiguration;
 			isa = XCBuildConfiguration;
 			buildSettings = {
 			buildSettings = {
 				CLANG_ENABLE_MODULES = YES;
 				CLANG_ENABLE_MODULES = YES;
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
 				DEFINES_MODULE = YES;
 				DEFINES_MODULE = YES;
 				DYLIB_COMPATIBILITY_VERSION = 1;
 				DYLIB_COMPATIBILITY_VERSION = 1;
 				DYLIB_CURRENT_VERSION = 13;
 				DYLIB_CURRENT_VERSION = 13;
@@ -335,6 +342,7 @@
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SKIP_INSTALL = YES;
 				SKIP_INSTALL = YES;
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+				SWIFT_VERSION = 3.0;
 			};
 			};
 			name = Debug;
 			name = Debug;
 		};
 		};
@@ -342,6 +350,7 @@
 			isa = XCBuildConfiguration;
 			isa = XCBuildConfiguration;
 			buildSettings = {
 			buildSettings = {
 				CLANG_ENABLE_MODULES = YES;
 				CLANG_ENABLE_MODULES = YES;
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
 				DEFINES_MODULE = YES;
 				DEFINES_MODULE = YES;
 				DYLIB_COMPATIBILITY_VERSION = 1;
 				DYLIB_COMPATIBILITY_VERSION = 1;
 				DYLIB_CURRENT_VERSION = 13;
 				DYLIB_CURRENT_VERSION = 13;
@@ -353,6 +362,7 @@
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdown;
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdown;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SKIP_INSTALL = YES;
 				SKIP_INSTALL = YES;
+				SWIFT_VERSION = 3.0;
 			};
 			};
 			name = Release;
 			name = Release;
 		};
 		};
@@ -363,6 +373,7 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownTests;
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownTests;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				SWIFT_VERSION = 3.0;
 			};
 			};
 			name = Debug;
 			name = Debug;
 		};
 		};
@@ -373,6 +384,7 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownTests;
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownTests;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				SWIFT_VERSION = 3.0;
 			};
 			};
 			name = Release;
 			name = Release;
 		};
 		};

+ 1 - 1
SwiftyMarkdown/Info.plist

@@ -15,7 +15,7 @@
 	<key>CFBundlePackageType</key>
 	<key>CFBundlePackageType</key>
 	<string>FMWK</string>
 	<string>FMWK</string>
 	<key>CFBundleShortVersionString</key>
 	<key>CFBundleShortVersionString</key>
-	<string>0.2.2</string>
+	<string>0.2.3</string>
 	<key>CFBundleSignature</key>
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<string>????</string>
 	<key>CFBundleVersion</key>
 	<key>CFBundleVersion</key>

+ 113 - 112
SwiftyMarkdown/SwiftyMarkdown.swift

@@ -21,78 +21,78 @@ A struct defining the styles that can be applied to the parsed Markdown. The `fo
 If that is not set, then the system default will be used.
 If that is not set, then the system default will be used.
 */
 */
 public struct BasicStyles : FontProperties {
 public struct BasicStyles : FontProperties {
-	public var fontName : String? = UIFont.preferredFontForTextStyle(UIFontTextStyleBody).fontName
-	public var color = UIColor.blackColor()
+	public var fontName : String? = UIFont.preferredFont(forTextStyle: UIFontTextStyle.body).fontName
+	public var color = UIColor.black
 }
 }
 
 
 enum LineType : Int {
 enum LineType : Int {
-	case H1, H2, H3, H4, H5, H6, Body
+	case h1, h2, h3, h4, h5, h6, body
 }
 }
 
 
 enum LineStyle : Int {
 enum LineStyle : Int {
-	case None
-	case Italic
-	case Bold
-	case Code
-	case Link
+	case none
+	case italic
+	case bold
+	case code
+	case link
 	
 	
-	static func styleFromString(string : String ) -> LineStyle {
+	static func styleFromString(_ string : String ) -> LineStyle {
 		if string == "**" || string == "__" {
 		if string == "**" || string == "__" {
-			return .Bold
+			return .bold
 		} else if string == "*" || string == "_" {
 		} else if string == "*" || string == "_" {
-			return .Italic
+			return .italic
 		} else if string == "`" {
 		} else if string == "`" {
-			return .Code
+			return .code
 		} else if string == "["  {
 		} else if string == "["  {
-			return .Link
+			return .link
 		} else {
 		} else {
-			return .None
+			return .none
 		}
 		}
 	}
 	}
 }
 }
 
 
 /// A class that takes a [Markdown](https://daringfireball.net/projects/markdown/) string or file and returns an NSAttributedString with the applied styles. Supports Dynamic Type.
 /// A class that takes a [Markdown](https://daringfireball.net/projects/markdown/) string or file and returns an NSAttributedString with the applied styles. Supports Dynamic Type.
-public class SwiftyMarkdown {
+open class SwiftyMarkdown {
 	
 	
 	/// The styles to apply to any H1 headers found in the Markdown
 	/// The styles to apply to any H1 headers found in the Markdown
-	public var h1 = BasicStyles()
+	open var h1 = BasicStyles()
 
 
 	/// The styles to apply to any H2 headers found in the Markdown
 	/// The styles to apply to any H2 headers found in the Markdown
-	public var h2 = BasicStyles()
+	open var h2 = BasicStyles()
 	
 	
 	/// The styles to apply to any H3 headers found in the Markdown
 	/// The styles to apply to any H3 headers found in the Markdown
-	public var h3 = BasicStyles()
+	open var h3 = BasicStyles()
 	
 	
 	/// The styles to apply to any H4 headers found in the Markdown
 	/// The styles to apply to any H4 headers found in the Markdown
-	public var h4 = BasicStyles()
+	open var h4 = BasicStyles()
 	
 	
 	/// The styles to apply to any H5 headers found in the Markdown
 	/// The styles to apply to any H5 headers found in the Markdown
-	public var h5 = BasicStyles()
+	open var h5 = BasicStyles()
 	
 	
 	/// The styles to apply to any H6 headers found in the Markdown
 	/// The styles to apply to any H6 headers found in the Markdown
-	public var h6 = BasicStyles()
+	open var h6 = BasicStyles()
 	
 	
 	/// The default body styles. These are the base styles and will be used for e.g. headers if no other styles override them.
 	/// The default body styles. These are the base styles and will be used for e.g. headers if no other styles override them.
-	public var body = BasicStyles()
+	open var body = BasicStyles()
 	
 	
 	/// The styles to apply to any links found in the Markdown
 	/// The styles to apply to any links found in the Markdown
-	public var link = BasicStyles()
+	open var link = BasicStyles()
 
 
 	/// The styles to apply to any bold text found in the Markdown
 	/// The styles to apply to any bold text found in the Markdown
-	public var bold = BasicStyles()
+	open var bold = BasicStyles()
 	
 	
 	/// The styles to apply to any italic text found in the Markdown
 	/// The styles to apply to any italic text found in the Markdown
-	public var italic = BasicStyles()
+	open var italic = BasicStyles()
 	
 	
 	/// The styles to apply to any code blocks or inline code text found in the Markdown
 	/// The styles to apply to any code blocks or inline code text found in the Markdown
-	public var code = BasicStyles()
+	open var code = BasicStyles()
 
 
 	
 	
-	var currentType : LineType = .Body
+	var currentType : LineType = .body
 
 
 	
 	
 	let string : String
 	let string : String
-	let instructionSet = NSCharacterSet(charactersInString: "[\\*_`")
+	let instructionSet = CharacterSet(charactersIn: "[\\*_`")
 	
 	
 	/**
 	/**
 	
 	
@@ -111,10 +111,10 @@ public class SwiftyMarkdown {
 	
 	
 	- returns: An initialized SwiftyMarkdown object, or nil if the string couldn't be read
 	- returns: An initialized SwiftyMarkdown object, or nil if the string couldn't be read
 	*/
 	*/
-	public init?(url : NSURL ) {
+	public init?(url : URL ) {
 		
 		
 		do {
 		do {
-			self.string = try NSString(contentsOfURL: url, encoding: NSUTF8StringEncoding) as String
+			self.string = try NSString(contentsOf: url, encoding: String.Encoding.utf8.rawValue) as String
 			
 			
 		} catch {
 		} catch {
 			self.string = ""
 			self.string = ""
@@ -128,10 +128,10 @@ public class SwiftyMarkdown {
 	
 	
 	- returns: An NSAttributedString with the styles applied
 	- returns: An NSAttributedString with the styles applied
 	*/
 	*/
-	public func attributedString() -> NSAttributedString {
+	open func attributedString() -> NSAttributedString {
 		let attributedString = NSMutableAttributedString(string: "")
 		let attributedString = NSMutableAttributedString(string: "")
 		
 		
-		let lines = self.string.componentsSeparatedByCharactersInSet(NSCharacterSet.newlineCharacterSet())
+		let lines = self.string.components(separatedBy: CharacterSet.newlines)
 		
 		
 		var lineCount = 0
 		var lineCount = 0
 		
 		
@@ -147,15 +147,15 @@ public class SwiftyMarkdown {
 			var line = theLine
 			var line = theLine
 			for heading in headings {
 			for heading in headings {
 				
 				
-				if let range =  line.rangeOfString(heading) where range.startIndex == line.startIndex {
+				if let range =  line.range(of: heading) , range.lowerBound == line.startIndex {
 					
 					
-					let startHeadingString = line.stringByReplacingCharactersInRange(range, withString: "")
+					let startHeadingString = line.replacingCharacters(in: range, with: "")
 
 
 					// Remove ending
 					// Remove ending
-					let endHeadingString = heading.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
-					line = startHeadingString.stringByReplacingOccurrencesOfString(endHeadingString, withString: "").stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
+					let endHeadingString = heading.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
+					line = startHeadingString.replacingOccurrences(of: endHeadingString, with: "").trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
 					
 					
-					currentType = LineType(rawValue: headings.indexOf(heading)!)!
+					currentType = LineType(rawValue: headings.index(of: heading)!)!
 
 
 					// We found a heading so break out of the inner loop
 					// We found a heading so break out of the inner loop
 					break
 					break
@@ -166,16 +166,16 @@ public class SwiftyMarkdown {
 			if lineCount  < lines.count {
 			if lineCount  < lines.count {
 				let nextLine = lines[lineCount]
 				let nextLine = lines[lineCount]
 				
 				
-				if let range = nextLine.rangeOfString("=") where range.startIndex == nextLine.startIndex {
+				if let range = nextLine.range(of: "=") , range.lowerBound == nextLine.startIndex {
 					// Make H1
 					// Make H1
-					currentType = .H1
+					currentType = .h1
 					// We need to skip the next line
 					// We need to skip the next line
 					skipLine = true
 					skipLine = true
 				}
 				}
 				
 				
-				if let range = nextLine.rangeOfString("-") where range.startIndex == nextLine.startIndex {
+				if let range = nextLine.range(of: "-") , range.lowerBound == nextLine.startIndex {
 					// Make H2
 					// Make H2
-					currentType = .H2
+					currentType = .h2
 					// We need to skip the next line
 					// We need to skip the next line
 					skipLine = true
 					skipLine = true
 				}
 				}
@@ -185,55 +185,55 @@ public class SwiftyMarkdown {
 			if line.characters.count > 0 {
 			if line.characters.count > 0 {
 				
 				
 				// ...start scanning
 				// ...start scanning
-				let scanner = NSScanner(string: line)
+				let scanner = Scanner(string: line)
 				
 				
 				// We want to be aware of spaces
 				// We want to be aware of spaces
 				scanner.charactersToBeSkipped = nil
 				scanner.charactersToBeSkipped = nil
 				
 				
-				while !scanner.atEnd {
+				while !scanner.isAtEnd {
 					var string : NSString?
 					var string : NSString?
 
 
 					// Get all the characters up to the ones we are interested in
 					// Get all the characters up to the ones we are interested in
-					if scanner.scanUpToCharactersFromSet(instructionSet, intoString: &string) {
+					if scanner.scanUpToCharacters(from: instructionSet, into: &string) {
 						
 						
 						if let hasString = string as? String {
 						if let hasString = string as? String {
-							let bodyString = attributedStringFromString(hasString, withStyle: .None)
-							attributedString.appendAttributedString(bodyString)
+							let bodyString = attributedStringFromString(hasString, withStyle: .none)
+							attributedString.append(bodyString)
 							
 							
 							let location = scanner.scanLocation
 							let location = scanner.scanLocation
 							
 							
 							let matchedCharacters = tagFromScanner(scanner).foundCharacters
 							let matchedCharacters = tagFromScanner(scanner).foundCharacters
 							// If the next string after the characters is a space, then add it to the final string and continue
 							// If the next string after the characters is a space, then add it to the final string and continue
 							
 							
-							let set = NSMutableCharacterSet.whitespaceCharacterSet()
-							set.formUnionWithCharacterSet(NSCharacterSet.punctuationCharacterSet())
-							if scanner.scanUpToCharactersFromSet(set, intoString: nil) {
+							let set = NSMutableCharacterSet.whitespace()
+							set.formUnion(with: CharacterSet.punctuationCharacters)
+							if scanner.scanUpToCharacters(from: set as CharacterSet, into: nil) {
 								scanner.scanLocation = location
 								scanner.scanLocation = location
-								attributedString.appendAttributedString(self.attributedStringFromScanner(scanner))
+								attributedString.append(self.attributedStringFromScanner(scanner))
 
 
 							} else if matchedCharacters == "[" {
 							} else if matchedCharacters == "[" {
 								scanner.scanLocation = location
 								scanner.scanLocation = location
-								attributedString.appendAttributedString(self.attributedStringFromScanner(scanner))								
+								attributedString.append(self.attributedStringFromScanner(scanner))								
 							} else {
 							} else {
-								let charAtts = attributedStringFromString(matchedCharacters, withStyle: .None)
-								attributedString.appendAttributedString(charAtts)
+								let charAtts = attributedStringFromString(matchedCharacters, withStyle: .none)
+								attributedString.append(charAtts)
 							}
 							}
 						}
 						}
 					} else {
 					} else {
-						attributedString.appendAttributedString(self.attributedStringFromScanner(scanner, atStartOfLine: true))
+						attributedString.append(self.attributedStringFromScanner(scanner, atStartOfLine: true))
 					}
 					}
 				}
 				}
 			}
 			}
 			
 			
 			// Append a new line character to the end of the processed line
 			// Append a new line character to the end of the processed line
-			attributedString.appendAttributedString(NSAttributedString(string: "\n"))
-			currentType = .Body
+			attributedString.append(NSAttributedString(string: "\n"))
+			currentType = .body
 		}
 		}
 		
 		
 		return attributedString
 		return attributedString
 	}
 	}
 	
 	
-	func attributedStringFromScanner( scanner : NSScanner, atStartOfLine start : Bool = false) -> NSAttributedString {
+	func attributedStringFromScanner( _ scanner : Scanner, atStartOfLine start : Bool = false) -> NSAttributedString {
 		var followingString : NSString?
 		var followingString : NSString?
 
 
 		let results = self.tagFromScanner(scanner)
 		let results = self.tagFromScanner(scanner)
@@ -241,73 +241,74 @@ public class SwiftyMarkdown {
 		var style = LineStyle.styleFromString(results.foundCharacters)
 		var style = LineStyle.styleFromString(results.foundCharacters)
 		
 		
 		var attributes = [String : AnyObject]()
 		var attributes = [String : AnyObject]()
-		if style == .Link {
+		if style == .link {
 			
 			
 			var linkText : NSString?
 			var linkText : NSString?
 			var linkURL : NSString?
 			var linkURL : NSString?
-			let linkCharacters = NSCharacterSet(charactersInString: "]()")
+			let linkCharacters = CharacterSet(charactersIn: "]()")
 			
 			
-			scanner.scanUpToCharactersFromSet(linkCharacters, intoString: &linkText)
-			scanner.scanCharactersFromSet(linkCharacters, intoString: nil)
-			scanner.scanUpToCharactersFromSet(linkCharacters, intoString: &linkURL)
-			scanner.scanCharactersFromSet(linkCharacters, intoString: nil)
+			scanner.scanUpToCharacters(from: linkCharacters, into: &linkText)
+			scanner.scanCharacters(from: linkCharacters, into: nil)
+			scanner.scanUpToCharacters(from: linkCharacters, into: &linkURL)
+			scanner.scanCharacters(from: linkCharacters, into: nil)
 			
 			
 			
 			
-			if let hasLink = linkText, hasURL = linkURL {
-				followingString = hasLink as String
-				attributes[NSLinkAttributeName] = hasURL as String
+			if let hasLink = linkText, let hasURL = linkURL {
+				followingString = hasLink
+				attributes[NSLinkAttributeName] = hasURL
 			} else {
 			} else {
-				style = .None
+				style = .none
 			}
 			}
 		} else {
 		} else {
-			scanner.scanUpToCharactersFromSet(instructionSet, intoString: &followingString)		
+			scanner.scanUpToCharacters(from: instructionSet, into: &followingString)		
 		}
 		}
 		
 		
 		let attributedString = attributedStringFromString(results.escapedCharacters, withStyle: style).mutableCopy() as! NSMutableAttributedString
 		let attributedString = attributedStringFromString(results.escapedCharacters, withStyle: style).mutableCopy() as! NSMutableAttributedString
 		if let hasString = followingString as? String {
 		if let hasString = followingString as? String {
 
 
-			let prefix = ( style == .Code && start ) ? "\t" : ""
+			let prefix = ( style == .code && start ) ? "\t" : ""
 			let attString = attributedStringFromString(prefix + hasString, withStyle: style, attributes: attributes)
 			let attString = attributedStringFromString(prefix + hasString, withStyle: style, attributes: attributes)
-			attributedString.appendAttributedString(attString)
+			attributedString.append(attString)
 		}
 		}
 		let suffix = self.tagFromScanner(scanner)
 		let suffix = self.tagFromScanner(scanner)
-		attributedString.appendAttributedString(attributedStringFromString(suffix.escapedCharacters, withStyle: style))
+		attributedString.append(attributedStringFromString(suffix.escapedCharacters, withStyle: style))
 		
 		
 		return attributedString
 		return attributedString
 	}
 	}
 	
 	
-	func tagFromScanner( scanner : NSScanner ) -> (foundCharacters : String, escapedCharacters : String) {
+	func tagFromScanner( _ scanner : Scanner ) -> (foundCharacters : String, escapedCharacters : String) {
 		var matchedCharacters : String = ""
 		var matchedCharacters : String = ""
 		var tempCharacters : NSString?
 		var tempCharacters : NSString?
 		
 		
 		// Scan the ones we are interested in
 		// Scan the ones we are interested in
-		while scanner.scanCharactersFromSet(instructionSet, intoString: &tempCharacters) {
+		while scanner.scanCharacters(from: instructionSet, into: &tempCharacters) {
 			if let chars = tempCharacters as? String {
 			if let chars = tempCharacters as? String {
 				matchedCharacters = matchedCharacters + chars
 				matchedCharacters = matchedCharacters + chars
 			}
 			}
 		}
 		}
 		var foundCharacters : String = ""
 		var foundCharacters : String = ""
 		
 		
-		while matchedCharacters.containsString("\\") {
-			if let hasRange = matchedCharacters.rangeOfString("\\") {
+		while matchedCharacters.contains("\\") {
+			if let hasRange = matchedCharacters.range(of: "\\") {
 				
 				
-				let newRange  = hasRange.startIndex...hasRange.endIndex
-				foundCharacters = foundCharacters + matchedCharacters.substringWithRange(newRange)
-
-				matchedCharacters.removeRange(newRange)
+				// FIXME: Possible error in range
+				let newRange  = hasRange.lowerBound..<matchedCharacters.index(hasRange.upperBound, offsetBy: 1)
+				foundCharacters = foundCharacters + matchedCharacters.substring(with: newRange)
+				
+				matchedCharacters.removeSubrange(newRange)
 			}
 			}
 			
 			
 		}
 		}
 		
 		
 		
 		
-		return (matchedCharacters, foundCharacters.stringByReplacingOccurrencesOfString("\\", withString: ""))
+		return (matchedCharacters, foundCharacters.replacingOccurrences(of: "\\", with: ""))
 	}
 	}
 	
 	
 	
 	
 	// Make H1
 	// Make H1
 	
 	
-	func attributedStringFromString(string : String, withStyle style : LineStyle, attributes : [String : AnyObject] = [:] ) -> NSAttributedString {
-		let textStyle : String
+	func attributedStringFromString(_ string : String, withStyle style : LineStyle, attributes : [String : AnyObject] = [:] ) -> NSAttributedString {
+		let textStyle : UIFontTextStyle
 		var fontName : String?
 		var fontName : String?
         var attributes = attributes
         var attributes = attributes
 
 
@@ -315,57 +316,57 @@ public class SwiftyMarkdown {
 		
 		
 		
 		
 		switch currentType {
 		switch currentType {
-		case .H1:
+		case .h1:
 			fontName = h1.fontName
 			fontName = h1.fontName
 			if #available(iOS 9, *) {
 			if #available(iOS 9, *) {
-				textStyle = UIFontTextStyleTitle1
+				textStyle = UIFontTextStyle.title1
 			} else {
 			} else {
-				textStyle = UIFontTextStyleHeadline
+				textStyle = UIFontTextStyle.headline
 			}
 			}
 			attributes[NSForegroundColorAttributeName] = h1.color
 			attributes[NSForegroundColorAttributeName] = h1.color
-		case .H2:
+		case .h2:
 			fontName = h2.fontName
 			fontName = h2.fontName
 			if #available(iOS 9, *) {
 			if #available(iOS 9, *) {
-				textStyle = UIFontTextStyleTitle2
+				textStyle = UIFontTextStyle.title2
 			} else {
 			} else {
-				textStyle = UIFontTextStyleHeadline
+				textStyle = UIFontTextStyle.headline
 			}
 			}
 			attributes[NSForegroundColorAttributeName] = h2.color
 			attributes[NSForegroundColorAttributeName] = h2.color
-		case .H3:
+		case .h3:
 			fontName = h3.fontName
 			fontName = h3.fontName
 			if #available(iOS 9, *) {
 			if #available(iOS 9, *) {
-				textStyle = UIFontTextStyleTitle2
+				textStyle = UIFontTextStyle.title2
 			} else {
 			} else {
-				textStyle = UIFontTextStyleSubheadline
+				textStyle = UIFontTextStyle.subheadline
 			}
 			}
 			attributes[NSForegroundColorAttributeName] = h3.color
 			attributes[NSForegroundColorAttributeName] = h3.color
-		case .H4:
+		case .h4:
 			fontName = h4.fontName
 			fontName = h4.fontName
-			textStyle = UIFontTextStyleHeadline
+			textStyle = UIFontTextStyle.headline
 			attributes[NSForegroundColorAttributeName] = h4.color
 			attributes[NSForegroundColorAttributeName] = h4.color
-		case .H5:
+		case .h5:
 			fontName = h5.fontName
 			fontName = h5.fontName
-			textStyle = UIFontTextStyleSubheadline
+			textStyle = UIFontTextStyle.subheadline
 			attributes[NSForegroundColorAttributeName] = h5.color
 			attributes[NSForegroundColorAttributeName] = h5.color
-		case .H6:
+		case .h6:
 			fontName = h6.fontName
 			fontName = h6.fontName
-			textStyle = UIFontTextStyleFootnote
+			textStyle = UIFontTextStyle.footnote
 			attributes[NSForegroundColorAttributeName] = h6.color
 			attributes[NSForegroundColorAttributeName] = h6.color
 		default:
 		default:
 			fontName = body.fontName
 			fontName = body.fontName
-			textStyle = UIFontTextStyleBody
+			textStyle = UIFontTextStyle.body
 			attributes[NSForegroundColorAttributeName] = body.color
 			attributes[NSForegroundColorAttributeName] = body.color
 			break
 			break
 		}
 		}
 		
 		
 		// Check for code
 		// Check for code
 		
 		
-		if style == .Code {
+		if style == .code {
 			fontName = code.fontName
 			fontName = code.fontName
 			attributes[NSForegroundColorAttributeName] = code.color
 			attributes[NSForegroundColorAttributeName] = code.color
 		}
 		}
 		
 		
-		if style == .Link {
+		if style == .link {
 			fontName = link.fontName
 			fontName = link.fontName
 			attributes[NSForegroundColorAttributeName] = link.color
 			attributes[NSForegroundColorAttributeName] = link.color
 		}
 		}
@@ -377,25 +378,25 @@ public class SwiftyMarkdown {
 			fontName = body.fontName
 			fontName = body.fontName
 		}
 		}
 		
 		
-		let font = UIFont.preferredFontForTextStyle(textStyle)
-		let styleDescriptor = font.fontDescriptor()
-		let styleSize = styleDescriptor.fontAttributes()[UIFontDescriptorSizeAttribute] as? CGFloat ?? CGFloat(14)
+		let font = UIFont.preferredFont(forTextStyle: textStyle)
+		let styleDescriptor = font.fontDescriptor
+		let styleSize = styleDescriptor.fontAttributes[UIFontDescriptorSizeAttribute] as? CGFloat ?? CGFloat(14)
 		
 		
 		var finalFont : UIFont
 		var finalFont : UIFont
-		if let finalFontName = fontName, font = UIFont(name: finalFontName, size: styleSize) {
+		if let finalFontName = fontName, let font = UIFont(name: finalFontName, size: styleSize) {
 			finalFont = font
 			finalFont = font
 		} else {
 		} else {
-			finalFont = UIFont.preferredFontForTextStyle(textStyle)
+			finalFont = UIFont.preferredFont(forTextStyle:  textStyle)
 		}
 		}
 		
 		
-		let finalFontDescriptor = finalFont.fontDescriptor()
-		if style == .Italic {
-			let italicDescriptor = finalFontDescriptor.fontDescriptorWithSymbolicTraits(.TraitItalic)
-			finalFont = UIFont(descriptor: italicDescriptor, size: styleSize)
+		let finalFontDescriptor = finalFont.fontDescriptor
+		if style == .italic {
+			let italicDescriptor = finalFontDescriptor.withSymbolicTraits(.traitItalic)
+			finalFont = UIFont(descriptor: italicDescriptor!, size: styleSize)
 		}
 		}
-		if style == .Bold {
-			let boldDescriptor = finalFontDescriptor.fontDescriptorWithSymbolicTraits(.TraitBold)
-			finalFont = UIFont(descriptor: boldDescriptor, size: styleSize)
+		if style == .bold {
+			let boldDescriptor = finalFontDescriptor.withSymbolicTraits(.traitBold)
+			finalFont = UIFont(descriptor: boldDescriptor!, size: styleSize)
 		}
 		}
 		
 		
 		
 		

+ 15 - 1
SwiftyMarkdownExample/SwiftyMarkdownExample.xcodeproj/project.pbxproj

@@ -233,18 +233,21 @@
 			isa = PBXProject;
 			isa = PBXProject;
 			attributes = {
 			attributes = {
 				LastSwiftUpdateCheck = 0720;
 				LastSwiftUpdateCheck = 0720;
-				LastUpgradeCheck = 0720;
+				LastUpgradeCheck = 0800;
 				ORGANIZATIONNAME = "Voyage Travel Apps";
 				ORGANIZATIONNAME = "Voyage Travel Apps";
 				TargetAttributes = {
 				TargetAttributes = {
 					F4CE98A71C8AEF7D00D735C1 = {
 					F4CE98A71C8AEF7D00D735C1 = {
 						CreatedOnToolsVersion = 7.2.1;
 						CreatedOnToolsVersion = 7.2.1;
+						LastSwiftMigration = 0800;
 					};
 					};
 					F4CE98BB1C8AEF7D00D735C1 = {
 					F4CE98BB1C8AEF7D00D735C1 = {
 						CreatedOnToolsVersion = 7.2.1;
 						CreatedOnToolsVersion = 7.2.1;
+						LastSwiftMigration = 0800;
 						TestTargetID = F4CE98A71C8AEF7D00D735C1;
 						TestTargetID = F4CE98A71C8AEF7D00D735C1;
 					};
 					};
 					F4CE98C61C8AEF7D00D735C1 = {
 					F4CE98C61C8AEF7D00D735C1 = {
 						CreatedOnToolsVersion = 7.2.1;
 						CreatedOnToolsVersion = 7.2.1;
+						LastSwiftMigration = 0800;
 						TestTargetID = F4CE98A71C8AEF7D00D735C1;
 						TestTargetID = F4CE98A71C8AEF7D00D735C1;
 					};
 					};
 				};
 				};
@@ -394,8 +397,10 @@
 				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
 				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN_ENUM_CONVERSION = YES;
 				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INFINITE_RECURSION = YES;
 				CLANG_WARN_INT_CONVERSION = YES;
 				CLANG_WARN_INT_CONVERSION = YES;
 				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
 				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+				CLANG_WARN_SUSPICIOUS_MOVE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -439,8 +444,10 @@
 				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
 				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN_ENUM_CONVERSION = YES;
 				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INFINITE_RECURSION = YES;
 				CLANG_WARN_INT_CONVERSION = YES;
 				CLANG_WARN_INT_CONVERSION = YES;
 				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
 				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+				CLANG_WARN_SUSPICIOUS_MOVE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -459,6 +466,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 9.2;
 				IPHONEOS_DEPLOYMENT_TARGET = 9.2;
 				MTL_ENABLE_DEBUG_INFO = NO;
 				MTL_ENABLE_DEBUG_INFO = NO;
 				SDKROOT = iphoneos;
 				SDKROOT = iphoneos;
+				SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
 				TARGETED_DEVICE_FAMILY = "1,2";
 				TARGETED_DEVICE_FAMILY = "1,2";
 				VALIDATE_PRODUCT = YES;
 				VALIDATE_PRODUCT = YES;
 			};
 			};
@@ -472,6 +480,7 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownExample;
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownExample;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				SWIFT_VERSION = 3.0;
 			};
 			};
 			name = Debug;
 			name = Debug;
 		};
 		};
@@ -483,6 +492,7 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownExample;
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownExample;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				SWIFT_VERSION = 3.0;
 			};
 			};
 			name = Release;
 			name = Release;
 		};
 		};
@@ -494,6 +504,7 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownExampleTests;
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownExampleTests;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				SWIFT_VERSION = 3.0;
 				TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftyMarkdownExample.app/SwiftyMarkdownExample";
 				TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftyMarkdownExample.app/SwiftyMarkdownExample";
 			};
 			};
 			name = Debug;
 			name = Debug;
@@ -506,6 +517,7 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownExampleTests;
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownExampleTests;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				SWIFT_VERSION = 3.0;
 				TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftyMarkdownExample.app/SwiftyMarkdownExample";
 				TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftyMarkdownExample.app/SwiftyMarkdownExample";
 			};
 			};
 			name = Release;
 			name = Release;
@@ -517,6 +529,7 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownExampleUITests;
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownExampleUITests;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				SWIFT_VERSION = 3.0;
 				TEST_TARGET_NAME = SwiftyMarkdownExample;
 				TEST_TARGET_NAME = SwiftyMarkdownExample;
 				USES_XCTRUNNER = YES;
 				USES_XCTRUNNER = YES;
 			};
 			};
@@ -529,6 +542,7 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownExampleUITests;
 				PRODUCT_BUNDLE_IDENTIFIER = com.voyagetravelapps.SwiftyMarkdownExampleUITests;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				SWIFT_VERSION = 3.0;
 				TEST_TARGET_NAME = SwiftyMarkdownExample;
 				TEST_TARGET_NAME = SwiftyMarkdownExample;
 				USES_XCTRUNNER = YES;
 				USES_XCTRUNNER = YES;
 			};
 			};

+ 6 - 6
SwiftyMarkdownExample/SwiftyMarkdownExample/AppDelegate.swift

@@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 	var window: UIWindow?
 	var window: UIWindow?
 
 
 
 
-	func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
+	private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: Any]?) -> Bool {
 		// Override point for customization after application launch.
 		// Override point for customization after application launch.
 		return true
 		return true
 	}
 	}
 
 
-	func applicationWillResignActive(application: UIApplication) {
+	func applicationWillResignActive(_ application: UIApplication) {
 		// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
 		// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
 		// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
 		// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
 	}
 	}
 
 
-	func applicationDidEnterBackground(application: UIApplication) {
+	func applicationDidEnterBackground(_ application: UIApplication) {
 		// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
 		// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
 		// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
 		// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
 	}
 	}
 
 
-	func applicationWillEnterForeground(application: UIApplication) {
+	func applicationWillEnterForeground(_ application: UIApplication) {
 		// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
 		// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
 	}
 	}
 
 
-	func applicationDidBecomeActive(application: UIApplication) {
+	func applicationDidBecomeActive(_ application: UIApplication) {
 		// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
 		// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
 	}
 	}
 
 
-	func applicationWillTerminate(application: UIApplication) {
+	func applicationWillTerminate(_ application: UIApplication) {
 		// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
 		// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
 	}
 	}
 
 

+ 3 - 5
SwiftyMarkdownExample/SwiftyMarkdownExample/ViewController.swift

@@ -17,10 +17,10 @@ class ViewController: UIViewController {
 		super.viewDidLoad()
 		super.viewDidLoad()
 		// Do any additional setup after loading the view, typically from a nib.
 		// Do any additional setup after loading the view, typically from a nib.
 		
 		
-		self.textView.dataDetectorTypes = UIDataDetectorTypes.All
-		if let url = NSBundle.mainBundle().URLForResource("example", withExtension: "md"), md = SwiftyMarkdown(url: url) {
+		self.textView.dataDetectorTypes = UIDataDetectorTypes.all
+		if let url = Bundle.main.url(forResource: "example", withExtension: "md"), let md = SwiftyMarkdown(url: url) {
 			md.h2.fontName = "AvenirNextCondensed-Bold"
 			md.h2.fontName = "AvenirNextCondensed-Bold"
-			md.h2.color = UIColor.redColor()
+			md.h2.color = UIColor.red
 			md.code.fontName = "CourierNewPSMT"
 			md.code.fontName = "CourierNewPSMT"
 			
 			
 			self.textView.attributedText = md.attributedString()
 			self.textView.attributedText = md.attributedString()
@@ -35,7 +35,5 @@ class ViewController: UIViewController {
 		super.didReceiveMemoryWarning()
 		super.didReceiveMemoryWarning()
 		// Dispose of any resources that can be recreated.
 		// Dispose of any resources that can be recreated.
 	}
 	}
-
-
 }
 }
 
 

+ 1 - 1
SwiftyMarkdownExample/SwiftyMarkdownExampleTests/SwiftyMarkdownExampleTests.swift

@@ -28,7 +28,7 @@ class SwiftyMarkdownExampleTests: XCTestCase {
     
     
     func testPerformanceExample() {
     func testPerformanceExample() {
         // This is an example of a performance test case.
         // This is an example of a performance test case.
-        self.measureBlock {
+        self.measure {
             // Put the code you want to measure the time of here.
             // Put the code you want to measure the time of here.
         }
         }
     }
     }

+ 1 - 1
SwiftyMarkdownTests/Info.plist

@@ -15,7 +15,7 @@
 	<key>CFBundlePackageType</key>
 	<key>CFBundlePackageType</key>
 	<string>BNDL</string>
 	<string>BNDL</string>
 	<key>CFBundleShortVersionString</key>
 	<key>CFBundleShortVersionString</key>
-	<string>0.2.2</string>
+	<string>0.2.3</string>
 	<key>CFBundleSignature</key>
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<string>????</string>
 	<key>CFBundleVersion</key>
 	<key>CFBundleVersion</key>