When I run the code below the attributedText is displayed in the console but does not show up in the UITextView. I save the attributedText in a global variable scrollViewText
. Ive tried printing scrollViewText
but it still shows up as a blank space in the console.
public static func getHonorsAdvisorsText(){
Alamofire.request("https://honors.purdue.edu/json/honors-advisors.json").responseJSON { response in
//check if result has value
if let value = response.result.value {
let json = JSON(value)
let freshmenName = json["first_year_advisors"][0]["name"].string
let freshmenAssignment = json["first_year_advisors"][0]["assignment"].string
let freshmenEmail = json["first_year_advisors"][0]["email"].string
let formattedString = NSMutableAttributedString()
formattedString
.bold("Freshmen Advisor", fontSize: 40)
.bold("\n" + "Name: " , fontSize: 20)
.normal(freshmenName!, fontSize: 20)
.bold("\n" + "Assignment: " , fontSize: 20)
.normal(freshmenAssignment!, fontSize: 20)
.bold("\n" + "Email: " , fontSize: 20)
.normal(freshmenEmail!, fontSize: 20)
scrollViewText = formattedString
print(formattedString)
}
}
}
I call the getHonorsAdvisorsText
function in the ThirdViewController by using the code:
case 1:
AcademicsPage.getHonorsAdvisorsText()
textViewer.attributedText = scrollViewText