Skip to content

Commit 05d2adc

Browse files
committed
get rid of encoding where no longer required
1 parent 84fe097 commit 05d2adc

File tree

31 files changed

+39
-39
lines changed

31 files changed

+39
-39
lines changed

bk1ch05p240error/bk1ch05p241error/ViewController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ViewController: UIViewController {
5151

5252
do {
5353
let f = "nonexistent" // path to some file, maybe
54-
let s = try String(contentsOfFile: f, encoding: .utf8)
54+
let s = try String(contentsOfFile: f)
5555
print(s) // we won't get here
5656
} catch {
5757
print((error as NSError).localizedDescription)
@@ -61,7 +61,7 @@ class ViewController: UIViewController {
6161

6262
do {
6363
let f = "nonexistent" // path to some file, maybe
64-
let s = try String(contentsOfFile: f, encoding: .utf8)
64+
let s = try String(contentsOfFile: f)
6565
print(s) // we won't get here
6666
} catch NSCocoaError.fileReadNoSuchFileError {
6767
print("no such file")
@@ -73,7 +73,7 @@ class ViewController: UIViewController {
7373

7474
do {
7575
let f = "nonexistent" // path to some file, maybe
76-
if let s = try? String(contentsOfFile: f, encoding: .utf8) {
76+
if let s = try? String(contentsOfFile: f) {
7777
print(s) // won't happen
7878
} else {
7979
print("I guess there was no such file, eh?")
@@ -83,7 +83,7 @@ class ViewController: UIViewController {
8383
lab: do {
8484
// okay, I'm sick of failing, let's succeed for once :)
8585
let f = Bundle.main.pathForResource("testing", ofType: "txt")!
86-
guard let s = try? String(contentsOfFile: f, encoding: .utf8)
86+
guard let s = try? String(contentsOfFile: f)
8787
else {print("still no file"); break lab}
8888
print(s)
8989
// if we get here, s is our string

bk2ch06p336memoryWarning/ch19p647memoryWarning/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ViewController : UIViewController {
7979
// tap button to prove we've got big data
8080

8181
@IBAction func doButton (_ sender:AnyObject?) {
82-
let s = String(data: self.myBigData, encoding: .utf8)
82+
let s = String(data: self.myBigData, encoding:.utf8)
8383
let av = UIAlertController(title: "Got big data, and it says:", message: s, preferredStyle: .alert)
8484
av.addAction(UIAlertAction(title: "OK", style: .cancel))
8585
self.present(av, animated: true)

bk2ch08p416sections/ch21p718sections/RootViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class RootViewController : UITableViewController {
1111
}
1212

1313
override func viewDidLoad() {
14-
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!, encoding: .utf8)
14+
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!)
1515
let states = s.components(separatedBy:"\n")
1616
var previous = ""
1717
for aState in states {

bk2ch08p424variableHeights/ch21p722variableHeights/RootViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class RootViewController : UITableViewController {
1717
super.viewDidLoad()
1818

1919
let url = Bundle.main.urlForResource("trivia", withExtension: "txt")
20-
let s = try! String(contentsOf:url!, encoding: .utf8)
20+
let s = try! String(contentsOf:url!)
2121
var arr = s.components(separatedBy:"\n")
2222
arr.removeLast()
2323
self.trivia = arr

bk2ch08p438searchableTable/ch21p718sections/RootViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class RootViewController : UITableViewController, UISearchBarDelegate {
2121
}
2222

2323
override func viewDidLoad() {
24-
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!, encoding: .utf8)
24+
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!)
2525
let states = s.components(separatedBy:"\n")
2626
var previous = ""
2727
for aState in states {

bk2ch08p438searchableTable2/ch21p718sections/RootViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RootViewController : UITableViewController, UISearchBarDelegate {
1818
}
1919

2020
override func viewDidLoad() {
21-
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!, encoding: .utf8)
21+
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!)
2222
let states = s.components(separatedBy:"\n")
2323
var previous = ""
2424
for aState in states {

bk2ch08p438searchableTable3/ch21p718sections/RootViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class RootViewController : UITableViewController, UISearchBarDelegate {
2121
}
2222

2323
override func viewDidLoad() {
24-
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!, encoding: .utf8)
24+
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!)
2525
let states = s.components(separatedBy:"\n")
2626
var previous = ""
2727
for aState in states {

bk2ch08p438searchableTable4/ch21p718sections/RootViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RootViewController : UITableViewController, UISearchBarDelegate {
1818
}
1919

2020
override func viewDidLoad() {
21-
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!, encoding: .utf8)
21+
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!)
2222
let states = s.components(separatedBy:"\n")
2323
var previous = ""
2424
for aState in states {

bk2ch08p445deleteTableRows/ch21p718sections/RootViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class RootViewController : UITableViewController {
1111
}
1212

1313
override func viewDidLoad() {
14-
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!, encoding: .utf8)
14+
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!)
1515
let states = s.components(separatedBy:"\n")
1616
var previous = ""
1717
for aState in states {

bk2ch08p446rowActions/ch21p718sections/RootViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class RootViewController : UITableViewController {
1111
}
1212

1313
override func viewDidLoad() {
14-
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!, encoding: .utf8)
14+
let s = try! String(contentsOfFile: Bundle.main.pathForResource("states", ofType: "txt")!)
1515
let states = s.components(separatedBy:"\n")
1616
var previous = ""
1717
for aState in states {

0 commit comments

Comments
 (0)