Kaynağa Gözat

Fixed unicode formatting across the app.

Iñigo Valentin 9 yıl önce
ebeveyn
işleme
07bbeecbb0

+ 3 - 3
app/HomeView.swift

@@ -124,7 +124,7 @@ class HomeView: UIView {
 			//I like to check the size of the returned results!
 			print ("Activities: \(searchResults.count)")
 			
-			var row : RowHomePastActivities
+			var row : RowHomeFutureActivities
 			var count = 0
 			var id: Int
 			var title: String
@@ -139,13 +139,13 @@ class HomeView: UIView {
 				
 				
 				//Create a new row
-				row = RowHomePastActivities.init(s: "rowHomeFutureActivities\(count)", i: count)
+				row = RowHomeFutureActivities.init(s: "rowHomeFutureActivities\(count)", i: count)
 				id = r.value(forKey: "id")! as! Int
 				title = r.value(forKey: "title_\(lang)")! as! String
 				text = r.value(forKey: "text_\(lang)")! as! String
 				print(title)
 				row.setTitle(text: title)
-				row.setText(text: text)
+				row.setText(text: text.decode())
 				
 				// Get main image
 				image = ""

+ 4 - 7
app/LablancaView.swift

@@ -88,7 +88,7 @@ class LablancaView: UIView {
 		self.nfWindow.isHidden = true
 		
 		// TODO: Get current year
-		let year = 2016
+		let year = 2017
 		
 		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
 		let appDelegate = UIApplication.shared.delegate as! AppDelegate
@@ -108,7 +108,7 @@ class LablancaView: UIView {
 				let r = searchResults[0]
 			
 				// Set description
-				self.fText.text = r.value(forKey: "text_\(lang)") as! String?
+				self.fText.text = (r.value(forKey: "text_\(lang)") as! String?)?.decode().stripHtml()
 			}
 
 		}
@@ -198,7 +198,7 @@ class LablancaView: UIView {
 				
 				let date: NSDate = day.value(forKey: "date")! as! NSDate
 				let dateString: String = dateFormatter.string(from: date as Date)
-				let nDay: String = dateString.subStr(start: 8, end: 9)
+				let nDay: Int = Int(dateString.subStr(start: 8, end: 9))!
 				let month: String = dateString.subStr(start: 5, end: 6)
 				var nMonth: String = "Agosto" // TODO: Reference
 				if month == "07"{
@@ -209,10 +209,7 @@ class LablancaView: UIView {
 				
 				// Create the row and set data.
 				row = RowLablancaDay.init(s: "rowLablancaDay\(count)", i: count)
-				row.name.text = name
-				row.price.text = "\(price) €"
-				row.number.text = "\(Int(nDay)!)"
-				row.month.text = nMonth
+				row.setDay(number: nDay, month: nMonth, name: name, price: price)
 				
 				// Add the row
 				fDayList.addArrangedSubview(row)

+ 2 - 2
app/RowBlog.swift

@@ -96,7 +96,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new title.
 	*/
 	func setTitle(text: String){
-		title.text = text.stripHtml()
+		title.text = text.decode().stripHtml()
 	}
 	
 	/**
@@ -104,7 +104,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new text.
 	*/
 	func setText(text: String){
-		descrip.text = text.stripHtml()
+		descrip.text = text.decode()
 	}
 	
 	/**

+ 3 - 3
app/RowFutureActivity.swift

@@ -90,7 +90,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new title.
 	*/
 	func setTitle(text: String){
-		self.title.text = text.stripHtml()
+		self.title.text = text.decode().stripHtml()
 	}
 	
 	/**
@@ -98,7 +98,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The city.
 	*/
 	func setCity(text: String){
-		self.city.text = text
+		self.city.text = text.decode().stripHtml()
 	}
 	
 	/**
@@ -119,7 +119,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new text.
 	*/
 	func setText(text: String){
-		self.descript.text = text.stripHtml()
+		self.descript.text = text.decode().stripHtml()
 	}
 	
 	/**

+ 1 - 1
app/RowGallery.swift

@@ -108,7 +108,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new title.
 	*/
 	func setTitle(text: String){
-		title.text = "  \(text.stripHtml())"
+		title.text = "  \(text.decode().stripHtml())"
 	}
 	
 	/**

+ 2 - 2
app/RowHomeBlog.swift

@@ -90,7 +90,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new title.
 	*/
 	func setTitle(text: String){
-		title.text = text.stripHtml()
+		title.text = text.decode().stripHtml()
 	}
 	
 	/**
@@ -98,7 +98,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new text.
 	*/
 	func setText(text: String){
-		descrip.text = text.stripHtml()
+		descrip.text = text.decode().stripHtml()
 	}
 	
 	/**

+ 2 - 2
app/RowHomeFutureActivities.swift

@@ -88,7 +88,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new title.
 	*/
 	func setTitle(text: String){
-		title.text = text.stripHtml()
+		title.text = text.decode().stripHtml()
 	}
 	
 	/**
@@ -96,7 +96,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new text.
 	*/
 	func setText(text: String){
-		descrip.text = text.stripHtml()
+		descrip.text = text.decode().stripHtml()
 	}
 	
 	/**

+ 2 - 2
app/RowHomePastActivities.swift

@@ -88,7 +88,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new title.
 	*/
 	func setTitle(text: String){
-		title.text = text.stripHtml()
+		title.text = text.decode().stripHtml()
 	}
 	
 	/**
@@ -96,7 +96,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new text.
 	*/
 	func setText(text: String){
-		descrip.text = text.stripHtml()
+		descrip.text = text.decode().stripHtml()
 	}
 	
 	/**

+ 1 - 1
app/RowLabel.swift

@@ -78,6 +78,6 @@ Extension of UIView to be formatted as sections.
 	:param: text The new text.
 	*/
 	func setText(text: String){
-		self.text.text = text.stripHtml()
+		self.text.text = text.decode().stripHtml()
 	}
 }

+ 7 - 3
app/RowLablancaDay.swift

@@ -34,9 +34,6 @@ Extension of UIView to be formatted as sections.
 	@IBOutlet weak var price: UILabel!
 	@IBOutlet weak var separator: UIView!
 	
-	
-	
-	
 	/**
 	Default constructor
 	*/
@@ -86,4 +83,11 @@ Extension of UIView to be formatted as sections.
 		super.init(frame: frame)
 	}
 	
+	func setDay(number: Int, month: String, name: String, price: Int){
+		self.number.text = "\(Int(number))"
+		self.month.text = month.decode().stripHtml()
+		self.name.text = name.decode().stripHtml()
+		self.price.text = "\(price) €"
+	}
+	
 }

+ 2 - 2
app/RowLablancaOffer.swift

@@ -96,7 +96,7 @@ Extension of UIView to be formatted as sections.
 	:param: name The name of the offer.
 	*/
 	func setName(name: String){
-		self.lbName.text = name
+		self.lbName.text = name.decode().stripHtml()
 	}
 	
 	/**
@@ -104,7 +104,7 @@ Extension of UIView to be formatted as sections.
 	:param: description The description of the offer.
 	*/
 	func setDescription(description: String){
-		self.lbDescription.text = description
+		self.lbDescription.text = description.decode().stripHtml()
 	}
 	
 	/**

+ 2 - 2
app/RowPastActivity.swift

@@ -87,7 +87,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new title.
 	*/
 	func setTitle(text: String){
-		title.text = text.stripHtml()
+		title.text = text.decode().stripHtml()
 	}
 	
 	/**
@@ -95,7 +95,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new text.
 	*/
 	func setText(text: String){
-		descript.text = text.stripHtml()
+		descript.text = text.decode().stripHtml()
 	}
 	
 	/**

+ 4 - 4
app/RowSchedule.swift

@@ -126,7 +126,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The title of the event.
 	*/
 	func setTitle(text: String){
-		self.lbTitle.text = text
+		self.lbTitle.text = text.decode().stripHtml()
 	}
 	
 	/**
@@ -134,7 +134,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The location of the event.
 	*/
 	func setLocation(text: String){
-		self.lbLocation.text = text
+		self.lbLocation.text = text.decode().stripHtml()
 	}
 	
 	/**
@@ -142,13 +142,13 @@ Extension of UIView to be formatted as sections.
 	:param: text The new text.
 	*/
 	func setText(text: String){
-		self.lbText.text = text.stripHtml()
+		self.lbText.text = text.decode().stripHtml()
 	}
 	
 	/**
 	Opens an event dialog.
 	*/
 	func openEvent(_ sender:UITapGestureRecognizer? = nil){
-		print("ROW_BLOG:DEBUG: openpost")
+		print("ROW_BLOG:DEBUG: Open Event")
 	}
 }

+ 13 - 0
app/String.swift

@@ -110,4 +110,17 @@ extension String {
 		//return self
 		
 	}
+	
+	/**
+	Removes escaped characters and unicode symbols from the string.
+	:return: Escaped string.
+	*/
+	func decode() -> String {
+		
+		let transform: NSString = "Any-Hex/Java"
+		let convertedString: NSMutableString = (self as NSString).mutableCopy() as! NSMutableString
+		
+		CFStringTransform(convertedString, nil, transform, true)
+		return (convertedString as String).replacingOccurrences(of: "\\/", with: "/")
+	}
 }