Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit ddd481b

Browse files
author
Nindi Gill
committed
Added rudimentary photo support
1 parent 701b9f5 commit ddd481b

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

MacUserGenerator/Export/Exporter.swift

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,34 @@ class Exporter: NSObject {
114114
if documentObject.picture.isValid {
115115

116116
if let tiff = documentObject.picture.tiffRepresentation {
117-
let string = tiff.base64EncodedString(options: .lineLength64Characters)
118-
// script = script.replaceFirstOccurrence(of: "#PICTURE#", with: string)
119-
// currently commented out, need to test
120-
script = script.replaceFirstOccurrence(of: "#PICTURE#", with: "")
117+
let string = tiff.base64EncodedString()
118+
119+
var firstString = ""
120+
var secondString = ""
121+
var thirdString = ""
122+
let third = string.count / 3
123+
124+
let index = string.index(string.startIndex, offsetBy: third)
125+
firstString = String(string[..<index])
126+
let startIndex = string.index(string.startIndex, offsetBy: third)
127+
let endIndex = string.index(startIndex, offsetBy: third)
128+
secondString = String(string[startIndex..<endIndex])
129+
thirdString = String(string[endIndex..<string.endIndex])
130+
131+
script = script.replaceFirstOccurrence(of: "#FIRSTCHUNK#", with: firstString)
132+
script = script.replaceFirstOccurrence(of: "#SECONDCHUNK#", with: secondString)
133+
script = script.replaceFirstOccurrence(of: "#THIRDCHUNK#", with: thirdString)
121134
}
122135
else {
123-
script = script.replaceFirstOccurrence(of: "#PICTURE#", with: "")
136+
script = script.replaceFirstOccurrence(of: "#FIRSTCHUNK#", with: "")
137+
script = script.replaceFirstOccurrence(of: "#SECONDCHUNK#", with: "")
138+
script = script.replaceFirstOccurrence(of: "#THIRDCHUNK#", with: "")
124139
}
125140
}
126141
else {
127-
script = script.replaceFirstOccurrence(of: "#PICTURE#", with: "")
142+
script = script.replaceFirstOccurrence(of: "#FIRSTCHUNK#", with: "")
143+
script = script.replaceFirstOccurrence(of: "#SECONDCHUNK#", with: "")
144+
script = script.replaceFirstOccurrence(of: "#THIRDCHUNK#", with: "")
128145
}
129146

130147
try script.write(to: url, atomically: true, encoding: .utf8)

0 commit comments

Comments
 (0)