Bladeren bron

Code fixes, simplifications and documentation.

Iñigo Valentin 9 jaren geleden
bovenliggende
commit
8cbc187abe

+ 3 - 1
app.xcodeproj/project.pbxproj

@@ -337,7 +337,7 @@
 			isa = PBXProject;
 			isa = PBXProject;
 			attributes = {
 			attributes = {
 				LastSwiftUpdateCheck = 0800;
 				LastSwiftUpdateCheck = 0800;
-				LastUpgradeCheck = 0800;
+				LastUpgradeCheck = 0830;
 				ORGANIZATIONNAME = Margolariak;
 				ORGANIZATIONNAME = Margolariak;
 				TargetAttributes = {
 				TargetAttributes = {
 					93B84B951D9C31AB006C0F67 = {
 					93B84B951D9C31AB006C0F67 = {
@@ -485,6 +485,7 @@
 				CLANG_WARN_INFINITE_RECURSION = 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_SUSPICIOUS_MOVES = YES;
 				CLANG_WARN_SUSPICIOUS_MOVES = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -535,6 +536,7 @@
 				CLANG_WARN_INFINITE_RECURSION = 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_SUSPICIOUS_MOVES = YES;
 				CLANG_WARN_SUSPICIOUS_MOVES = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;

+ 1 - 1
app.xcodeproj/xcuserdata/seavenois.xcuserdatad/xcschemes/app.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
 <Scheme
-   LastUpgradeVersion = "0800"
+   LastUpgradeVersion = "0830"
    version = "1.3">
    version = "1.3">
    <BuildAction
    <BuildAction
       parallelizeBuildables = "YES"
       parallelizeBuildables = "YES"

+ 15 - 15
app/ActivitiesView.swift

@@ -42,6 +42,7 @@ class ActivitiesView: UIView {
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Run when the view is started.
 	Run when the view is started.
 	*/
 	*/
@@ -49,8 +50,6 @@ class ActivitiesView: UIView {
 		
 		
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 		
 		
-		NSLog(":ACTIVITIES:DEBUG: init.")
-		
 		//Load the contents of the HomeView.xib file.
 		//Load the contents of the HomeView.xib file.
 		Bundle.main.loadNibNamed("ActivitiesView", owner: self, options: nil)
 		Bundle.main.loadNibNamed("ActivitiesView", owner: self, options: nil)
 		self.addSubview(container)
 		self.addSubview(container)
@@ -71,7 +70,11 @@ class ActivitiesView: UIView {
 		// Populate activity lists.
 		// Populate activity lists.
 		populate()
 		populate()
 	}
 	}
-		
+	
+	
+	/**
+	Actually populates the section.
+	*/
 	func populate(){
 	func populate(){
 		// Show future activities
 		// Show future activities
 		var fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
 		var fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
@@ -82,7 +85,6 @@ class ActivitiesView: UIView {
 		
 		
 		do {
 		do {
 			let searchResults = try self.context?.fetch(fetchRequest)
 			let searchResults = try self.context?.fetch(fetchRequest)
-			NSLog(":ACTIVITIES:DEBUG: Total future activities: \(String(describing: searchResults?.count))")
 			if searchResults?.count == 0{
 			if searchResults?.count == 0{
 				NSLog(":ACTIVITIES:DEBUG: No future activities: \(String(describing: searchResults?.count))")
 				NSLog(":ACTIVITIES:DEBUG: No future activities: \(String(describing: searchResults?.count))")
 				let row: RowLabel = RowLabel.init(s: "rowFutureActivity0", i: 0)
 				let row: RowLabel = RowLabel.init(s: "rowFutureActivity0", i: 0)
@@ -103,7 +105,6 @@ class ActivitiesView: UIView {
 			
 			
 				for r in searchResults! {
 				for r in searchResults! {
 					count = count + 1
 					count = count + 1
-					NSLog(":ACTIVITIES:DEBUG: Activity perm: \(String(describing: r.value(forKey: "permalink")))")
 				
 				
 					// Create a new row
 					// Create a new row
 					row = RowFutureActivity.init(s: "rowFutureActivity\(count)", i: count)
 					row = RowFutureActivity.init(s: "rowFutureActivity\(count)", i: count)
@@ -131,7 +132,6 @@ class ActivitiesView: UIView {
 						let imgSearchResults = try self.context?.fetch(imgFetchRequest)
 						let imgSearchResults = try self.context?.fetch(imgFetchRequest)
 						for imgR in imgSearchResults!{
 						for imgR in imgSearchResults!{
 							image = imgR.value(forKey: "image")! as! String
 							image = imgR.value(forKey: "image")! as! String
-							NSLog(":ACTIVITIES:DEBUG: Image: \(image)")
 							row.setImage(filename: image)
 							row.setImage(filename: image)
 						}
 						}
 					} catch {
 					} catch {
@@ -139,9 +139,7 @@ class ActivitiesView: UIView {
 					}
 					}
 				
 				
 					self.futureList?.addArrangedSubview(row)
 					self.futureList?.addArrangedSubview(row)
-					//row.setNeedsLayout()
-					//row.layoutIfNeeded()
-				
+					
 					// TODO: Do this on the row didLoad method
 					// TODO: Do this on the row didLoad method
 					// Set tap recognizer
 					// Set tap recognizer
 					//let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(openActivity(_:)))
 					//let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(openActivity(_:)))
@@ -167,7 +165,6 @@ class ActivitiesView: UIView {
 		
 		
 		do {
 		do {
 			let searchResults = try self.context?.fetch(fetchRequest)
 			let searchResults = try self.context?.fetch(fetchRequest)
-			NSLog(":ACTIVITIES:DEBUG: Total past activities: \(String(describing: searchResults?.count))")
 			
 			
 			var row: RowPastActivity
 			var row: RowPastActivity
 			var count: Int = 0
 			var count: Int = 0
@@ -178,7 +175,6 @@ class ActivitiesView: UIView {
 			
 			
 			for r in searchResults! {
 			for r in searchResults! {
 				count = count + 1
 				count = count + 1
-				NSLog(":ACTIVITIES:DEBUG: Activity perm: \(String(describing: r.value(forKey: "permalink")))")
 				
 				
 				// Create a new row
 				// Create a new row
 				row = RowPastActivity.init(s: "rowPastActivity\(count)", i: count)
 				row = RowPastActivity.init(s: "rowPastActivity\(count)", i: count)
@@ -200,7 +196,6 @@ class ActivitiesView: UIView {
 					let imgSearchResults = try self.context?.fetch(imgFetchRequest)
 					let imgSearchResults = try self.context?.fetch(imgFetchRequest)
 					for imgR in imgSearchResults!{
 					for imgR in imgSearchResults!{
 						image = imgR.value(forKey: "image")! as! String
 						image = imgR.value(forKey: "image")! as! String
-						NSLog(":ACTIVITIES:DEBUG: Image: \(image)")
 						row.setImage(filename: image)
 						row.setImage(filename: image)
 					}
 					}
 				}
 				}
@@ -208,11 +203,8 @@ class ActivitiesView: UIView {
 					NSLog(":ACTIVITIES:ERROR: Error getting image for activity \(id): \(error)")
 					NSLog(":ACTIVITIES:ERROR: Error getting image for activity \(id): \(error)")
 				}
 				}
 				
 				
-				NSLog(":ACTIVITIES:DEBUG: Row height: \(row.frame.height)")
 				
 				
 				self.pastList?.addArrangedSubview(row)
 				self.pastList?.addArrangedSubview(row)
-				//row.setNeedsLayout()
-				//row.layoutIfNeeded()
 				
 				
 				// TODO: Do this on the row didLoad method
 				// TODO: Do this on the row didLoad method
 				// Set tap recognizer
 				// Set tap recognizer
@@ -228,6 +220,7 @@ class ActivitiesView: UIView {
 		NSLog(":ACTIVITIES:DEBUG: Finished loading ActivitiesView")
 		NSLog(":ACTIVITIES:DEBUG: Finished loading ActivitiesView")
 	}
 	}
 	
 	
+	
 	/*func openActivity(){//(_ sender:UITapGestureRecognizer? = nil){
 	/*func openActivity(){//(_ sender:UITapGestureRecognizer? = nil){
 		NSLog(":ACTIVITIES:DEBUG: getting delegate and showing activity.")
 		NSLog(":ACTIVITIES:DEBUG: getting delegate and showing activity.")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
@@ -235,6 +228,7 @@ class ActivitiesView: UIView {
 		NSLog(":ACTIVITIES:DEBUG: Activity should be shown.")
 		NSLog(":ACTIVITIES:DEBUG: Activity should be shown.")
 	}
 	}
 	
 	
+	
 	func openActivity(_ sender:UITapGestureRecognizer? = nil){
 	func openActivity(_ sender:UITapGestureRecognizer? = nil){
 		NSLog(":ACTIVITIES:DEBUG: getting delegate and showing activity.")
 		NSLog(":ACTIVITIES:DEBUG: getting delegate and showing activity.")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
@@ -242,6 +236,12 @@ class ActivitiesView: UIView {
 		NSLog(":ACTIVITIES:DEBUG: Activity should be shown.")
 		NSLog(":ACTIVITIES:DEBUG: Activity should be shown.")
 	}*/
 	}*/
 	
 	
+	
+	/**
+	Gets the device language. The only recognized languages are Spanish, English and Basque.
+	If the device has another language, Spanish will be selected by default.
+	:return: Two-letter language code.
+	*/
 	func getLanguage() -> String{
 	func getLanguage() -> String{
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		if(pre == "es" || pre == "en" || pre == "eu"){
 		if(pre == "es" || pre == "en" || pre == "eu"){

+ 14 - 11
app/AlbumViewController.swift

@@ -41,17 +41,21 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 	// Id received from segue.
 	// Id received from segue.
 	var passId: Int = -1
 	var passId: Int = -1
 	
 	
+	
+	/**
+	Gets the app context.
+	:return: Application context.
+	*/
 	func getContext () -> NSManagedObjectContext {
 	func getContext () -> NSManagedObjectContext {
 		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
 		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Run when the app loads.
 	Run when the app loads.
 	*/
 	*/
 	override func viewDidLoad() {
 	override func viewDidLoad() {
 		
 		
-		NSLog(":ALBUMCONTROLLER:LOG: Init album.")
-		
 		super.viewDidLoad()
 		super.viewDidLoad()
 		self.loadAlbum(id: id)
 		self.loadAlbum(id: id)
 		
 		
@@ -59,11 +63,11 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 		barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
 		barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Returns to the main view controller.
 	Returns to the main view controller.
 	*/
 	*/
 	func back() {
 	func back() {
-		NSLog(":ALBUMCONTROLLER:DEBUG: Back")
 		self.dismiss(animated: true, completion: nil)
 		self.dismiss(animated: true, completion: nil)
 	}
 	}
 	
 	
@@ -75,15 +79,12 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 		super.didReceiveMemoryWarning()
 		super.didReceiveMemoryWarning()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Loads the photos of the album
 	Loads the photos of the album
 	*/
 	*/
 	public func loadAlbum(id: Int){
 	public func loadAlbum(id: Int){
 		
 		
-		NSLog(":ALBUMCONTROLLER:DEBUG: Loading album \(id)")
-		
-		albumContainer.backgroundColor = UIColor.red
-		
 		var row : RowAlbum
 		var row : RowAlbum
 		
 		
 		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
 		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
@@ -141,7 +142,7 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 					//TODO create row, add images (L+R), add row to container.
 					//TODO create row, add images (L+R), add row to container.
 					//row.setImage(filename: image)
 					//row.setImage(filename: image)
 				} catch {
 				} catch {
-					print(":GALLERYCONTROLLER:ERROR: Error getting image for post \(id): \(error)")
+					NSLog(":GALLERYCONTROLLER:ERROR: Error getting image for post \(id): \(error)")
 				}
 				}
 				
 				
 				NSLog(":GALLERYCONTROLLER:DEBUG: Adding row: height: \(row.frame.height)")
 				NSLog(":GALLERYCONTROLLER:DEBUG: Adding row: height: \(row.frame.height)")
@@ -150,13 +151,15 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 				rowcount = rowcount + 1
 				rowcount = rowcount + 1
 			}
 			}
 		} catch {
 		} catch {
-			print("POST:ERROR: Error with request: \(error)")
+			NSLog(":GALLERYCONTROLLER:ERROR: Error with request: \(error)")
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
-	Gets the device language.
-	:return: Two letter language code of the device.
+	Gets the device language. The only recognized languages are Spanish, English and Basque.
+	If the device has another language, Spanish will be selected by default.
+	:return: Two-letter language code.
 	*/
 	*/
 	func getLanguage() -> String{
 	func getLanguage() -> String{
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)

+ 45 - 21
app/AppDelegate.swift

@@ -26,11 +26,9 @@ import GoogleMaps
 class AppDelegate: UIResponder, UIApplicationDelegate {
 class AppDelegate: UIResponder, UIApplicationDelegate {
 
 
 	var window: UIWindow?
 	var window: UIWindow?
-	
 	var controller: ViewController?
 	var controller: ViewController?
 
 
 	
 	
-
 	func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
 	func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
 		// Override point for customization after application launch.
 		// Override point for customization after application launch.
 		
 		
@@ -38,48 +36,73 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 		
 		
 		return true
 		return true
 	}
 	}
+	
 
 
+	/**
+	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 invalidate
+	graphics rendering callbacks. Games should use this method to pause the game.
+	*/
 	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.
-		// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
 	}
 	}
+	
 
 
+	/**
+	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.
+	*/
 	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.
-		// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
 	}
 	}
 
 
+	
+	/**
+	Called as part of the transition from the background to the active state;
+	here you can undo many of the changes made on entering the background.
+	*/
 	func applicationWillEnterForeground(_ application: UIApplication) {
 	func applicationWillEnterForeground(_ application: UIApplication) {
-		// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
 	}
 	}
 
 
+	
+	/**
+	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 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.
 	}
 	}
 
 
+	/**
+	Called when the application is about to terminate. Save data if appropriate.
+	See also applicationDidEnterBackground:.
+	Saves changes in the application's managed object context before the application terminates.
+	*/
 	func applicationWillTerminate(_ application: UIApplication) {
 	func applicationWillTerminate(_ application: UIApplication) {
-		// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
-		// Saves changes in the application's managed object context before the application terminates.
-		//self.saveContext()
 	}
 	}
 
 
 	// MARK: - Core Data stack
 	// MARK: - Core Data stack
 	
 	
+	
+	// The directory the application uses to store the Core Data store file.
 	lazy var applicationDocumentsDirectory: URL = {
 	lazy var applicationDocumentsDirectory: URL = {
-		// The directory the application uses to store the Core Data store file. This code uses a directory named "com.cadiridris.coreDataTemplate" in the application's documents Application Support directory.
 		let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
 		let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
 		return urls[urls.count-1]
 		return urls[urls.count-1]
 	}()
 	}()
 	
 	
+	
+	// The managed object model for the application
 	lazy var managedObjectModel: NSManagedObjectModel = {
 	lazy var managedObjectModel: NSManagedObjectModel = {
-		// The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
 		let modelURL = Bundle.main.url(forResource: "app", withExtension: "momd")!
 		let modelURL = Bundle.main.url(forResource: "app", withExtension: "momd")!
 		return NSManagedObjectModel(contentsOf: modelURL)!
 		return NSManagedObjectModel(contentsOf: modelURL)!
 	}()
 	}()
 	
 	
+	// he persistent store coordinator for the application
 	lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator = {
 	lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator = {
-		// The persistent store coordinator for the application. This implementation creates and returns a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail.
-		// Create the coordinator and store
 		let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
 		let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
 		let url = self.applicationDocumentsDirectory.appendingPathComponent("SingleViewCoreData.sqlite")
 		let url = self.applicationDocumentsDirectory.appendingPathComponent("SingleViewCoreData.sqlite")
 		var failureReason = "There was an error creating or loading the application's saved data."
 		var failureReason = "There was an error creating or loading the application's saved data."
@@ -93,17 +116,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 			
 			
 			dict[NSUnderlyingErrorKey] = error as NSError
 			dict[NSUnderlyingErrorKey] = error as NSError
 			let wrappedError = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
 			let wrappedError = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
-			// Replace this with code to handle the error appropriately.
-			// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
-			NSLog("Unresolved error \(wrappedError), \(wrappedError.userInfo)")
+			NSLog(":DELEGATE:ERROR: Unresolved error \(wrappedError), \(wrappedError.userInfo)")
 			abort()
 			abort()
 		}
 		}
 		
 		
 		return coordinator
 		return coordinator
 	}()
 	}()
 	
 	
+	
+	// Returns the managed object context for the application
 	lazy var managedObjectContext: NSManagedObjectContext = {
 	lazy var managedObjectContext: NSManagedObjectContext = {
-		// Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) This property is optional since there are legitimate error conditions that could cause the creation of the context to fail.
 		let coordinator = self.persistentStoreCoordinator
 		let coordinator = self.persistentStoreCoordinator
 		var managedObjectContext = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
 		var managedObjectContext = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
 		managedObjectContext.persistentStoreCoordinator = coordinator
 		managedObjectContext.persistentStoreCoordinator = coordinator
@@ -112,6 +134,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 	
 	
 	// MARK: - Core Data Saving support
 	// MARK: - Core Data Saving support
 	
 	
+	/**
+	Saves the application context.
+	*/
 	func saveContext () {
 	func saveContext () {
 		if managedObjectContext.hasChanges {
 		if managedObjectContext.hasChanges {
 			do {
 			do {
@@ -120,11 +145,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 				// Replace this implementation with code to handle the error appropriately.
 				// Replace this implementation with code to handle the error appropriately.
 				// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
 				// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
 				let nserror = error as NSError
 				let nserror = error as NSError
-				NSLog("Unresolved error \(nserror), \(nserror.userInfo)")
+				NSLog(":DELEGATE:ERROR: Unresolved error \(nserror), \(nserror.userInfo)")
 				abort()
 				abort()
 			}
 			}
 		}
 		}
 	}
 	}
-	
 }
 }
 
 

+ 15 - 12
app/BlogView.swift

@@ -43,13 +43,13 @@ class BlogView: UIView {
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Run when the view is started.
 	Run when the view is started.
 	*/
 	*/
 	required init?(coder aDecoder: NSCoder) {
 	required init?(coder aDecoder: NSCoder) {
 		
 		
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
-		NSLog(":BLOG:DEBUG: init (coder).")
 		
 		
 		// Load the contents of the HomeView.xib file.
 		// Load the contents of the HomeView.xib file.
 		Bundle.main.loadNibNamed("BlogView", owner: self, options: nil)
 		Bundle.main.loadNibNamed("BlogView", owner: self, options: nil)
@@ -68,10 +68,12 @@ class BlogView: UIView {
 		
 		
 		populate()
 		populate()
 		
 		
-		NSLog(":BLOG:DEBUG: Finished loading BlogView")
-		
 	}
 	}
 	
 	
+	
+	/**
+	Populates the section.
+	*/
 	func populate(){
 	func populate(){
 		let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()
 		let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()
 		let sortDescriptor = NSSortDescriptor(key: "dtime", ascending: false)
 		let sortDescriptor = NSSortDescriptor(key: "dtime", ascending: false)
@@ -86,7 +88,6 @@ class BlogView: UIView {
 			
 			
 			// Get the results
 			// Get the results
 			let searchResults = try self.context?.fetch(fetchRequest)			
 			let searchResults = try self.context?.fetch(fetchRequest)			
-			NSLog(":BLOG:DEBUG: Total posts: \(String(describing: searchResults?.count))")
 			
 			
 			var row : RowBlog
 			var row : RowBlog
 			var count = 0
 			var count = 0
@@ -97,8 +98,7 @@ class BlogView: UIView {
 			
 			
 			for r in searchResults! {
 			for r in searchResults! {
 				count = count + 1
 				count = count + 1
-				NSLog(":BLOG:DEBUG: Post perm: \(String(describing: r.value(forKey: "permalink")))")
-								
+				
 				//Create a new row
 				//Create a new row
 				row = RowBlog.init(s: "rowBlog\(count)", i: count)
 				row = RowBlog.init(s: "rowBlog\(count)", i: count)
 				id = r.value(forKey: "id")! as! Int
 				id = r.value(forKey: "id")! as! Int
@@ -119,7 +119,6 @@ class BlogView: UIView {
 					let imgSearchResults = try context?.fetch(imgFetchRequest)
 					let imgSearchResults = try context?.fetch(imgFetchRequest)
 					for imgR in imgSearchResults!{
 					for imgR in imgSearchResults!{
 						image = imgR.value(forKey: "image")! as! String
 						image = imgR.value(forKey: "image")! as! String
-						NSLog(":BLOG:DEBUG: Image: \(image)")
 						row.setImage(filename: image)
 						row.setImage(filename: image)
 					}
 					}
 				} catch {
 				} catch {
@@ -128,8 +127,6 @@ class BlogView: UIView {
 				
 				
 				
 				
 				self.postList?.addArrangedSubview(row)
 				self.postList?.addArrangedSubview(row)
-				//row.setNeedsLayout()
-				//row.layoutIfNeeded()
 				
 				
 				// TODO: Do this on the row didLoad method
 				// TODO: Do this on the row didLoad method
 				// Set tap recognizer
 				// Set tap recognizer
@@ -137,8 +134,6 @@ class BlogView: UIView {
 				//row.isUserInteractionEnabled = true
 				//row.isUserInteractionEnabled = true
 				//row.addGestureRecognizer(tapRecognizer)
 				//row.addGestureRecognizer(tapRecognizer)
 				
 				
-				
-				
 			}
 			}
 
 
 			// Trigger a layout update
 			// Trigger a layout update
@@ -151,11 +146,13 @@ class BlogView: UIView {
 		NSLog(":BLOG:DEBUG: Finished populating BlogView")
 		NSLog(":BLOG:DEBUG: Finished populating BlogView")
 	}
 	}
 	
 	
+	
 	/*func openPost(){//(_ sender:UITapGestureRecognizer? = nil){
 	/*func openPost(){//(_ sender:UITapGestureRecognizer? = nil){
 		print("BLOG:DEBUG: getting delegate and showing post.")
 		print("BLOG:DEBUG: getting delegate and showing post.")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		delegate.controller?.showPost(id: 4)
 		delegate.controller?.showPost(id: 4)
-		print("BLOG:DEBUG: Post should be shown.")
+		
+	print("BLOG:DEBUG: Post should be shown.")
 	}
 	}
 	
 	
 	func openPost(_ sender:UITapGestureRecognizer? = nil){
 	func openPost(_ sender:UITapGestureRecognizer? = nil){
@@ -165,6 +162,12 @@ class BlogView: UIView {
 		print("BLOG:DEBUG: Post should be shown.")
 		print("BLOG:DEBUG: Post should be shown.")
 	}*/
 	}*/
 	
 	
+	
+	/**
+	Gets the device language. The only recognized languages are Spanish, English and Basque.
+	If the device has another language, Spanish will be selected by default.
+	:return: Two-letter language code.
+	*/
 	func getLanguage() -> String{
 	func getLanguage() -> String{
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		if(pre == "es" || pre == "en" || pre == "eu"){
 		if(pre == "es" || pre == "en" || pre == "eu"){

+ 2 - 9
app/Entry.swift

@@ -30,7 +30,7 @@ class Entry: UIView {
 	@IBOutlet weak var entry: UIView!
 	@IBOutlet weak var entry: UIView!
 	
 	
 	/**
 	/**
-	Run when the section is loaded.
+	Run when the entry is loaded.
 	*/
 	*/
 	required init?(coder aDecoder: NSCoder) {
 	required init?(coder aDecoder: NSCoder) {
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
@@ -40,12 +40,5 @@ class Entry: UIView {
 		self.addSubview(entry)
 		self.addSubview(entry)
 		entry.frame = self.bounds
 		entry.frame = self.bounds
 	}
 	}
-	
-	/**
-	Chancges the title of the section.
-	:param: title The new title.
-	*/
-	//func setTitle(text: String){
-	//	title.text = text
-	//}
+
 }
 }

+ 18 - 5
app/GalleryView.swift

@@ -37,6 +37,7 @@ class GalleryView: UIView {
 	// Section row list
 	// Section row list
 	var rows: Array<RowGallery> = []
 	var rows: Array<RowGallery> = []
 	
 	
+	
 	/**
 	/**
 	Run when the view is started.
 	Run when the view is started.
 	*/
 	*/
@@ -44,6 +45,7 @@ class GalleryView: UIView {
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Run when the view is started.
 	Run when the view is started.
 	*/
 	*/
@@ -138,9 +140,6 @@ class GalleryView: UIView {
 				
 				
 				// Add to the rows array
 				// Add to the rows array
 				self.rows.append(row)
 				self.rows.append(row)
-				
-				
-				
 			}
 			}
 		} catch {
 		} catch {
 			NSLog(":GALLERY:ERROR: Error with request: \(error)")
 			NSLog(":GALLERY:ERROR: Error with request: \(error)")
@@ -150,15 +149,19 @@ class GalleryView: UIView {
 		var h: Int = 0
 		var h: Int = 0
 		for view in scrollView.subviews {
 		for view in scrollView.subviews {
 			//contentRect = contentRect.union(view.frame);
 			//contentRect = contentRect.union(view.frame);
-			h = h + Int(view.frame.height) + 30 //Why 30?
+			h = h + Int(view.frame.height) + 30 // TODO Why 30?
 		}
 		}
 		// TODO: Calculate at the end
 		// TODO: Calculate at the end
-		self.scrollView.contentSize.height = 2500//CGFloat(h);
+		self.scrollView.contentSize.height = 2500 //CGFloat(h);
 		
 		
 		self.setUpRowsTapRecognizers()
 		self.setUpRowsTapRecognizers()
 		NSLog(":GALLERY:LOG: Finished loading gallery section.")
 		NSLog(":GALLERY:LOG: Finished loading gallery section.")
 	}
 	}
 	
 	
+	
+	/**
+	Opens an album.
+	*/
 	func openAlbum(_ sender:UITapGestureRecognizer? = nil){
 	func openAlbum(_ sender:UITapGestureRecognizer? = nil){
 		let id = (sender?.view as! RowGallery).id
 		let id = (sender?.view as! RowGallery).id
 		NSLog(":GALLERY:DEBUG: getting delegate and showing album \(id).")
 		NSLog(":GALLERY:DEBUG: getting delegate and showing album \(id).")
@@ -166,6 +169,12 @@ class GalleryView: UIView {
 		delegate.controller?.showAlbum(id: id)
 		delegate.controller?.showAlbum(id: id)
 	}
 	}
 	
 	
+	
+	/**
+	Gets the device language. The only recognized languages are Spanish, English and Basque.
+	If the device has another language, Spanish will be selected by default.
+	:return: Two-letter language code.
+	*/
 	func getLanguage() -> String{
 	func getLanguage() -> String{
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		if(pre == "es" || pre == "en" || pre == "eu"){
 		if(pre == "es" || pre == "en" || pre == "eu"){
@@ -176,6 +185,10 @@ class GalleryView: UIView {
 		}
 		}
 	}
 	}
 	
 	
+	
+	/**
+	Handles the click events to open albums.
+	*/
 	func setUpRowsTapRecognizers(){
 	func setUpRowsTapRecognizers(){
 		NSLog(":GALLERY:DEBUG: Setting up tap recognizers")
 		NSLog(":GALLERY:DEBUG: Setting up tap recognizers")
 		for row in self.rows{
 		for row in self.rows{

+ 54 - 64
app/HomeView.swift

@@ -91,12 +91,16 @@ class HomeView: UIView {
 		for view in scrollView.subviews {
 		for view in scrollView.subviews {
 			//contentRect = contentRect.union(view.frame);
 			//contentRect = contentRect.union(view.frame);
 			h = h + Int(view.frame.height) + 30 //Why 30?
 			h = h + Int(view.frame.height) + 30 //Why 30?
-			print("curh: \(h)")
 		}
 		}
 		// TODO: Calculate at the end
 		// TODO: Calculate at the end
 		self.scrollView.contentSize.height = 1300// CGFloat(h);
 		self.scrollView.contentSize.height = 1300// CGFloat(h);
 	}
 	}
 	
 	
+	/**
+	Gets the device language. The only recognized languages are Spanish, English and Basque.
+	If the device has another language, Spanish will be selected by default.
+	:return: Two-letter language code.
+	*/
 	func getLanguage() -> String{
 	func getLanguage() -> String{
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		if(pre == "es" || pre == "en" || pre == "eu"){
 		if(pre == "es" || pre == "en" || pre == "eu"){
@@ -107,9 +111,14 @@ class HomeView: UIView {
 		}
 		}
 	}
 	}
 	
 	
+	
+	/**
+	Sets up the future activities section.
+	:param: delegate App delegate.
+	:param: lang Language code (two letter code, lowercase. Only 'es', 'en' and 'eu' supported).
+	:param: parent Stack view to load the rows in.
+	*/
 	func setUpFutureActivities(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
 	func setUpFutureActivities(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
-		
-		//context.persistentStoreCoordinator = delegate.persistentStoreCoordinator
 		let fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
 		let fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
 		let sortDescriptor = NSSortDescriptor(key: "date", ascending: true)
 		let sortDescriptor = NSSortDescriptor(key: "date", ascending: true)
 		let sortDescriptors = [sortDescriptor]
 		let sortDescriptors = [sortDescriptor]
@@ -118,12 +127,8 @@ class HomeView: UIView {
 		fetchRequest.fetchLimit = 2
 		fetchRequest.fetchLimit = 2
 		
 		
 		do {
 		do {
-			//go get the results
 			let searchResults = try context.fetch(fetchRequest)
 			let searchResults = try context.fetch(fetchRequest)
 			
 			
-			//I like to check the size of the returned results!
-			print ("Activities: \(searchResults.count)")
-			
 			var row : RowHomeFutureActivities
 			var row : RowHomeFutureActivities
 			var count = 0
 			var count = 0
 			var id: Int
 			var id: Int
@@ -131,19 +136,14 @@ class HomeView: UIView {
 			var text: String
 			var text: String
 			var image: String
 			var image: String
 			
 			
-			//You need to convert to NSManagedObject to use 'for' loops
 			for r in searchResults as [NSManagedObject] {
 			for r in searchResults as [NSManagedObject] {
 				count = count + 1
 				count = count + 1
-				//get the Key Value pairs (although there may be a better way to do that...
-				print("Perm: \(r.value(forKey: "permalink"))")
-				
 				
 				
 				//Create a new row
 				//Create a new row
 				row = RowHomeFutureActivities.init(s: "rowHomeFutureActivities\(count)", i: count)
 				row = RowHomeFutureActivities.init(s: "rowHomeFutureActivities\(count)", i: count)
 				id = r.value(forKey: "id")! as! Int
 				id = r.value(forKey: "id")! as! Int
 				title = r.value(forKey: "title_\(lang)")! as! String
 				title = r.value(forKey: "title_\(lang)")! as! String
 				text = r.value(forKey: "text_\(lang)")! as! String
 				text = r.value(forKey: "text_\(lang)")! as! String
-				print(title)
 				row.setTitle(text: title)
 				row.setTitle(text: title)
 				row.setText(text: text.decode())
 				row.setText(text: text.decode())
 				
 				
@@ -159,26 +159,30 @@ class HomeView: UIView {
 					let imgSearchResults = try context.fetch(imgFetchRequest)
 					let imgSearchResults = try context.fetch(imgFetchRequest)
 					for imgR in imgSearchResults as [NSManagedObject]{
 					for imgR in imgSearchResults as [NSManagedObject]{
 						image = imgR.value(forKey: "image")! as! String
 						image = imgR.value(forKey: "image")! as! String
-						print ("IMAGE: \(image)")
 						row.setImage(filename: image)
 						row.setImage(filename: image)
 					}
 					}
-				} catch {
-					print("Error getting image for activity \(id): \(error)")
 				}
 				}
-				
-				print("Row height: \(row.frame.height)")
+				catch {
+					NSLog(":HOME:ERROR: Error getting image for activity \(id): \(error)")
+				}
 				
 				
 				parent.addArrangedSubview(row)
 				parent.addArrangedSubview(row)
 				
 				
 			}
 			}
 		} catch {
 		} catch {
-			print("Error with request: \(error)")
+			NSLog(":HOME:ERROR: Error loading future activities: \(error)")
 		}
 		}
 	}
 	}
 	
 	
+	
+	/**
+	Sets up the blog section.
+	:param: delegate App delegate.
+	:param: lang Language code (two letter code, lowercase. Only 'es', 'en' and 'eu' supported).
+	:param: parent Stack view to load the rows in.
+	*/
 	func setUpBlog(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
 	func setUpBlog(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
 		
 		
-		//context.persistentStoreCoordinator = delegate.persistentStoreCoordinator
 		let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()
 		let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()
 		let sortDescriptor = NSSortDescriptor(key: "dtime", ascending: false)
 		let sortDescriptor = NSSortDescriptor(key: "dtime", ascending: false)
 		let sortDescriptors = [sortDescriptor]
 		let sortDescriptors = [sortDescriptor]
@@ -186,12 +190,7 @@ class HomeView: UIView {
 		fetchRequest.fetchLimit = 2
 		fetchRequest.fetchLimit = 2
 		
 		
 		do {
 		do {
-			//go get the results
 			let searchResults = try context.fetch(fetchRequest)
 			let searchResults = try context.fetch(fetchRequest)
-			
-			//I like to check the size of the returned results!
-			print ("Post: \(searchResults.count)")
-			
 			var row : RowHomeBlog
 			var row : RowHomeBlog
 			var count = 0
 			var count = 0
 			var id: Int
 			var id: Int
@@ -199,12 +198,8 @@ class HomeView: UIView {
 			var text: String
 			var text: String
 			var image: String
 			var image: String
 			
 			
-			//You need to convert to NSManagedObject to use 'for' loops
 			for r in searchResults as [NSManagedObject] {
 			for r in searchResults as [NSManagedObject] {
 				count = count + 1
 				count = count + 1
-				//get the Key Value pairs (although there may be a better way to do that...
-				print("Perm: \(r.value(forKey: "permalink"))")
-				
 				
 				
 				//Create a new row
 				//Create a new row
 				row = RowHomeBlog.init(s: "rowHomeBlog\(count)", i: count)
 				row = RowHomeBlog.init(s: "rowHomeBlog\(count)", i: count)
@@ -228,15 +223,12 @@ class HomeView: UIView {
 					let imgSearchResults = try context.fetch(imgFetchRequest)
 					let imgSearchResults = try context.fetch(imgFetchRequest)
 					for imgR in imgSearchResults as [NSManagedObject]{
 					for imgR in imgSearchResults as [NSManagedObject]{
 						image = imgR.value(forKey: "image")! as! String
 						image = imgR.value(forKey: "image")! as! String
-						print ("IMAGE: \(image)")
 						row.setImage(filename: image)
 						row.setImage(filename: image)
 					}
 					}
 				} catch {
 				} catch {
-					print("Error getting image for post \(id): \(error)")
+					NSLog(":HOME:ERROR: Error getting image for post \(id): \(error)")
 				}
 				}
 				
 				
-				print("Row height: \(row.frame.height)")
-				
 				parent.addArrangedSubview(row)
 				parent.addArrangedSubview(row)
 				
 				
 				let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(openPost(_:)))
 				let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(openPost(_:)))
@@ -244,14 +236,21 @@ class HomeView: UIView {
 				row.addGestureRecognizer(tapRecognizer)
 				row.addGestureRecognizer(tapRecognizer)
 				
 				
 			}
 			}
-		} catch {
-			print("Error with request: \(error)")
+		}
+		catch {
+			NSLog(":HOME:ERROR: Error loading the blog section: \(error)")
 		}
 		}
 	}
 	}
 	
 	
+	
+	/**
+	Sets up the past activities section.
+	:param: delegate App delegate.
+	:param: lang Language code (two letter code, lowercase. Only 'es', 'en' and 'eu' supported).
+	:param: parent Stack view to load the rows in.
+	*/
 	func setUpPastActivities(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
 	func setUpPastActivities(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
 		
 		
-		//context.persistentStoreCoordinator = delegate.persistentStoreCoordinator
 		let fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
 		let fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
 		let sortDescriptor = NSSortDescriptor(key: "date", ascending: false)
 		let sortDescriptor = NSSortDescriptor(key: "date", ascending: false)
 		let sortDescriptors = [sortDescriptor]
 		let sortDescriptors = [sortDescriptor]
@@ -260,12 +259,8 @@ class HomeView: UIView {
 		fetchRequest.fetchLimit = 2
 		fetchRequest.fetchLimit = 2
 		
 		
 		do {
 		do {
-			//go get the results
 			let searchResults = try context.fetch(fetchRequest)
 			let searchResults = try context.fetch(fetchRequest)
 			
 			
-			//I like to check the size of the returned results!
-			print ("Activities: \(searchResults.count)")
-			
 			var row : RowHomePastActivities
 			var row : RowHomePastActivities
 			var count = 0
 			var count = 0
 			var id: Int
 			var id: Int
@@ -273,12 +268,8 @@ class HomeView: UIView {
 			var text: String
 			var text: String
 			var image: String
 			var image: String
 			
 			
-			//You need to convert to NSManagedObject to use 'for' loops
 			for r in searchResults as [NSManagedObject] {
 			for r in searchResults as [NSManagedObject] {
 				count = count + 1
 				count = count + 1
-				//get the Key Value pairs (although there may be a better way to do that...
-				print("Perm: \(r.value(forKey: "permalink"))")
-				
 				
 				
 				//Create a new row
 				//Create a new row
 				row = RowHomePastActivities.init(s: "rowHomePastActivities\(count)", i: count)
 				row = RowHomePastActivities.init(s: "rowHomePastActivities\(count)", i: count)
@@ -286,7 +277,6 @@ class HomeView: UIView {
 				title = r.value(forKey: "title_\(lang)")! as! String
 				title = r.value(forKey: "title_\(lang)")! as! String
 				text = r.value(forKey: "text_\(lang)")! as! String
 				text = r.value(forKey: "text_\(lang)")! as! String
 				
 				
-				
 				row.setTitle(text: title)
 				row.setTitle(text: title)
 				row.setText(text: text)
 				row.setText(text: text)
 				
 				
@@ -302,32 +292,32 @@ class HomeView: UIView {
 					let imgSearchResults = try context.fetch(imgFetchRequest)
 					let imgSearchResults = try context.fetch(imgFetchRequest)
 					for imgR in imgSearchResults as [NSManagedObject]{
 					for imgR in imgSearchResults as [NSManagedObject]{
 						image = imgR.value(forKey: "image")! as! String
 						image = imgR.value(forKey: "image")! as! String
-						print ("IMAGE: \(image)")
 						row.setImage(filename: image)
 						row.setImage(filename: image)
 					}
 					}
-				} catch {
-					print("Error getting image for activity \(id): \(error)")
 				}
 				}
-				
-				print("Row height: \(row.frame.height)")
-				
+				catch {
+					NSLog(":HOME:ERROR: Error getting image for past activity \(id): \(error)")
+				}
 				parent.addArrangedSubview(row)
 				parent.addArrangedSubview(row)
 				
 				
 			}
 			}
 		} catch {
 		} catch {
-			print("Error with request: \(error)")
+			NSLog(":HOME:ERROR: Error loading past activities: \(error)")
 		}
 		}
 	}
 	}
 	
 	
+	/**
+	Sets up the future activities section.
+	:param: delegate App delegate.
+	:param: parent Stack view to load the rows in.
+	*/
 	func setUpGallery(context : NSManagedObjectContext, delegate: AppDelegate,parent: UIStackView){
 	func setUpGallery(context : NSManagedObjectContext, delegate: AppDelegate,parent: UIStackView){
-		print("HOME:LOG: Setting up gallery.")
 		
 		
 		// Create the row
 		// Create the row
 		var row: RowHomeGallery
 		var row: RowHomeGallery
 		row = RowHomeGallery.init(s: "rowHomeGallery", i: 0)
 		row = RowHomeGallery.init(s: "rowHomeGallery", i: 0)
 		parent.addArrangedSubview(row)
 		parent.addArrangedSubview(row)
 		
 		
-		
 		// Set images
 		// Set images
 		let fetchRequest: NSFetchRequest<Photo> = Photo.fetchRequest()
 		let fetchRequest: NSFetchRequest<Photo> = Photo.fetchRequest()
 		let sortDescriptor = NSSortDescriptor(key: "uploaded", ascending: false)
 		let sortDescriptor = NSSortDescriptor(key: "uploaded", ascending: false)
@@ -336,13 +326,10 @@ class HomeView: UIView {
 		fetchRequest.fetchLimit = 4
 		fetchRequest.fetchLimit = 4
 		
 		
 		do {
 		do {
-			//go get the results
 			let searchResults = try context.fetch(fetchRequest)
 			let searchResults = try context.fetch(fetchRequest)
 	
 	
 			var id: Int
 			var id: Int
 			var image: String
 			var image: String
-			
-			// Loop images
 			var i = 0
 			var i = 0
 			for r in searchResults as [NSManagedObject] {
 			for r in searchResults as [NSManagedObject] {
 				
 				
@@ -350,30 +337,33 @@ class HomeView: UIView {
 				row.setImage(idx: i, filename: image)
 				row.setImage(idx: i, filename: image)
 				
 				
 				//TODO Set click listener
 				//TODO Set click listener
-				
 				i = i + 1
 				i = i + 1
 			}
 			}
-			
 		}
 		}
 		catch{
 		catch{
-			print("HOME:ERROR: Error setting gallery up: \(error)")
+			NSLog(":HOME:ERROR: Error setting gallery up: \(error)")
 		}
 		}
-		
 	}
 	}
 	
 	
+	
+	/**
+	Sets up the social section.
+	:param: parent Stack view to load the rows in.
+	*/
 	func setUpSocial(parent : UIStackView){
 	func setUpSocial(parent : UIStackView){
-		print("SETING UP SOCIAL")
 		//Create a new row
 		//Create a new row
 		var row : RowHomeSocial
 		var row : RowHomeSocial
 		row = RowHomeSocial.init(s: "rowHomeSocial", i: 0)
 		row = RowHomeSocial.init(s: "rowHomeSocial", i: 0)
-		print("ROW CREATED")
 		parent.addArrangedSubview(row)
 		parent.addArrangedSubview(row)
 	}
 	}
 	
 	
+	
+	/**
+	Opens a post.
+	*/
 	func openPost(_ sender:UITapGestureRecognizer? = nil){
 	func openPost(_ sender:UITapGestureRecognizer? = nil){
-		print("HOME:DEBUG: getting delegate and showing post.")
+		NSLog(":HOME:DEBUG: Getting delegate and showing post.")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		delegate.controller?.showPost(id: (sender?.view as! RowHomeBlog).id)
 		delegate.controller?.showPost(id: (sender?.view as! RowHomeBlog).id)
-		print("HOME:DEBUG: Post should be shown.")
 	}
 	}
 }
 }

+ 15 - 15
app/LablancaView.swift

@@ -41,8 +41,6 @@ class LablancaView: UIView {
 	// App delegate
 	// App delegate
 	var delegate: AppDelegate? = nil
 	var delegate: AppDelegate? = nil
 	
 	
-	// Section row list
-	//var rows: Array<RowGallery> = []
 	
 	
 	/**
 	/**
 	Run when the view is started.
 	Run when the view is started.
@@ -51,6 +49,7 @@ class LablancaView: UIView {
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Run when the view is started.
 	Run when the view is started.
 	*/
 	*/
@@ -62,15 +61,15 @@ class LablancaView: UIView {
 
 
 		Bundle.main.loadNibNamed("LablancaView", owner: self, options: nil)
 		Bundle.main.loadNibNamed("LablancaView", owner: self, options: nil)
 		self.addSubview(container)
 		self.addSubview(container)
-		container.frame = self.bounds
+		self.container.frame = self.bounds
 		
 		
 		// Get viewController from StoryBoard
 		// Get viewController from StoryBoard
 		let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
 		let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
-		let controller = storyboard.instantiateViewController(withIdentifier: "GMViewController") as! ViewController
+		_ = storyboard.instantiateViewController(withIdentifier: "GMViewController") as! ViewController
 		
 		
 		// Read settings and show the required sections
 		// Read settings and show the required sections
 		let defaults = UserDefaults.standard
 		let defaults = UserDefaults.standard
-		let festivals: Int = 1 //TODO defaults.integer(forKey: "festivals")
+		let festivals: Int = defaults.integer(forKey: "festivals")
 		
 		
 		if festivals == 1{
 		if festivals == 1{
 			showFestivals()
 			showFestivals()
@@ -184,7 +183,7 @@ class LablancaView: UIView {
 
 
 		// Get days
 		// Get days
 		let dayFetchRequest: NSFetchRequest<Festival_day> = Festival_day.fetchRequest()
 		let dayFetchRequest: NSFetchRequest<Festival_day> = Festival_day.fetchRequest()
-		dayFetchRequest.predicate = NSPredicate(format: "(date >= %@) AND (date <= %@)", argumentArray: [sDate, eDate])
+		dayFetchRequest.predicate = NSPredicate(format: "(date >= %@) AND (date <= %@)", argumentArray: [sDate!, eDate!])
 		
 		
 		do {
 		do {
 			
 			
@@ -224,7 +223,8 @@ class LablancaView: UIView {
 				count = count + 1
 				count = count + 1
 			}
 			}
 			
 			
-		} catch {
+		}
+		catch {
 			NSLog(":LABLANCA:ERROR: Error getting festival days info: \(error)")
 			NSLog(":LABLANCA:ERROR: Error getting festival days info: \(error)")
 		}
 		}
 	}
 	}
@@ -241,9 +241,9 @@ class LablancaView: UIView {
 	
 	
 
 
 	/**
 	/**
-  Commands the view controller to show the city schedule view.
-  :param: sender The view that triggered the event.
-  */
+	Commands the view controller to show the city schedule view.
+	:param: sender The view that triggered the event.
+	*/
 	func openSchedule(_ sender:UITapGestureRecognizer? = nil){
 	func openSchedule(_ sender:UITapGestureRecognizer? = nil){
 		NSLog(":LABLANCA:DEBUG: Getting delegate and showing schedule.")
 		NSLog(":LABLANCA:DEBUG: Getting delegate and showing schedule.")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
@@ -257,11 +257,11 @@ class LablancaView: UIView {
 	:param: sender The view that triggered the event.
 	:param: sender The view that triggered the event.
 	*/
 	*/
 	func openGMSchedule(_ sender:UITapGestureRecognizer? = nil){
 	func openGMSchedule(_ sender:UITapGestureRecognizer? = nil){
-    NSLog(":LABLANCA:DEBUG: Getting delegate and showing GM schedule.")
-    let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
-    delegate.controller?.showSchedule(margolari: true)
-    NSLog(":LABLANCA:DEBUG: GM schedule should be shown.")
-  }
+		NSLog(":LABLANCA:DEBUG: Getting delegate and showing GM schedule.")
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showSchedule(margolari: true)
+		NSLog(":LABLANCA:DEBUG: GM schedule should be shown.")
+	}
 
 
 	
 	
 	/**
 	/**

+ 5 - 15
app/LocationView.swift

@@ -36,13 +36,13 @@ class LocationView: UIView {
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Run when the view is started.
 	Run when the view is started.
 	*/
 	*/
 	required init?(coder aDecoder: NSCoder) {
 	required init?(coder aDecoder: NSCoder) {
 		
 		
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
-		NSLog(":LOCATION:DEBUG: init (coder).")
 		
 		
 		// Load the contents of the HomeView.xib file.
 		// Load the contents of the HomeView.xib file.
 		Bundle.main.loadNibNamed("LocationView", owner: self, options: nil)
 		Bundle.main.loadNibNamed("LocationView", owner: self, options: nil)
@@ -54,22 +54,12 @@ class LocationView: UIView {
 		//map.addObserver(self, forKeyPath: "myLocation", options: NSKeyValueObservingOptions.new, context: nil)
 		//map.addObserver(self, forKeyPath: "myLocation", options: NSKeyValueObservingOptions.new, context: nil)
 		let camera: GMSCameraPosition = GMSCameraPosition.camera(withLatitude: 42.846399, longitude: -2.673365, zoom: 12.0)
 		let camera: GMSCameraPosition = GMSCameraPosition.camera(withLatitude: 42.846399, longitude: -2.673365, zoom: 12.0)
 		map.camera = camera
 		map.camera = camera
-		/*self.postList = self.section.getContentStack()
-		
-		// Get viewController from StoryBoard
-		self.storyboard = UIStoryboard(name: "Main", bundle: nil)
-		self.controller = storyboard?.instantiateViewController(withIdentifier: "GMViewController") as? ViewController
-		self.context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
-		self.delegate = UIApplication.shared.delegate as? AppDelegate
-		self.lang = getLanguage()
-		self.context?.persistentStoreCoordinator = delegate?.persistentStoreCoordinator
-		
-		populate()*/
-		
-		NSLog(":LOCATION:DEBUG: Finished loading LocationView")
-		
 	}
 	}
 	
 	
+	
+	/**
+	I am not sure what does this do...
+	*/
 	func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
 	func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
 		if status == CLAuthorizationStatus.authorizedWhenInUse {
 		if status == CLAuthorizationStatus.authorizedWhenInUse {
 			map.isMyLocationEnabled = true
 			map.isMyLocationEnabled = true

+ 23 - 35
app/PostViewController.swift

@@ -26,8 +26,6 @@ The view controller of the app.
 */
 */
 class PostViewController: UIViewController, UIGestureRecognizerDelegate {
 class PostViewController: UIViewController, UIGestureRecognizerDelegate {
 	
 	
-
-	
 	@IBOutlet weak var barTitle: UILabel!
 	@IBOutlet weak var barTitle: UILabel!
 	@IBOutlet weak var barButton: UIButton!
 	@IBOutlet weak var barButton: UIButton!
 	@IBOutlet weak var postText: UILabel!
 	@IBOutlet weak var postText: UILabel!
@@ -36,33 +34,31 @@ class PostViewController: UIViewController, UIGestureRecognizerDelegate {
 	var id: Int = -1
 	var id: Int = -1
 	var delegate: AppDelegate?
 	var delegate: AppDelegate?
 	
 	
-	//Each of the sections of the app.
-	
 	var passId: Int = -1
 	var passId: Int = -1
 	
 	
+	/**
+	Get the app context.
+	:return: The app context.
+	*/
 	func getContext () -> NSManagedObjectContext {
 	func getContext () -> NSManagedObjectContext {
-		//let appDelegate = UIApplication.shared.delegate as! AppDelegate
-		//return appDelegate.persistentContainer.viewContext
 		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
 		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Run when the app loads.
 	Run when the app loads.
 	*/
 	*/
 	override func viewDidLoad() {
 	override func viewDidLoad() {
-		
-		print("POSTCONTROLLER:LOG: viewDidLoad()")
-		
 		super.viewDidLoad()
 		super.viewDidLoad()
 		self.loadPost(id: id)
 		self.loadPost(id: id)
-		
 		// Set button action
 		// Set button action
 		barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
 		barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
 	}
 	}
 	
 	
-	//TODO implement all the logic for post loading here, including iboutlts
-	
 	
 	
+	/**
+	Dismisses the controller.
+	*/
 	func back() {
 	func back() {
 		print("POSTCONTROLLER:DEBUG: Back")
 		print("POSTCONTROLLER:DEBUG: Back")
 		self.dismiss(animated: true, completion: nil)
 		self.dismiss(animated: true, completion: nil)
@@ -76,9 +72,14 @@ class PostViewController: UIViewController, UIGestureRecognizerDelegate {
 		super.didReceiveMemoryWarning()
 		super.didReceiveMemoryWarning()
 	}
 	}
 	
 	
+	
+	/**
+	Loads the selected post.
+	:param: id Post id.
+	*/
 	public func loadPost(id: Int){
 	public func loadPost(id: Int){
 		
 		
-		print("POSTCONTROLLER:DEBUG: Loading post \(id)")
+		NSLog(":POSTCONTROLLER:DEBUG: Loading post \(id)")
 		
 		
 		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
 		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
 		let appDelegate = UIApplication.shared.delegate as! AppDelegate
 		let appDelegate = UIApplication.shared.delegate as! AppDelegate
@@ -88,18 +89,14 @@ class PostViewController: UIViewController, UIGestureRecognizerDelegate {
 		fetchRequest.predicate = NSPredicate(format: "id = %i", id)
 		fetchRequest.predicate = NSPredicate(format: "id = %i", id)
 		
 		
 		do {
 		do {
-			//go get the results
 			let searchResults = try context.fetch(fetchRequest)
 			let searchResults = try context.fetch(fetchRequest)
-			
 			var count = 0
 			var count = 0
 			var sTitle: String
 			var sTitle: String
 			var sText: String
 			var sText: String
 			var image: String
 			var image: String
 			
 			
-			//You need to convert to NSManagedObject to use 'for' loops
 			for r in searchResults as [NSManagedObject] {
 			for r in searchResults as [NSManagedObject] {
 				count = count + 1
 				count = count + 1
-				
 				sTitle = r.value(forKey: "title_\(lang)")! as! String
 				sTitle = r.value(forKey: "title_\(lang)")! as! String
 				sText = r.value(forKey: "text_\(lang)")! as! String
 				sText = r.value(forKey: "text_\(lang)")! as! String
 				postTitle.text = "  \(sTitle)"
 				postTitle.text = "  \(sTitle)"
@@ -113,37 +110,28 @@ class PostViewController: UIViewController, UIGestureRecognizerDelegate {
 				imgFetchRequest.sortDescriptors = imgSortDescriptors
 				imgFetchRequest.sortDescriptors = imgSortDescriptors
 				imgFetchRequest.predicate = NSPredicate(format: "post == %i", id)
 				imgFetchRequest.predicate = NSPredicate(format: "post == %i", id)
 				imgFetchRequest.fetchLimit = 1
 				imgFetchRequest.fetchLimit = 1
-				//TODO get more images
 				do{
 				do{
 					let imgSearchResults = try context.fetch(imgFetchRequest)
 					let imgSearchResults = try context.fetch(imgFetchRequest)
 					for imgR in imgSearchResults as [NSManagedObject]{
 					for imgR in imgSearchResults as [NSManagedObject]{
 						image = imgR.value(forKey: "image")! as! String
 						image = imgR.value(forKey: "image")! as! String
-						print ("POST:LOG: Image: \(image)")
-						//TODO set image
-						//row.setImage(filename: image)
+						let path = "img/blog/preview/\(image)"
+						self.postImage.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
 					}
 					}
 				} catch {
 				} catch {
-					print("POST:ERROR: Error getting image for post \(id): \(error)")
+					NSLog(":POST:ERROR: Error getting image for post \(id): \(error)")
 				}
 				}
 				
 				
 			}
 			}
 		} catch {
 		} catch {
-			print("POST:ERROR: Error with request: \(error)")
+			NSLog(":POST:ERROR: Error with request: \(error)")
 		}
 		}
-		
-		//Always at the end: update scrollview
-		// TODOs
-		//var h: Int = 0
-		//for view in scrollView.subviews {
-			//contentRect = contentRect.union(view.frame);
-		//	h = h + Int(view.frame.height) + 30 //Why 30?
-		//}
-		//print("POST:DEBUG: Height: \(h)")
-		// TODO: Calculate at the end
-		//self.scrollView.contentSize.height = 4500//CGFloat(h);
-
 	}
 	}
 	
 	
+	/**
+	Gets the device language. The only recognized languages are Spanish, English and Basque.
+	If the device has another language, Spanish will be selected by default.
+	:return: Two-letter language code.
+	*/
 	func getLanguage() -> String{
 	func getLanguage() -> String{
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		if(pre == "es" || pre == "en" || pre == "eu"){
 		if(pre == "es" || pre == "en" || pre == "eu"){

+ 10 - 17
app/RowAlbum.swift

@@ -31,13 +31,9 @@ Extension of UIView to be formatted as sections.
 	@IBOutlet weak var photo0: UIImageView!
 	@IBOutlet weak var photo0: UIImageView!
 	@IBOutlet weak var photo1: UIImageView!
 	@IBOutlet weak var photo1: UIImageView!
 
 
-	
 	// Album ID
 	// Album ID
 	var id = -1
 	var id = -1
 	
 	
-	// This view
-	var v: UIView!
-	
 	// Array with the imageviews
 	// Array with the imageviews
 	var preview: [UIImageView] = []
 	var preview: [UIImageView] = []
 
 
@@ -54,21 +50,20 @@ Extension of UIView to be formatted as sections.
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first as! UIView
+		nib.instantiate(withOwner: self, options: nil).first
 		
 		
-		v = self
 		self.frame = self.bounds
 		self.frame = self.bounds
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.translatesAutoresizingMaskIntoConstraints = true
 		self.translatesAutoresizingMaskIntoConstraints = true
 		
 		
-		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		container.translatesAutoresizingMaskIntoConstraints = true
+		self.container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.container.translatesAutoresizingMaskIntoConstraints = true
 		
 		
-		container.frame = self.bounds
-		self.addSubview(container)
-
+		self.container.frame = self.bounds
+		self.addSubview(self.container)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor.
 	Default constructor.
 	:param: s Custom identifier
 	:param: s Custom identifier
@@ -79,13 +74,12 @@ Extension of UIView to be formatted as sections.
 		
 		
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()
-		v = self
 		self.frame = self.bounds
 		self.frame = self.bounds
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.translatesAutoresizingMaskIntoConstraints = true
 		self.translatesAutoresizingMaskIntoConstraints = true
 		
 		
 		//Populate review array
 		//Populate review array
-		preview = [photo0, photo1]
+		self.preview = [self.photo0, self.photo1]
 		
 		
 		// Set tap recognizers
 		// Set tap recognizers
 		// TODO
 		// TODO
@@ -108,6 +102,7 @@ Extension of UIView to be formatted as sections.
 		//delegate.controller?.showAlbum(id: self.id)
 		//delegate.controller?.showAlbum(id: self.id)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the preview image of the photos.
 	Changes the preview image of the photos.
 	If null or empty, the igage is hidden.
 	If null or empty, the igage is hidden.
@@ -116,14 +111,12 @@ Extension of UIView to be formatted as sections.
 	*/
 	*/
 	func setImage(idx: Int, filename: String){
 	func setImage(idx: Int, filename: String){
 		if (filename == ""){
 		if (filename == ""){
-			NSLog(":ROWALBUM:DEBUG: No image for album \(self.id) at index \(idx).")
-			preview[idx].isHidden = true
+			self.preview[idx].isHidden = true
 			//TODO hide the imageview
 			//TODO hide the imageview
 		}
 		}
 		else{
 		else{
-			NSLog(":ROWALBUM:DEBUG: Set image \(filename) for at index \(idx).")
 			let path = "img/galeria/thumb/\(filename)"
 			let path = "img/galeria/thumb/\(filename)"
-			preview[idx].setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+			self.preview[idx].setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
 		}
 		}
 	}
 	}
 	
 	

+ 27 - 20
app/RowBlog.swift

@@ -26,9 +26,6 @@ Extension of UIView to be formatted as sections.
 */
 */
 @IBDesignable class RowBlog: UIView {
 @IBDesignable class RowBlog: UIView {
 	
 	
-	//This view
-	var v: UIView!
-	
 	//The container.
 	//The container.
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var container: UIView!
 	
 	
@@ -44,6 +41,7 @@ Extension of UIView to be formatted as sections.
 	//The post image.
 	//The post image.
 	@IBOutlet weak var image: UIImageView!
 	@IBOutlet weak var image: UIImageView!
 	
 	
+	
 	/**
 	/**
 	Default constructor
 	Default constructor
 	*/
 	*/
@@ -51,10 +49,14 @@ Extension of UIView to be formatted as sections.
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	
+	/**
+	Loads the view in the xib file with the same name.
+	*/
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first as! UIView
+		nib.instantiate(withOwner: self, options: nil).first
 	}
 	}
 	
 	
 	/**
 	/**
@@ -65,15 +67,14 @@ Extension of UIView to be formatted as sections.
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()
-		v = self
-		v.frame = bounds
-		v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		v.translatesAutoresizingMaskIntoConstraints = true
-		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		container.translatesAutoresizingMaskIntoConstraints = true
+		self.frame = self.bounds
+		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.translatesAutoresizingMaskIntoConstraints = true
+		self.container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.container.translatesAutoresizingMaskIntoConstraints = true
 		
 		
-		container.frame = v.bounds
-		v.addSubview(container)
+		self.container.frame = self.bounds
+		self.addSubview(self.container)
 		
 		
 		// Set tap recognizer
 		// Set tap recognizer
 		/*print("ROW_BLOG:DEBUG: set tap recognizer")
 		/*print("ROW_BLOG:DEBUG: set tap recognizer")
@@ -82,6 +83,7 @@ Extension of UIView to be formatted as sections.
 		addGestureRecognizer(tapRecognizer)*/
 		addGestureRecognizer(tapRecognizer)*/
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor for the interface builder
 	Default constructor for the interface builder
 	*/
 	*/
@@ -89,24 +91,25 @@ Extension of UIView to be formatted as sections.
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
-
 	
 	
 	/**
 	/**
 	Changes the title of the post. Decodes HTML.
 	Changes the title of the post. Decodes HTML.
 	:param: text The new title.
 	:param: text The new title.
 	*/
 	*/
 	func setTitle(text: String){
 	func setTitle(text: String){
-		title.text = text.decode().stripHtml()
+		self.title.text = text.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the description of the post. Decodes HTML.
 	Changes the description of the post. Decodes HTML.
 	:param: text The new text.
 	:param: text The new text.
 	*/
 	*/
 	func setText(text: String){
 	func setText(text: String){
-		descrip.text = text.decode()
+		self.descrip.text = text.decode()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the image of the post.
 	Changes the image of the post.
 	If null or empty, the igage is hidden.
 	If null or empty, the igage is hidden.
@@ -114,17 +117,21 @@ Extension of UIView to be formatted as sections.
 	*/
 	*/
 	func setImage(filename: String){
 	func setImage(filename: String){
 		if (filename == ""){
 		if (filename == ""){
-			print("No image")
-			//TODO hide the imageview
+			// Hide the imageview
+			self.image.isHidden = true
 		}
 		}
 		else{
 		else{
-			print("Set image \(filename)")
 			let path = "img/blog/thumb/\(filename)"
 			let path = "img/blog/thumb/\(filename)"
-			image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+			self.image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
 		}
 		}
 	}
 	}
 	
 	
+	
+	/**
+	Opens a post.
+	*/
 	func openPost(_ sender:UITapGestureRecognizer? = nil){
 	func openPost(_ sender:UITapGestureRecognizer? = nil){
-		print("ROW_BLOG:DEBUG: openpost")
+		// TODO implement openPost.
+		NSLog(":ROW_BLOG:DEBUG: openpost")
 	}
 	}
 }
 }

+ 6 - 8
app/RowFutureActivity.swift

@@ -25,9 +25,6 @@ import UIKit
 Extension of UIView to be formatted as sections.
 Extension of UIView to be formatted as sections.
 */
 */
 @IBDesignable class RowFutureActivity: UIView {
 @IBDesignable class RowFutureActivity: UIView {
-	
-	//This view
-	var v: UIView!
 
 
 	// Outlets
 	// Outlets
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var container: UIView!
@@ -38,17 +35,21 @@ Extension of UIView to be formatted as sections.
 	@IBOutlet weak var city: UILabel!
 	@IBOutlet weak var city: UILabel!
 	@IBOutlet weak var price: UILabel!
 	@IBOutlet weak var price: UILabel!
 	
 	
+	
 	/**
 	/**
 	Default constructor
 	Default constructor
+	:param: coder Coder.
 	*/
 	*/
 	required init?(coder aDecoder: NSCoder) {
 	required init?(coder aDecoder: NSCoder) {
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	
+	
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first as! UIView
+		nib.instantiate(withOwner: self, options: nil).first
 	}
 	}
 	
 	
 	/**
 	/**
@@ -59,7 +60,6 @@ Extension of UIView to be formatted as sections.
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()
-		v = self
 		self.frame = self.bounds
 		self.frame = self.bounds
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.translatesAutoresizingMaskIntoConstraints = true
 		self.translatesAutoresizingMaskIntoConstraints = true
@@ -128,9 +128,7 @@ Extension of UIView to be formatted as sections.
 	:param: lang Device language.
 	:param: lang Device language.
 	*/
 	*/
 	func setDate(date: NSDate, lang: String){
 	func setDate(date: NSDate, lang: String){
-		
-		let dateformatter = DateFormatter()
-		
+				
 		let months_es = ["0index", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"]
 		let months_es = ["0index", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"]
 		let months_en = ["0index", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
 		let months_en = ["0index", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
 		let months_eu = ["0index", "urtarrilaren", "otsailaren", "martxoaren", "abrilaren", "maiatzaren", "ekainaren", "ustailaren", "abustuaren", "irailaren", "urriaren", "azaroaren", "abenduaren"]
 		let months_eu = ["0index", "urtarrilaren", "otsailaren", "martxoaren", "abrilaren", "maiatzaren", "ekainaren", "ustailaren", "abustuaren", "irailaren", "urriaren", "azaroaren", "abenduaren"]

+ 21 - 19
app/RowGallery.swift

@@ -26,9 +26,6 @@ Extension of UIView to be formatted as sections.
 */
 */
 @IBDesignable class RowGallery: UIView {
 @IBDesignable class RowGallery: UIView {
 	
 	
-	// This view
-	var v: UIView!
-	
 	// Outlets
 	// Outlets
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var title: UILabel!
 	@IBOutlet weak var title: UILabel!
@@ -51,38 +48,38 @@ Extension of UIView to be formatted as sections.
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Loads the view from the xib with the same name as the class.
 	Loads the view from the xib with the same name as the class.
 	*/
 	*/
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first as! UIView
+		nib.instantiate(withOwner: self, options: nil).first
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor.
 	Default constructor.
 	:param: s Custom identifier
 	:param: s Custom identifier
 	:param: i Custom identifier
 	:param: i Custom identifier
 	*/
 	*/
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
-		NSLog(":ROWGALLERY:DEBUG: Init \(s), \(i)")
 		
 		
 		super.init(frame: CGRect(x: 0, y: 0, width: 1000, height: 1000))
 		super.init(frame: CGRect(x: 0, y: 0, width: 1000, height: 1000))
 		loadViewFromNib()
 		loadViewFromNib()
-		v = self
-		v.frame = bounds
-		v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		v.translatesAutoresizingMaskIntoConstraints = true
+		self.frame = self.bounds
+		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.translatesAutoresizingMaskIntoConstraints = true
 		
 		
-		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		container.translatesAutoresizingMaskIntoConstraints = true
+		self.container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.container.translatesAutoresizingMaskIntoConstraints = true
 		
 		
-		container.frame = v.bounds
-		v.addSubview(container)
+		self.container.frame = self.bounds
+		self.addSubview(self.container)
 		
 		
 		//Populate review array
 		//Populate review array
-		preview = [photo0, photo1, photo2, photo3]
+		self.preview = [photo0, photo1, photo2, photo3]
 		
 		
 		// Set tap recognizer
 		// Set tap recognizer
 		let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (RowGallery.openAlbum (_:)))
 		let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (RowGallery.openAlbum (_:)))
@@ -90,6 +87,7 @@ Extension of UIView to be formatted as sections.
 		self.addGestureRecognizer(tapRecognizer)
 		self.addGestureRecognizer(tapRecognizer)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor for the interface builder
 	Default constructor for the interface builder
 	*/
 	*/
@@ -97,20 +95,26 @@ Extension of UIView to be formatted as sections.
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
+	/**
+	Opens an album.
+	*/
 	func openAlbum(_ sender:UITapGestureRecognizer? = nil){
 	func openAlbum(_ sender:UITapGestureRecognizer? = nil){
 		NSLog(":ROW_GALLERY:DEBUG: Getting delegate and showing album \(self.id).")
 		NSLog(":ROW_GALLERY:DEBUG: Getting delegate and showing album \(self.id).")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		delegate.controller?.showAlbum(id: self.id)
 		delegate.controller?.showAlbum(id: self.id)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the title of the album. Decodes HTML.
 	Changes the title of the album. Decodes HTML.
 	:param: text The new title.
 	:param: text The new title.
 	*/
 	*/
 	func setTitle(text: String){
 	func setTitle(text: String){
-		title.text = "  \(text.decode().stripHtml())"
+		self.title.text = "  \(text.decode().stripHtml())"
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the preview image of the album.
 	Changes the preview image of the album.
 	If null or empty, the igage is hidden.
 	If null or empty, the igage is hidden.
@@ -119,13 +123,11 @@ Extension of UIView to be formatted as sections.
 	func setImage(idx: Int, filename: String){
 	func setImage(idx: Int, filename: String){
 		if (filename == ""){
 		if (filename == ""){
 			NSLog(":ROWGALLERY:DEBUG: No image for album \(self.id) at index \(idx).")
 			NSLog(":ROWGALLERY:DEBUG: No image for album \(self.id) at index \(idx).")
-			preview[idx].isHidden = true
-			//TODO hide the imageview
+			self.preview[idx].isHidden = true
 		}
 		}
 		else{
 		else{
-			NSLog(":ROWGALLERY:DEBUG: Set image \(filename) for album \(self.id) at index \(idx).")
 			let path = "img/galeria/thumb/\(filename)"
 			let path = "img/galeria/thumb/\(filename)"
-			preview[idx].setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+			self.preview[idx].setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
 		}
 		}
 	}
 	}
 	
 	

+ 22 - 17
app/RowHomeBlog.swift

@@ -25,10 +25,7 @@ import UIKit
 Extension of UIView to be formatted as sections.
 Extension of UIView to be formatted as sections.
 */
 */
 @IBDesignable class RowHomeBlog: UIView {
 @IBDesignable class RowHomeBlog: UIView {
-	
-	//This view
-	var v: UIView!
-	
+
 	var id: Int!
 	var id: Int!
 	
 	
 	//The container.
 	//The container.
@@ -46,6 +43,7 @@ Extension of UIView to be formatted as sections.
 	//The image.
 	//The image.
 	@IBOutlet weak var image: UIImageView!
 	@IBOutlet weak var image: UIImageView!
 	
 	
+	
 	/**
 	/**
 	Default constructor
 	Default constructor
 	*/
 	*/
@@ -53,12 +51,17 @@ Extension of UIView to be formatted as sections.
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	
+	/**
+	Loads the view in the xib file with the same name.
+	*/
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first as! UIView
+		nib.instantiate(withOwner: self, options: nil).first
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor.
 	Default constructor.
 	:param: s Custom identifier
 	:param: s Custom identifier
@@ -67,17 +70,17 @@ Extension of UIView to be formatted as sections.
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()
-		v = self
-		v.frame = bounds
-		v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		v.translatesAutoresizingMaskIntoConstraints = true
+		self.frame = self.bounds
+		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.translatesAutoresizingMaskIntoConstraints = true
 		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		container.translatesAutoresizingMaskIntoConstraints = true
 		container.translatesAutoresizingMaskIntoConstraints = true
 		
 		
-		container.frame = v.bounds
-		v.addSubview(container)
+		container.frame = self.bounds
+		self.addSubview(container)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor for the interface builder
 	Default constructor for the interface builder
 	*/
 	*/
@@ -85,22 +88,25 @@ Extension of UIView to be formatted as sections.
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the title of the post. Decodes HTML.
 	Changes the title of the post. Decodes HTML.
 	:param: text The new title.
 	:param: text The new title.
 	*/
 	*/
 	func setTitle(text: String){
 	func setTitle(text: String){
-		title.text = text.decode().stripHtml()
+		self.title.text = text.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the text of the text. Decodes HTML.
 	Changes the text of the text. Decodes HTML.
 	:param: text The new text.
 	:param: text The new text.
 	*/
 	*/
 	func setText(text: String){
 	func setText(text: String){
-		descrip.text = text.decode().stripHtml()
+		self.descrip.text = text.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the image of the activity.
 	Changes the image of the activity.
 	If null or empty, the igage is hidden.
 	If null or empty, the igage is hidden.
@@ -108,13 +114,12 @@ Extension of UIView to be formatted as sections.
 	*/
 	*/
 	func setImage(filename: String){
 	func setImage(filename: String){
 		if (filename == ""){
 		if (filename == ""){
-			print("No image")
-			//TODO hide the imageview
+			// Hide the imageview
+			self.image.isHidden = true
 		}
 		}
 		else{
 		else{
-			print("Set image \(filename)")
 			let path = "img/blog/thumb/\(filename)"
 			let path = "img/blog/thumb/\(filename)"
-			image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+			self.image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
 		}
 		}
 	}
 	}
 }
 }

+ 23 - 18
app/RowHomeFutureActivities.swift

@@ -26,9 +26,6 @@ Extension of UIView to be formatted as sections.
 */
 */
 @IBDesignable class RowHomeFutureActivities: UIView {
 @IBDesignable class RowHomeFutureActivities: UIView {
 	
 	
-	//This view
-	var v: UIView!
-	
 	//The container.
 	//The container.
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var container: UIView!
 	
 	
@@ -44,6 +41,7 @@ Extension of UIView to be formatted as sections.
 	//The activity image.
 	//The activity image.
 	@IBOutlet weak var image: UIImageView!
 	@IBOutlet weak var image: UIImageView!
 	
 	
+	
 	/**
 	/**
 	Default constructor
 	Default constructor
 	*/
 	*/
@@ -51,12 +49,17 @@ Extension of UIView to be formatted as sections.
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	
+	/**
+	Loads the view in the xib file with the same name.
+	*/
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first as! UIView
+		nib.instantiate(withOwner: self, options: nil).first
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor.
 	Default constructor.
 	:param: s Custom identifier
 	:param: s Custom identifier
@@ -65,17 +68,17 @@ Extension of UIView to be formatted as sections.
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()
-		v = self
-		v.frame = bounds
-		v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		v.translatesAutoresizingMaskIntoConstraints = true
-		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		container.translatesAutoresizingMaskIntoConstraints = true
+		self.frame = self.bounds
+		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.translatesAutoresizingMaskIntoConstraints = true
+		self.container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.container.translatesAutoresizingMaskIntoConstraints = true
 		
 		
-		container.frame = v.bounds
-		v.addSubview(container)
+		self.container.frame = self.bounds
+		self.addSubview(container)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor for the interface builder
 	Default constructor for the interface builder
 	*/
 	*/
@@ -83,22 +86,25 @@ Extension of UIView to be formatted as sections.
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the title of the activity. Decodes HTML.
 	Changes the title of the activity. Decodes HTML.
 	:param: text The new title.
 	:param: text The new title.
 	*/
 	*/
 	func setTitle(text: String){
 	func setTitle(text: String){
-		title.text = text.decode().stripHtml()
+		self.title.text = text.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the description of the activity. Decodes HTML.
 	Changes the description of the activity. Decodes HTML.
 	:param: text The new text.
 	:param: text The new text.
 	*/
 	*/
 	func setText(text: String){
 	func setText(text: String){
-		descrip.text = text.decode().stripHtml()
+		self.descrip.text = text.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the image of the activity.
 	Changes the image of the activity.
 	If null or empty, the igage is hidden.
 	If null or empty, the igage is hidden.
@@ -106,13 +112,12 @@ Extension of UIView to be formatted as sections.
 	*/
 	*/
 	func setImage(filename: String){
 	func setImage(filename: String){
 		if (filename == ""){
 		if (filename == ""){
-			print("No image")
-			//TODO hide the imageview
+			// Hide the imageview
+			self.image.isHidden = true
 		}
 		}
 		else{
 		else{
-			print("Set image \(filename)")
 			let path = "img/actividades/thumb/\(filename)"
 			let path = "img/actividades/thumb/\(filename)"
-			image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+			self.image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
 		}
 		}
 	}
 	}
 }
 }

+ 12 - 17
app/RowHomeGallery.swift

@@ -26,9 +26,6 @@ Extension of UIView to be formatted as sections.
 */
 */
 @IBDesignable class RowHomeGallery: UIView {
 @IBDesignable class RowHomeGallery: UIView {
 	
 	
-	//This view
-	var v: UIView!
-	
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var photo0: UIImageView!
 	@IBOutlet weak var photo0: UIImageView!
 	@IBOutlet weak var photo1: UIImageView!
 	@IBOutlet weak var photo1: UIImageView!
@@ -37,6 +34,7 @@ Extension of UIView to be formatted as sections.
 	
 	
 	var photos: [UIImageView] = []
 	var photos: [UIImageView] = []
 	
 	
+	
 	/**
 	/**
 	Default constructor
 	Default constructor
 	*/
 	*/
@@ -44,12 +42,17 @@ Extension of UIView to be formatted as sections.
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	
+	/**
+	Loads the view in the xib file with the same name.
+	*/
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		nib.instantiate(withOwner: self, options: nil).first as! UIView
 		nib.instantiate(withOwner: self, options: nil).first as! UIView
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor.
 	Default constructor.
 	:param: s Custom identifier
 	:param: s Custom identifier
@@ -58,24 +61,15 @@ Extension of UIView to be formatted as sections.
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()
-		v = self
-		//v.frame = bounds
-		//v.bounds = v.frame
-		//v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		//v.translatesAutoresizingMaskIntoConstraints = true
-		//container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		//container.translatesAutoresizingMaskIntoConstraints = true
-		
-		//container.frame = v.bounds
-		v.addSubview(container)
+		self.addSubview(self.container)
 		
 		
-		photos = [photo0, photo1, photo2, photo3]
+		self.photos = [photo0, photo1, photo2, photo3]
 		
 		
 
 
-		
 		//TODO Set click listeners
 		//TODO Set click listeners
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor for the interface builder
 	Default constructor for the interface builder
 	*/
 	*/
@@ -83,6 +77,7 @@ Extension of UIView to be formatted as sections.
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the preview image.
 	Changes the preview image.
 	If null or empty, the igage is hidden.
 	If null or empty, the igage is hidden.
@@ -90,8 +85,8 @@ Extension of UIView to be formatted as sections.
 	*/
 	*/
 	func setImage(idx: Int, filename: String){
 	func setImage(idx: Int, filename: String){
 		if (filename == ""){
 		if (filename == ""){
-			print("ROWHOMEGALLERY:LOG: No image.")
-			//TODO hide the imageview
+			// Hide the imageview
+			self.photos[idx].isHidden = true
 		}
 		}
 		else{
 		else{
 			let path = "img/galeria/thumb/\(filename)"
 			let path = "img/galeria/thumb/\(filename)"

+ 23 - 18
app/RowHomePastActivities.swift

@@ -26,9 +26,6 @@ Extension of UIView to be formatted as sections.
 */
 */
 @IBDesignable class RowHomePastActivities: UIView {
 @IBDesignable class RowHomePastActivities: UIView {
 	
 	
-	//This view
-	var v: UIView!
-	
 	//The container.
 	//The container.
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var container: UIView!
 	
 	
@@ -44,6 +41,7 @@ Extension of UIView to be formatted as sections.
 	//The activity image.
 	//The activity image.
 	@IBOutlet weak var image: UIImageView!
 	@IBOutlet weak var image: UIImageView!
 	
 	
+	
 	/**
 	/**
 	Default constructor
 	Default constructor
 	*/
 	*/
@@ -51,12 +49,17 @@ Extension of UIView to be formatted as sections.
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	
+	/**
+	Loads the view in the xib file with the same name.
+	*/
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first as! UIView
+		nib.instantiate(withOwner: self, options: nil).first
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor.
 	Default constructor.
 	:param: s Custom identifier
 	:param: s Custom identifier
@@ -65,17 +68,17 @@ Extension of UIView to be formatted as sections.
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()
-		v = self
-		v.frame = bounds
-		v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		v.translatesAutoresizingMaskIntoConstraints = true
-		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		container.translatesAutoresizingMaskIntoConstraints = true
+		self.frame = self.bounds
+		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.translatesAutoresizingMaskIntoConstraints = true
+		self.container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.container.translatesAutoresizingMaskIntoConstraints = true
 
 
-		container.frame = v.bounds
-		v.addSubview(container)
+		self.container.frame = self.bounds
+		self.addSubview(container)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor for the interface builder
 	Default constructor for the interface builder
 	*/
 	*/
@@ -83,22 +86,25 @@ Extension of UIView to be formatted as sections.
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the title of the activity. Decodes HTML.
 	Changes the title of the activity. Decodes HTML.
 	:param: text The new title.
 	:param: text The new title.
 	*/
 	*/
 	func setTitle(text: String){
 	func setTitle(text: String){
-		title.text = text.decode().stripHtml()
+		self.title.text = text.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the description of the activity. Decodes HTML.
 	Changes the description of the activity. Decodes HTML.
 	:param: text The new text.
 	:param: text The new text.
 	*/
 	*/
 	func setText(text: String){
 	func setText(text: String){
-		descrip.text = text.decode().stripHtml()
+		self.descrip.text = text.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the image of the activity.
 	Changes the image of the activity.
 	If null or empty, the igage is hidden.
 	If null or empty, the igage is hidden.
@@ -106,13 +112,12 @@ Extension of UIView to be formatted as sections.
 	*/
 	*/
 	func setImage(filename: String){
 	func setImage(filename: String){
 		if (filename == ""){
 		if (filename == ""){
-			print("No image")
-			//TODO hide the imageview
+			// Hide the imageview
+			self.image.isHidden = true
 		}
 		}
 		else{
 		else{
-			print("Set image \(filename)")
 			let path = "img/actividades/thumb/\(filename)"
 			let path = "img/actividades/thumb/\(filename)"
-			image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+			self.image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
 		}
 		}
 	}
 	}
 }
 }

+ 53 - 24
app/RowHomeSocial.swift

@@ -25,10 +25,7 @@ import UIKit
 Extension of UIView to be formatted as sections.
 Extension of UIView to be formatted as sections.
 */
 */
 @IBDesignable class RowHomeSocial: UIView {
 @IBDesignable class RowHomeSocial: UIView {
-	
-	//This view
-	var v: UIView!
-	
+
 	//The container.
 	//The container.
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var container: UIView!
 	
 	
@@ -45,6 +42,7 @@ Extension of UIView to be formatted as sections.
 	@IBOutlet weak var btnYoutube: UIImageView!
 	@IBOutlet weak var btnYoutube: UIImageView!
 	@IBOutlet weak var btnInstagram: UIImageView!
 	@IBOutlet weak var btnInstagram: UIImageView!
 	
 	
+	
 	/**
 	/**
 	Default constructor
 	Default constructor
 	*/
 	*/
@@ -52,14 +50,13 @@ Extension of UIView to be formatted as sections.
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	/**
+	Loads the view in the xib file with the same name.
+	*/
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
-		print("LOADING NIB...")
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
-		print("GOT BUNDLE...")
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		print("NIB CREATED")
-		nib.instantiate(withOwner: self, options: nil).first as! UIView
-		print("NIB INSTANTIATED")
+		nib.instantiate(withOwner: self, options: nil).first
 	}
 	}
 	
 	
 	/**
 	/**
@@ -70,15 +67,14 @@ Extension of UIView to be formatted as sections.
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()
-		v = self
-		v.frame = bounds
-		v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		v.translatesAutoresizingMaskIntoConstraints = true
-		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		container.translatesAutoresizingMaskIntoConstraints = true
+		self.frame = self.bounds
+		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.translatesAutoresizingMaskIntoConstraints = true
+		self.container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.container.translatesAutoresizingMaskIntoConstraints = true
 		
 		
-		container.frame = v.bounds
-		v.addSubview(container)
+		self.container.frame = self.bounds
+		self.addSubview(container)
 		
 		
 		// Set buttons up
 		// Set buttons up
 		let phoneTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapPhone))
 		let phoneTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapPhone))
@@ -109,42 +105,75 @@ Extension of UIView to be formatted as sections.
 	
 	
 	/**
 	/**
 	Default constructor for the interface builder
 	Default constructor for the interface builder
+	:param: frame View frame.
 	*/
 	*/
 	override init(frame: CGRect){
 	override init(frame: CGRect){
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
+	/**
+	Called when the phone button is tapped.
+	*/
 	func didTapPhone() {
 	func didTapPhone() {
-		UIApplication.shared.openURL(NSURL(string: "tel://+34637140371") as! URL)
+		UIApplication.shared.openURL(NSURL(string: "tel://+34637140371")! as URL)
 	}
 	}
 	
 	
+	
+	/**
+	Called when the mail button is tapped.
+	*/
 	func didTapMail() {
 	func didTapMail() {
-		UIApplication.shared.openURL(NSURL(string: "mailto:gasteizkomargolariak@gmail.com") as! URL)
+		UIApplication.shared.openURL(NSURL(string: "mailto:gasteizkomargolariak@gmail.com")! as URL)
 	}
 	}
 	
 	
+	
+	/**
+	Called when the Whatsapp button is tapped.
+	*/
 	func didTapWhatsapp() {
 	func didTapWhatsapp() {
 		//As of today, imposible
 		//As of today, imposible
 		//UIApplication.shared.openURL(NSURL(string: "+34637140371") as! URL)
 		//UIApplication.shared.openURL(NSURL(string: "+34637140371") as! URL)
 	}
 	}
 	
 	
+	
+	/**
+	Called when the Facebook button is tapped.
+	*/
 	func didTapFacebook() {
 	func didTapFacebook() {
-		UIApplication.shared.openURL(NSURL(string: "http://facebook.com/gmargolariak") as! URL)
+		UIApplication.shared.openURL(NSURL(string: "http://facebook.com/gmargolariak")! as URL)
 	}
 	}
 	
 	
+	
+	/**
+	Called when the Twitter button is tapped.
+	*/
 	func didTapTwitter() {
 	func didTapTwitter() {
-		UIApplication.shared.openURL(NSURL(string: "http://twitter.com/gmargolariak") as! URL)
+		UIApplication.shared.openURL(NSURL(string: "http://twitter.com/gmargolariak")! as URL)
 	}
 	}
 	
 	
+	
+	/**
+	Called when the G+ button is tapped.
+	*/
 	func didTapGoogle() {
 	func didTapGoogle() {
-		UIApplication.shared.openURL(NSURL(string: "https://plus.google.com/106661466029005469492") as! URL)
+		UIApplication.shared.openURL(NSURL(string: "https://plus.google.com/106661466029005469492")! as URL)
 	}
 	}
 	
 	
+	
+	/**
+	Called when the Youtube button is tapped.
+	*/
 	func didTapYoutube() {
 	func didTapYoutube() {
-		UIApplication.shared.openURL(NSURL(string: "https://www.youtube.com/user/GasteizkoMargolariak") as! URL)
+		UIApplication.shared.openURL(NSURL(string: "https://www.youtube.com/user/GasteizkoMargolariak")! as URL)
 	}
 	}
 	
 	
+	
+	/**
+	Called when the Instagram button is tapped.
+	*/
 	func didTapInstagram() {
 	func didTapInstagram() {
-		UIApplication.shared.openURL(NSURL(string: "https://instagram.com/gmargolariak/") as! URL)
+		UIApplication.shared.openURL(NSURL(string: "https://instagram.com/gmargolariak/")! as URL)
 	}
 	}
 	
 	
 	
 	

+ 30 - 30
app/RowHomeSocial.xib

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
         <adaptation id="fullscreen"/>
     </device>
     </device>
     <dependencies>
     <dependencies>
         <deployment identifier="iOS"/>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
         <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
         <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
         <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
         <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -37,66 +37,66 @@
                             <rect key="frame" x="10" y="10" width="355" height="177.5"/>
                             <rect key="frame" x="10" y="10" width="355" height="177.5"/>
                             <subviews>
                             <subviews>
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Phone" translatesAutoresizingMaskIntoConstraints="NO" id="512-B2-6nt">
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Phone" translatesAutoresizingMaskIntoConstraints="NO" id="512-B2-6nt">
-                                    <rect key="frame" x="0.0" y="0.0" width="89.5" height="89.5"/>
+                                    <rect key="frame" x="7" y="7" width="75" height="75"/>
                                 </imageView>
                                 </imageView>
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Mail" translatesAutoresizingMaskIntoConstraints="NO" id="5Xa-Sh-XrB" userLabel="Mail">
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Mail" translatesAutoresizingMaskIntoConstraints="NO" id="5Xa-Sh-XrB" userLabel="Mail">
-                                    <rect key="frame" x="89.5" y="0.0" width="89" height="89.5"/>
+                                    <rect key="frame" x="96" y="7" width="75" height="75"/>
                                     <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
                                     <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
                                 </imageView>
                                 </imageView>
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Whatsapp" translatesAutoresizingMaskIntoConstraints="NO" id="0jq-K4-utG" userLabel="Whatsapp">
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Whatsapp" translatesAutoresizingMaskIntoConstraints="NO" id="0jq-K4-utG" userLabel="Whatsapp">
-                                    <rect key="frame" x="179" y="0.0" width="89" height="89"/>
+                                    <rect key="frame" x="185" y="7" width="75" height="75"/>
                                     <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
                                     <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
                                 </imageView>
                                 </imageView>
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Facebook" translatesAutoresizingMaskIntoConstraints="NO" id="wP8-1o-Rrh" userLabel="Facebook">
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Facebook" translatesAutoresizingMaskIntoConstraints="NO" id="wP8-1o-Rrh" userLabel="Facebook">
-                                    <rect key="frame" x="268" y="0.0" width="89" height="89"/>
+                                    <rect key="frame" x="274" y="7" width="75" height="75"/>
                                     <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
                                     <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
                                 </imageView>
                                 </imageView>
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Twitter" translatesAutoresizingMaskIntoConstraints="NO" id="Ttk-Ce-1XP">
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Twitter" translatesAutoresizingMaskIntoConstraints="NO" id="Ttk-Ce-1XP">
-                                    <rect key="frame" x="0.0" y="90" width="89.5" height="89.5"/>
+                                    <rect key="frame" x="7" y="96" width="75" height="74.5"/>
                                 </imageView>
                                 </imageView>
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="GooglePlus" translatesAutoresizingMaskIntoConstraints="NO" id="L4k-eK-pkc">
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="GooglePlus" translatesAutoresizingMaskIntoConstraints="NO" id="L4k-eK-pkc">
-                                    <rect key="frame" x="90" y="90" width="89.5" height="89.5"/>
+                                    <rect key="frame" x="96.5" y="96" width="75.5" height="74.5"/>
                                 </imageView>
                                 </imageView>
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Youtube" translatesAutoresizingMaskIntoConstraints="NO" id="1qd-jG-4Bn">
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Youtube" translatesAutoresizingMaskIntoConstraints="NO" id="1qd-jG-4Bn">
-                                    <rect key="frame" x="179" y="89" width="89.5" height="89.5"/>
+                                    <rect key="frame" x="185" y="96" width="75.5" height="75"/>
                                 </imageView>
                                 </imageView>
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Instagram" translatesAutoresizingMaskIntoConstraints="NO" id="OlS-ga-Ngl">
                                 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Instagram" translatesAutoresizingMaskIntoConstraints="NO" id="OlS-ga-Ngl">
-                                    <rect key="frame" x="268" y="89" width="89.5" height="89.5"/>
+                                    <rect key="frame" x="274" y="96" width="75.5" height="75"/>
                                 </imageView>
                                 </imageView>
                             </subviews>
                             </subviews>
                             <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
                             <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
                             <constraints>
                             <constraints>
                                 <constraint firstItem="Ttk-Ce-1XP" firstAttribute="width" secondItem="512-B2-6nt" secondAttribute="width" id="0QX-sh-Y62"/>
                                 <constraint firstItem="Ttk-Ce-1XP" firstAttribute="width" secondItem="512-B2-6nt" secondAttribute="width" id="0QX-sh-Y62"/>
                                 <constraint firstItem="Ttk-Ce-1XP" firstAttribute="height" secondItem="512-B2-6nt" secondAttribute="height" id="39L-QV-csw"/>
                                 <constraint firstItem="Ttk-Ce-1XP" firstAttribute="height" secondItem="512-B2-6nt" secondAttribute="height" id="39L-QV-csw"/>
-                                <constraint firstItem="wP8-1o-Rrh" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" id="3xb-00-2P6"/>
-                                <constraint firstItem="5Xa-Sh-XrB" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="7T1-Hk-R35"/>
-                                <constraint firstItem="Ttk-Ce-1XP" firstAttribute="top" secondItem="512-B2-6nt" secondAttribute="bottom" id="9F0-DU-FFO"/>
-                                <constraint firstItem="0jq-K4-utG" firstAttribute="leading" secondItem="5Xa-Sh-XrB" secondAttribute="trailing" id="AH1-0L-nYQ"/>
+                                <constraint firstItem="wP8-1o-Rrh" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="7" id="3xb-00-2P6"/>
+                                <constraint firstItem="5Xa-Sh-XrB" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" constant="-14" id="7T1-Hk-R35"/>
+                                <constraint firstItem="Ttk-Ce-1XP" firstAttribute="top" secondItem="512-B2-6nt" secondAttribute="bottom" constant="14" id="9F0-DU-FFO"/>
+                                <constraint firstItem="0jq-K4-utG" firstAttribute="leading" secondItem="5Xa-Sh-XrB" secondAttribute="trailing" constant="14" id="AH1-0L-nYQ"/>
                                 <constraint firstItem="1qd-jG-4Bn" firstAttribute="height" secondItem="0jq-K4-utG" secondAttribute="height" id="CUC-LH-oVM"/>
                                 <constraint firstItem="1qd-jG-4Bn" firstAttribute="height" secondItem="0jq-K4-utG" secondAttribute="height" id="CUC-LH-oVM"/>
-                                <constraint firstItem="wP8-1o-Rrh" firstAttribute="leading" secondItem="0jq-K4-utG" secondAttribute="trailing" id="IM6-dv-FSu"/>
+                                <constraint firstItem="wP8-1o-Rrh" firstAttribute="leading" secondItem="0jq-K4-utG" secondAttribute="trailing" constant="14" id="IM6-dv-FSu"/>
                                 <constraint firstItem="L4k-eK-pkc" firstAttribute="height" secondItem="5Xa-Sh-XrB" secondAttribute="height" id="IWg-0Z-7tO"/>
                                 <constraint firstItem="L4k-eK-pkc" firstAttribute="height" secondItem="5Xa-Sh-XrB" secondAttribute="height" id="IWg-0Z-7tO"/>
-                                <constraint firstItem="L4k-eK-pkc" firstAttribute="top" secondItem="5Xa-Sh-XrB" secondAttribute="bottom" id="Jf9-UI-kn3"/>
+                                <constraint firstItem="L4k-eK-pkc" firstAttribute="top" secondItem="5Xa-Sh-XrB" secondAttribute="bottom" constant="14" id="Jf9-UI-kn3"/>
                                 <constraint firstItem="L4k-eK-pkc" firstAttribute="leading" secondItem="5Xa-Sh-XrB" secondAttribute="leading" id="Lkg-Ff-jNA"/>
                                 <constraint firstItem="L4k-eK-pkc" firstAttribute="leading" secondItem="5Xa-Sh-XrB" secondAttribute="leading" id="Lkg-Ff-jNA"/>
-                                <constraint firstItem="wP8-1o-Rrh" firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="Lyv-es-d3j"/>
-                                <constraint firstItem="512-B2-6nt" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="MYA-FO-b5k"/>
-                                <constraint firstItem="1qd-jG-4Bn" firstAttribute="top" secondItem="0jq-K4-utG" secondAttribute="bottom" id="QMP-Gi-WCw"/>
-                                <constraint firstItem="0jq-K4-utG" firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="RPd-iR-02y"/>
-                                <constraint firstItem="512-B2-6nt" firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="Z1m-CY-xaF"/>
-                                <constraint firstItem="5Xa-Sh-XrB" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" id="aFU-bQ-Y2T"/>
+                                <constraint firstItem="wP8-1o-Rrh" firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" constant="-14" id="Lyv-es-d3j"/>
+                                <constraint firstItem="512-B2-6nt" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" constant="-14" id="MYA-FO-b5k"/>
+                                <constraint firstItem="1qd-jG-4Bn" firstAttribute="top" secondItem="0jq-K4-utG" secondAttribute="bottom" constant="14" id="QMP-Gi-WCw"/>
+                                <constraint firstItem="0jq-K4-utG" firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" constant="-14" id="RPd-iR-02y"/>
+                                <constraint firstItem="512-B2-6nt" firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" constant="-14" id="Z1m-CY-xaF"/>
+                                <constraint firstItem="5Xa-Sh-XrB" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="7" id="aFU-bQ-Y2T"/>
                                 <constraint firstItem="OlS-ga-Ngl" firstAttribute="leading" secondItem="wP8-1o-Rrh" secondAttribute="leading" id="aGq-AJ-HXg"/>
                                 <constraint firstItem="OlS-ga-Ngl" firstAttribute="leading" secondItem="wP8-1o-Rrh" secondAttribute="leading" id="aGq-AJ-HXg"/>
-                                <constraint firstItem="5Xa-Sh-XrB" firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="agd-tD-Z7B"/>
+                                <constraint firstItem="5Xa-Sh-XrB" firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" constant="-14" id="agd-tD-Z7B"/>
                                 <constraint firstItem="L4k-eK-pkc" firstAttribute="width" secondItem="5Xa-Sh-XrB" secondAttribute="width" id="bD5-gc-RZQ"/>
                                 <constraint firstItem="L4k-eK-pkc" firstAttribute="width" secondItem="5Xa-Sh-XrB" secondAttribute="width" id="bD5-gc-RZQ"/>
                                 <constraint firstItem="OlS-ga-Ngl" firstAttribute="width" secondItem="wP8-1o-Rrh" secondAttribute="width" id="bil-4K-d7f"/>
                                 <constraint firstItem="OlS-ga-Ngl" firstAttribute="width" secondItem="wP8-1o-Rrh" secondAttribute="width" id="bil-4K-d7f"/>
                                 <constraint firstItem="Ttk-Ce-1XP" firstAttribute="leading" secondItem="512-B2-6nt" secondAttribute="leading" id="fMj-Zv-80b"/>
                                 <constraint firstItem="Ttk-Ce-1XP" firstAttribute="leading" secondItem="512-B2-6nt" secondAttribute="leading" id="fMj-Zv-80b"/>
-                                <constraint firstItem="wP8-1o-Rrh" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="gjG-xf-f2v"/>
-                                <constraint firstItem="5Xa-Sh-XrB" firstAttribute="leading" secondItem="512-B2-6nt" secondAttribute="trailing" id="iay-5b-e6B"/>
+                                <constraint firstItem="wP8-1o-Rrh" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" constant="-14" id="gjG-xf-f2v"/>
+                                <constraint firstItem="5Xa-Sh-XrB" firstAttribute="leading" secondItem="512-B2-6nt" secondAttribute="trailing" constant="14" id="iay-5b-e6B"/>
                                 <constraint firstItem="1qd-jG-4Bn" firstAttribute="width" secondItem="0jq-K4-utG" secondAttribute="width" id="jDu-hC-arJ"/>
                                 <constraint firstItem="1qd-jG-4Bn" firstAttribute="width" secondItem="0jq-K4-utG" secondAttribute="width" id="jDu-hC-arJ"/>
                                 <constraint firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.5" id="jGP-1G-1P3"/>
                                 <constraint firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.5" id="jGP-1G-1P3"/>
-                                <constraint firstItem="512-B2-6nt" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" id="lyN-c0-DOH"/>
-                                <constraint firstItem="0jq-K4-utG" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" id="nUV-gk-zhw"/>
-                                <constraint firstItem="0jq-K4-utG" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="uCp-Vv-c61"/>
-                                <constraint firstItem="OlS-ga-Ngl" firstAttribute="top" secondItem="wP8-1o-Rrh" secondAttribute="bottom" id="vCU-hL-wuO"/>
-                                <constraint firstItem="512-B2-6nt" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" id="wMJ-K2-1e9"/>
+                                <constraint firstItem="512-B2-6nt" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="7" id="lyN-c0-DOH"/>
+                                <constraint firstItem="0jq-K4-utG" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="7" id="nUV-gk-zhw"/>
+                                <constraint firstItem="0jq-K4-utG" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" constant="-14" id="uCp-Vv-c61"/>
+                                <constraint firstItem="OlS-ga-Ngl" firstAttribute="top" secondItem="wP8-1o-Rrh" secondAttribute="bottom" constant="14" id="vCU-hL-wuO"/>
+                                <constraint firstItem="512-B2-6nt" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" constant="7" id="wMJ-K2-1e9"/>
                                 <constraint firstItem="OlS-ga-Ngl" firstAttribute="height" secondItem="wP8-1o-Rrh" secondAttribute="height" id="xZ5-XM-Ixz"/>
                                 <constraint firstItem="OlS-ga-Ngl" firstAttribute="height" secondItem="wP8-1o-Rrh" secondAttribute="height" id="xZ5-XM-Ixz"/>
                                 <constraint firstItem="1qd-jG-4Bn" firstAttribute="leading" secondItem="0jq-K4-utG" secondAttribute="leading" id="zfP-9S-Gfc"/>
                                 <constraint firstItem="1qd-jG-4Bn" firstAttribute="leading" secondItem="0jq-K4-utG" secondAttribute="leading" id="zfP-9S-Gfc"/>
                             </constraints>
                             </constraints>

+ 13 - 9
app/RowLabel.swift

@@ -25,14 +25,13 @@ import UIKit
 Extension of UIView to be formatted as sections.
 Extension of UIView to be formatted as sections.
 */
 */
 @IBDesignable class RowLabel: UIView {
 @IBDesignable class RowLabel: UIView {
-	
-	//This view
-	var v: UIView!
+
 	
 	
 	// Outlets
 	// Outlets
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var text: UILabel!
 	@IBOutlet weak var text: UILabel!
 	
 	
+	
 	/**
 	/**
 	Default constructor
 	Default constructor
 	*/
 	*/
@@ -40,12 +39,17 @@ Extension of UIView to be formatted as sections.
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	
+	/**
+	Loads the view from the xib with the same name as the class.
+	*/
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first as! UIView
+		nib.instantiate(withOwner: self, options: nil).first
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor.
 	Default constructor.
 	:param: s Custom identifier
 	:param: s Custom identifier
@@ -54,17 +58,17 @@ Extension of UIView to be formatted as sections.
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()
-		v = self
 		self.frame = self.bounds
 		self.frame = self.bounds
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.translatesAutoresizingMaskIntoConstraints = true
 		self.translatesAutoresizingMaskIntoConstraints = true
-		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		container.translatesAutoresizingMaskIntoConstraints = true
+		self.container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.container.translatesAutoresizingMaskIntoConstraints = true
 		
 		
-		container.frame = self.bounds
-		self.addSubview(container)
+		self.container.frame = self.bounds
+		self.addSubview(self.container)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor for the interface builder
 	Default constructor for the interface builder
 	*/
 	*/

+ 17 - 6
app/RowLablancaDay.swift

@@ -34,6 +34,7 @@ Extension of UIView to be formatted as sections.
 	@IBOutlet weak var price: UILabel!
 	@IBOutlet weak var price: UILabel!
 	@IBOutlet weak var separator: UIView!
 	@IBOutlet weak var separator: UIView!
 	
 	
+	
 	/**
 	/**
 	Default constructor
 	Default constructor
 	*/
 	*/
@@ -41,33 +42,34 @@ Extension of UIView to be formatted as sections.
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Loads the view from the xib with the same name as the class.
 	Loads the view from the xib with the same name as the class.
 	*/
 	*/
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first as! UIView
+		nib.instantiate(withOwner: self, options: nil).first
 		
 		
 		self.frame = self.bounds
 		self.frame = self.bounds
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.translatesAutoresizingMaskIntoConstraints = true
 		self.translatesAutoresizingMaskIntoConstraints = true
 		
 		
-		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		container.translatesAutoresizingMaskIntoConstraints = true
+		self.container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.container.translatesAutoresizingMaskIntoConstraints = true
 		
 		
-		container.frame = self.bounds
-		self.addSubview(container)
+		self.container.frame = self.bounds
+		self.addSubview(self.container)
 		
 		
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor.
 	Default constructor.
 	:param: s Custom identifier
 	:param: s Custom identifier
 	:param: i Custom identifier
 	:param: i Custom identifier
 	*/
 	*/
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
-		NSLog(":ROWLABLANCADAY:DEBUG: Init \(s), \(i)")
 		
 		
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()
@@ -76,6 +78,7 @@ Extension of UIView to be formatted as sections.
 		self.translatesAutoresizingMaskIntoConstraints = true
 		self.translatesAutoresizingMaskIntoConstraints = true
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor for the interface builder
 	Default constructor for the interface builder
 	*/
 	*/
@@ -83,6 +86,14 @@ Extension of UIView to be formatted as sections.
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
+	/**
+	Sets the info about the day.
+	:param: number Number of the day (1-31)
+	:param: month Name of the month.
+	:param: name Name of the day.
+	:param: price Price of the day, in euros.
+	*/
 	func setDay(number: Int, month: String, name: String, price: Int){
 	func setDay(number: Int, month: String, name: String, price: Int){
 		self.number.text = "\(Int(number))"
 		self.number.text = "\(Int(number))"
 		self.month.text = month.decode().stripHtml()
 		self.month.text = month.decode().stripHtml()

+ 9 - 11
app/RowLablancaOffer.swift

@@ -27,20 +27,12 @@ Extension of UIView to be formatted as sections.
 @IBDesignable class RowLablancaOffer: UIView {
 @IBDesignable class RowLablancaOffer: UIView {
 	
 	
 	// Outlets
 	// Outlets
-	/*@IBOutlet weak var container: UIView!
-	@IBOutlet weak var number: UILabel!
-	@IBOutlet weak var month: UILabel!
-	@IBOutlet weak var name: UILabel!
-	@IBOutlet weak var price: UILabel!
-	@IBOutlet weak var separator: UIView!*/
 	@IBOutlet weak var vwContainer: UIView!
 	@IBOutlet weak var vwContainer: UIView!
 	@IBOutlet weak var lbName: UILabel!
 	@IBOutlet weak var lbName: UILabel!
 	@IBOutlet weak var lbDescription: UILabel!
 	@IBOutlet weak var lbDescription: UILabel!
 	@IBOutlet weak var lbPrice: UILabel!
 	@IBOutlet weak var lbPrice: UILabel!
 	@IBOutlet weak var vwSeparator: UIView!
 	@IBOutlet weak var vwSeparator: UIView!
-	
-	
-	
+
 	
 	
 	/**
 	/**
 	Default constructor
 	Default constructor
@@ -49,13 +41,14 @@ Extension of UIView to be formatted as sections.
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Loads the view from the xib with the same name as the class.
 	Loads the view from the xib with the same name as the class.
 	*/
 	*/
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first as! UIView
+		nib.instantiate(withOwner: self, options: nil).first
 		
 		
 		self.frame = self.bounds
 		self.frame = self.bounds
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
@@ -66,9 +59,9 @@ Extension of UIView to be formatted as sections.
 		
 		
 		self.vwContainer.frame = self.bounds
 		self.vwContainer.frame = self.bounds
 		self.addSubview(self.vwContainer)
 		self.addSubview(self.vwContainer)
-		
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor.
 	Default constructor.
 	:param: s Custom identifier
 	:param: s Custom identifier
@@ -84,6 +77,7 @@ Extension of UIView to be formatted as sections.
 		self.translatesAutoresizingMaskIntoConstraints = true
 		self.translatesAutoresizingMaskIntoConstraints = true
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor for the interface builder
 	Default constructor for the interface builder
 	*/
 	*/
@@ -91,6 +85,7 @@ Extension of UIView to be formatted as sections.
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Sets the name of the offer.
 	Sets the name of the offer.
 	:param: name The name of the offer.
 	:param: name The name of the offer.
@@ -99,6 +94,7 @@ Extension of UIView to be formatted as sections.
 		self.lbName.text = name.decode().stripHtml()
 		self.lbName.text = name.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Sets the description of the offer.
 	Sets the description of the offer.
 	:param: description The description of the offer.
 	:param: description The description of the offer.
@@ -107,6 +103,7 @@ Extension of UIView to be formatted as sections.
 		self.lbDescription.text = description.decode().stripHtml()
 		self.lbDescription.text = description.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Sets the price of the offer.
 	Sets the price of the offer.
 	:param: price The description of the offer.
 	:param: price The description of the offer.
@@ -115,6 +112,7 @@ Extension of UIView to be formatted as sections.
 		self.lbPrice.text = "\(price) €"
 		self.lbPrice.text = "\(price) €"
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Hiddes the separator bar.
 	Hiddes the separator bar.
 	*/
 	*/

+ 22 - 12
app/RowPastActivity.swift

@@ -42,12 +42,17 @@ Extension of UIView to be formatted as sections.
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	
+	/**
+	Loads the view from the xib with the same name as the class.
+	*/
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first as! UIView
+		nib.instantiate(withOwner: self, options: nil).first
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor.
 	Default constructor.
 	:param: s Custom identifier
 	:param: s Custom identifier
@@ -56,15 +61,14 @@ Extension of UIView to be formatted as sections.
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()
-		v = self
 		self.frame = self.bounds
 		self.frame = self.bounds
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.translatesAutoresizingMaskIntoConstraints = true
 		self.translatesAutoresizingMaskIntoConstraints = true
-		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		container.translatesAutoresizingMaskIntoConstraints = true
+		self.container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.container.translatesAutoresizingMaskIntoConstraints = true
 		
 		
-		container.frame = self.bounds
-		self.addSubview(container)
+		self.container.frame = self.bounds
+		self.addSubview(self.container)
 		
 		
 		// Set tap recognizer
 		// Set tap recognizer
 		/*print("ROW_PAST_ACTIVITY:DEBUG: set tap recognizer")
 		/*print("ROW_PAST_ACTIVITY:DEBUG: set tap recognizer")
@@ -73,6 +77,7 @@ Extension of UIView to be formatted as sections.
 		addGestureRecognizer(tapRecognizer)*/
 		addGestureRecognizer(tapRecognizer)*/
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor for the interface builder
 	Default constructor for the interface builder
 	*/
 	*/
@@ -81,23 +86,24 @@ Extension of UIView to be formatted as sections.
 	}
 	}
 	
 	
 	
 	
-	
 	/**
 	/**
 	Changes the title of the activity. Decodes HTML.
 	Changes the title of the activity. Decodes HTML.
 	:param: text The new title.
 	:param: text The new title.
 	*/
 	*/
 	func setTitle(text: String){
 	func setTitle(text: String){
-		title.text = text.decode().stripHtml()
+		self.title.text = text.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the description of the activity. Decodes HTML.
 	Changes the description of the activity. Decodes HTML.
 	:param: text The new text.
 	:param: text The new text.
 	*/
 	*/
 	func setText(text: String){
 	func setText(text: String){
-		descript.text = text.decode().stripHtml()
+		self.descript.text = text.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Changes the image of the activity.
 	Changes the image of the activity.
 	If null or empty, the igage is hidden.
 	If null or empty, the igage is hidden.
@@ -105,17 +111,21 @@ Extension of UIView to be formatted as sections.
 	*/
 	*/
 	func setImage(filename: String){
 	func setImage(filename: String){
 		if (filename == ""){
 		if (filename == ""){
-			NSLog("ROW_PAST_ACTIVITY:DEBUG: No image")
-			//TODO hide the imageview
+			// Hide the imageview
+			self.image.isHidden = true
 		}
 		}
 		else{
 		else{
-			NSLog(":ROW_PAST_ACTIVITY:DEBUG: Set image \(filename)")
 			let path = "img/actividades/thumb/\(filename)"
 			let path = "img/actividades/thumb/\(filename)"
 			image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
 			image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
 		}
 		}
 	}
 	}
 	
 	
+	
+	/**
+	Opens an activity.
+	*/
 	func openActivity(_ sender:UITapGestureRecognizer? = nil){
 	func openActivity(_ sender:UITapGestureRecognizer? = nil){
+		// TODO: Implement openActivity.
 		NSLog(":ROW_PAST_ACTIVITY:DEBUG: open activity")
 		NSLog(":ROW_PAST_ACTIVITY:DEBUG: open activity")
 	}
 	}
 }
 }

+ 16 - 1
app/RowSchedule.swift

@@ -34,6 +34,7 @@ Extension of UIView to be formatted as sections.
 	@IBOutlet weak var lbText: UILabel!
 	@IBOutlet weak var lbText: UILabel!
 	@IBOutlet weak var lbLocation: UILabel!
 	@IBOutlet weak var lbLocation: UILabel!
 	
 	
+	
 	/**
 	/**
 	Default constructor
 	Default constructor
 	*/
 	*/
@@ -41,12 +42,17 @@ Extension of UIView to be formatted as sections.
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	
+	/**
+	Loads the view from the xib with the same name as the class.
+	*/
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first as! UIView
+		nib.instantiate(withOwner: self, options: nil).first
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor.
 	Default constructor.
 	:param: s Custom identifier
 	:param: s Custom identifier
@@ -72,6 +78,7 @@ Extension of UIView to be formatted as sections.
 		addGestureRecognizer(tapRecognizer)*/
 		addGestureRecognizer(tapRecognizer)*/
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor for the interface builder
 	Default constructor for the interface builder
 	*/
 	*/
@@ -79,6 +86,7 @@ Extension of UIView to be formatted as sections.
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Sets the time of the event.
 	Sets the time of the event.
 	:param: str String with the time to set.
 	:param: str String with the time to set.
@@ -87,6 +95,7 @@ Extension of UIView to be formatted as sections.
 		self.lbTime.text = str
 		self.lbTime.text = str
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Sets the time of the event.
 	Sets the time of the event.
 	:param: hours Hour of the event start.
 	:param: hours Hour of the event start.
@@ -103,6 +112,7 @@ Extension of UIView to be formatted as sections.
 		self.lbTime.text = "\(hours):\(strMinutes)"
 		self.lbTime.text = "\(hours):\(strMinutes)"
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Sets the time of the event.
 	Sets the time of the event.
 	:param: dtime Datetime of the event start.
 	:param: dtime Datetime of the event start.
@@ -121,6 +131,7 @@ Extension of UIView to be formatted as sections.
 		self.lbTime.text = "\(hours):\(strMinutes)"
 		self.lbTime.text = "\(hours):\(strMinutes)"
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Sets the title of the event.
 	Sets the title of the event.
 	:param: text The title of the event.
 	:param: text The title of the event.
@@ -129,6 +140,7 @@ Extension of UIView to be formatted as sections.
 		self.lbTitle.text = text.decode().stripHtml()
 		self.lbTitle.text = text.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Sets the location of the event.
 	Sets the location of the event.
 	:param: text The location of the event.
 	:param: text The location of the event.
@@ -137,6 +149,7 @@ Extension of UIView to be formatted as sections.
 		self.lbLocation.text = text.decode().stripHtml()
 		self.lbLocation.text = text.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Sets the description of the event. Decodes HTML.
 	Sets the description of the event. Decodes HTML.
 	:param: text The new text.
 	:param: text The new text.
@@ -145,10 +158,12 @@ Extension of UIView to be formatted as sections.
 		self.lbText.text = text.decode().stripHtml()
 		self.lbText.text = text.decode().stripHtml()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Opens an event dialog.
 	Opens an event dialog.
 	*/
 	*/
 	func openEvent(_ sender:UITapGestureRecognizer? = nil){
 	func openEvent(_ sender:UITapGestureRecognizer? = nil){
+		// TODO implement openEvent.
 		print("ROW_BLOG:DEBUG: Open Event")
 		print("ROW_BLOG:DEBUG: Open Event")
 	}
 	}
 }
 }

+ 29 - 43
app/ScheduleViewController.swift

@@ -18,6 +18,9 @@
 // License along with the Gasteizko Margolariak IOS app.
 // License along with the Gasteizko Margolariak IOS app.
 // If not, see <http://www.gnu.org/licenses/>.
 // If not, see <http://www.gnu.org/licenses/>.
 
 
+
+// TODO: Barely working. City schedule not working, GM is shown but events times are mixed.
+
 import UIKit
 import UIKit
 import CoreData
 import CoreData
 
 
@@ -48,6 +51,7 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 	var days: [NSDate] = [NSDate]()
 	var days: [NSDate] = [NSDate]()
 	var selectedDay: Int = 0
 	var selectedDay: Int = 0
 
 
+	
 	/**
 	/**
 	Gets the application context.
 	Gets the application context.
 	:return: The application context.
 	:return: The application context.
@@ -56,13 +60,12 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
 		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Run when the app loads.
 	Run when the app loads.
 	*/
 	*/
 	override func viewDidLoad() {
 	override func viewDidLoad() {
 		
 		
-		NSLog(":SCHEDULECONTROLLER:LOG: Init schedule.")
-		
 		super.viewDidLoad()
 		super.viewDidLoad()
 		self.loadSchedule(margolari: margolari)
 		self.loadSchedule(margolari: margolari)
 		
 		
@@ -80,11 +83,11 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 		btToolbarButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
 		btToolbarButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Returns to the main view controller.
 	Returns to the main view controller.
 	*/
 	*/
 	func back() {
 	func back() {
-		NSLog(":SCHEDULECONTROLLER:DEBUG: Back")
 		self.dismiss(animated: true, completion: nil)
 		self.dismiss(animated: true, completion: nil)
 	}
 	}
 	
 	
@@ -96,29 +99,20 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 		super.didReceiveMemoryWarning()
 		super.didReceiveMemoryWarning()
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Loads the schedule.
 	Loads the schedule.
 	*/
 	*/
 	public func loadSchedule(margolari: Bool){
 	public func loadSchedule(margolari: Bool){
 		
 		
-		NSLog(":SCHEDULECONTROLLER:DEBUG: Loading schedule: Margolariak \(margolari)")
-		
-		var rowcount = 0
-		var row: RowSchedule
-		var start: NSDate
-		var title: String
-		var text: String
-		var locationId: Int
-		var location: String
-		
 		self.context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
 		self.context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
-		self.delegate = UIApplication.shared.delegate as! AppDelegate
+		self.delegate = UIApplication.shared.delegate as? AppDelegate
 		self.lang = getLanguage()
 		self.lang = getLanguage()
 		self.context?.persistentStoreCoordinator = self.delegate?.persistentStoreCoordinator
 		self.context?.persistentStoreCoordinator = self.delegate?.persistentStoreCoordinator
 
 
 		// Get days
 		// Get days
 		// TODO: Get current year
 		// TODO: Get current year
-		let year = 2016
+		let year = 2017
 		let dateFormatter = DateFormatter()
 		let dateFormatter = DateFormatter()
 		dateFormatter.dateFormat = "yyyy-MM-dd"
 		dateFormatter.dateFormat = "yyyy-MM-dd"
 		dateFormatter.locale = Locale.init(identifier: "en_GB")
 		dateFormatter.locale = Locale.init(identifier: "en_GB")
@@ -129,14 +123,13 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 		let dayFetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Festival_event")
 		let dayFetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Festival_event")
 		dayFetchRequest.propertiesToFetch = ["day"]
 		dayFetchRequest.propertiesToFetch = ["day"]
 		if self.margolari == true{
 		if self.margolari == true{
-			dayFetchRequest.predicate = NSPredicate(format: "(gm = %i) AND (start >= %@) AND (start <= %@)", argumentArray: [1, sDate, eDate])
+			dayFetchRequest.predicate = NSPredicate(format: "(gm = %i) AND (start >= %@) AND (start <= %@)", argumentArray: [1, sDate!, eDate!])
 		}
 		}
 		else{
 		else{
-			dayFetchRequest.predicate = NSPredicate(format: "(gm = %i) AND (start >= %@) AND (start <= %@)", argumentArray: [0, sDate, eDate])
+			dayFetchRequest.predicate = NSPredicate(format: "(gm = %i) AND (start >= %@) AND (start <= %@)", argumentArray: [0, sDate!, eDate!])
 		}
 		}
 
 
 		dayFetchRequest.returnsDistinctResults = true
 		dayFetchRequest.returnsDistinctResults = true
-		//dayFetchRequest.resultType = NSFetchRequestResultType.dictionaryResultType
 
 
 		do {
 		do {
 			let results = try self.context?.fetch(dayFetchRequest)
 			let results = try self.context?.fetch(dayFetchRequest)
@@ -145,18 +138,9 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 				let day: NSDate = r.value(forKey: "day") as! NSDate
 				let day: NSDate = r.value(forKey: "day") as! NSDate
 				// Don't add duplicates
 				// Don't add duplicates
 				if self.days.contains(day) == false{
 				if self.days.contains(day) == false{
-					NSLog(":SCHEDULECONTROLLER:DEBUG: Day \(day)")
 					self.days.append(day)
 					self.days.append(day)
 				}
 				}
 			}
 			}
-
-			/*let resultsDict = results as! [[String: String]]
-			for r in resultsDict {
-				//let dayStr: String = r.value(forKey: "day") as! String
-				NSLog(":SCHEDULECONTROLLER:DEBUG: Day \(r["day"])")
-				//self.days.append(r.value(forKey: "day") as! NSDate)
-			}*/
-
 		}
 		}
 		catch let err as NSError {
 		catch let err as NSError {
 			NSLog(":SCHEDULECONTROLLER:ERROR: Error getting day list: \(err)")
 			NSLog(":SCHEDULECONTROLLER:ERROR: Error getting day list: \(err)")
@@ -174,8 +158,7 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 		self.btNext.isUserInteractionEnabled = true
 		self.btNext.isUserInteractionEnabled = true
 		self.btNext.addGestureRecognizer(tapRecognizerNextDay)
 		self.btNext.addGestureRecognizer(tapRecognizerNextDay)
 
 
-	loadDay()
-
+		loadDay()
 	}
 	}
 
 
 
 
@@ -201,7 +184,7 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 			var name: String = ""
 			var name: String = ""
 			do {
 			do {
 				let daySearchResults = try self.context?.fetch(dayFetchRequest)
 				let daySearchResults = try self.context?.fetch(dayFetchRequest)
-				for r in daySearchResults as! [NSManagedObject] {
+				for r in daySearchResults! {
 					name = r.value(forKey: "name_\(lang!)") as! String
 					name = r.value(forKey: "name_\(lang!)") as! String
 				}
 				}
 				self.lbDayName.text = name
 				self.lbDayName.text = name
@@ -213,7 +196,14 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 		else{
 		else{
 			self.lbDayName.text = ""
 			self.lbDayName.text = ""
 		}
 		}
-		let dateString: String = dateFormatter.string(from: days[selectedDay] as Date)
+		
+		// Check for no days
+		if self.selectedDay >= days.count || selectedDay < 0 {
+			NSLog("SCHEDULECONTROLLER:ERROR: No schedule for day \(selectedDay)")
+			return
+		}
+		
+		let dateString: String = dateFormatter.string(from: self.days[self.selectedDay] as Date)
 		let nDay: String = dateString.subStr(start: 8, end: 9)
 		let nDay: String = dateString.subStr(start: 8, end: 9)
 		let month: String = dateString.subStr(start: 5, end: 6)
 		let month: String = dateString.subStr(start: 5, end: 6)
 		var nMonth: String = "Agosto" // TODO: Reference
 		var nMonth: String = "Agosto" // TODO: Reference
@@ -240,9 +230,6 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 			self.btNext.alpha = 1
 			self.btNext.alpha = 1
 			self.btNext.isUserInteractionEnabled = true
 			self.btNext.isUserInteractionEnabled = true
 		}
 		}
-
-		
-		
 		
 		
 		var rowcount = 0
 		var rowcount = 0
 		var row: RowSchedule
 		var row: RowSchedule
@@ -269,9 +256,7 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 			// Get the result
 			// Get the result
 			let searchResults = try self.context?.fetch(fetchRequest)
 			let searchResults = try self.context?.fetch(fetchRequest)
 			
 			
-			NSLog(":SCHEDULECONTROLLER:DEBUG: Total events: \(searchResults?.count)")
-			
-			for r in searchResults as! [NSManagedObject] {
+			for r in searchResults! {
 				
 				
 				title = r.value(forKey: "title_\(lang!)") as! String
 				title = r.value(forKey: "title_\(lang!)") as! String
 				if let tx = r.value(forKey: "description_\(lang!)"){
 				if let tx = r.value(forKey: "description_\(lang!)"){
@@ -311,9 +296,8 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 			svScheduleList.layoutIfNeeded()
 			svScheduleList.layoutIfNeeded()
 
 
 		} catch {
 		} catch {
-			NSLog(":SCHEDULECONTROLLER:ERROR: Error with request: \(error)")
+			NSLog(":SCHEDULECONTROLLER:ERROR: Error with event: \(error)")
 		}
 		}
-
 	}
 	}
 
 
 
 
@@ -331,8 +315,8 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 	:param: sender Event trigger.
 	:param: sender Event trigger.
 	*/
 	*/
 	func prevDay(_ sender:UITapGestureRecognizer? = nil){
 	func prevDay(_ sender:UITapGestureRecognizer? = nil){
-    changeDay(increment: -1)
-  }
+		changeDay(increment: -1)
+	}
 
 
 
 
 	/**
 	/**
@@ -352,9 +336,11 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 		loadDay()
 		loadDay()
 	}
 	}
 	
 	
+	
 	/**
 	/**
-	Gets the device language.
-	:return: Two letter language code of the device.
+	Gets the device language. The only recognized languages are Spanish, English and Basque.
+	If the device has another language, Spanish will be selected by default.
+	:return: Two-letter language code.
 	*/
 	*/
 	func getLanguage() -> String{
 	func getLanguage() -> String{
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)

+ 17 - 8
app/Section.swift

@@ -36,7 +36,6 @@ class Section: UIView {
 	@IBOutlet var content: UIStackView!
 	@IBOutlet var content: UIStackView!
 	
 	
 	
 	
-	
 	/**
 	/**
 	 Run when the section is loaded.
 	 Run when the section is loaded.
 	*/
 	*/
@@ -49,31 +48,41 @@ class Section: UIView {
 		container.frame = self.bounds
 		container.frame = self.bounds
 	}
 	}
 	
 	
+	/**
+	Gets the stack view to be populated.
+	:return: The stack view of the seciton.
+	*/
 	func getContentStack() -> UIStackView {
 	func getContentStack() -> UIStackView {
 		return content
 		return content
 	}
 	}
 	
 	
 	/**
 	/**
-	 Chancges the title of the section.
-	 :param: title The new title.
+	Chancges the title of the section.
+	:param: title The new title.
 	*/
 	*/
 	func setTitle(text: String){
 	func setTitle(text: String){
-		title.text = text
+		title.text = text.decode().stripHtml()
 	}
 	}
 	
 	
+	/**
+	Recalculates the size of the section.
+	*/
 	func expandSection(){
 	func expandSection(){
-		print("Bounds: \(self.bounds)")
-		print("Frame: \(self.frame)")
-		print("Subviews: \(self.subviews)")
 		sizeToFit()
 		sizeToFit()
 	}
 	}
 	
 	
+	/**
+	Adds a view to the section.
+	:param: view View to be added.
+	*/
 	func addEntry(view : UIView){
 	func addEntry(view : UIView){
 		let lbl = UILabel()
 		let lbl = UILabel()
-		lbl.text = "ABBA"
 		content.addSubview(lbl)
 		content.addSubview(lbl)
 	}
 	}
 	
 	
+	/**
+	Recalculates the size of the section.
+	*/
 	func resizeToFitSubviews() {
 	func resizeToFitSubviews() {
 		var width: CGFloat = 0
 		var width: CGFloat = 0
 		var height: CGFloat = 0
 		var height: CGFloat = 0

+ 7 - 4
app/String.swift

@@ -26,6 +26,7 @@ Extension of String to include custom utilities.
 */
 */
 extension String {
 extension String {
 	
 	
+	
 	/**
 	/**
 	The length of the string.
 	The length of the string.
 	*/
 	*/
@@ -33,6 +34,7 @@ extension String {
 		return self.characters.count
 		return self.characters.count
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Finds the first position of a substring.
 	Finds the first position of a substring.
 	:param: target The substring to look for.
 	:param: target The substring to look for.
@@ -50,6 +52,7 @@ extension String {
 		
 		
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Finds the last position of a substring.
 	Finds the last position of a substring.
 	:param: target The substring to look for.
 	:param: target The substring to look for.
@@ -69,6 +72,7 @@ extension String {
 		
 		
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Checks for a substring
 	Checks for a substring
 	:param: target Ths substring to look for.
 	:param: target Ths substring to look for.
@@ -78,6 +82,7 @@ extension String {
 		return (self.range(of: s) != nil) ? true : false
 		return (self.range(of: s) != nil) ? true : false
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Gets a subset of the string.
 	Gets a subset of the string.
 	:param: start The beggining index of the substring.
 	:param: start The beggining index of the substring.
@@ -93,6 +98,7 @@ extension String {
 		return self[range]
 		return self[range]
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Removes HTML symbolf from the string. It also decodes HTML symbols.
 	Removes HTML symbolf from the string. It also decodes HTML symbols.
 	:return: The string eithout the HTML symbols.
 	:return: The string eithout the HTML symbols.
@@ -105,12 +111,9 @@ extension String {
 			print(error.localizedDescription)
 			print(error.localizedDescription)
 			return self
 			return self
 		}
 		}
-		
-		// TODO implement
-		//return self
-		
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Removes escaped characters and unicode symbols from the string.
 	Removes escaped characters and unicode symbols from the string.
 	:return: Escaped string.
 	:return: Escaped string.

+ 22 - 25
app/Sync.swift

@@ -142,40 +142,18 @@ class Sync{
 			
 			
 			self.saveSettings(entries: dataSettings)
 			self.saveSettings(entries: dataSettings)
 			
 			
-			
-			//DEBUG: Tester, Debug only
-			// Test if a entity has entries
-			/*let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
-			let appDelegate = UIApplication.shared.delegate as! AppDelegate
-			context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
-			let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()  //Entity to debug
-			
-			do {
-				//go get the results
-				let searchResults = try context.fetch(fetchRequest)
-				
-				NSLog(":SYNC:DEBUG: Num of results = \(searchResults.count).")
-				for r in searchResults as [NSManagedObject] {
-					NSLog(":SYNC:DEBUG: id: \(r.value(forKey: "id")).")
-				}
-			} catch {
-				NSLog(":SYNC:DEBUG: Error with request: \(error).")
-			}*/
-			//End tester
-			
 			// If it's the initial sync, hide the segue
 			// If it's the initial sync, hide the segue
 			if self.initial == true{
 			if self.initial == true{
 				NSLog(":SYNC:LOG: Finishing synchronous sync.")
 				NSLog(":SYNC:LOG: Finishing synchronous sync.")
 				let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 				let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 				delegate.controller?.initialSync(showScreen: false)
 				delegate.controller?.initialSync(showScreen: false)
-				
 			}
 			}
 		}
 		}
 		
 		
 		task.resume()
 		task.resume()
-		
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Extracts table rows from the raw data received.
 	Extracts table rows from the raw data received.
 	:param: param Received data in JSON format.
 	:param: param Received data in JSON format.
@@ -207,6 +185,7 @@ class Sync{
 		return entries
 		return entries
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -300,6 +279,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -369,6 +349,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -473,6 +454,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -551,6 +533,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -614,6 +597,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -667,6 +651,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -824,6 +809,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -902,6 +888,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -965,6 +952,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -1018,6 +1006,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -1130,6 +1119,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -1225,6 +1215,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -1335,6 +1326,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -1392,6 +1384,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -1481,6 +1474,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -1559,6 +1553,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -1659,6 +1654,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -1766,7 +1762,7 @@ class Sync{
 			var day = dateFormatter.date(from: str.subStr(start : str.indexOf(target : "\"start\":")! + 9, end : str.indexOf(target : ",\"")! - 11))!
 			var day = dateFormatter.date(from: str.subStr(start : str.indexOf(target : "\"start\":")! + 9, end : str.indexOf(target : ",\"")! - 11))!
 			// If on the first hours of the next day...
 			// If on the first hours of the next day...
 			let calendar = Calendar.current
 			let calendar = Calendar.current
-			let hours = calendar.component(.hour, from: day as! Date)
+			let hours = calendar.component(.hour, from: day )
 			// ... the event belongs to the previous day.
 			// ... the event belongs to the previous day.
 			if hours < 6{
 			if hours < 6{
 				day = Calendar.current.date(byAdding: .day, value: -1, to: day)!	
 				day = Calendar.current.date(byAdding: .day, value: -1, to: day)!	
@@ -1794,6 +1790,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the data in the table.
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -1924,6 +1921,7 @@ class Sync{
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Saves the received settings.
 	Saves the received settings.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -1949,7 +1947,6 @@ class Sync{
 				NSLog(":SYNC:LOG: Setting \(name) \(value)")
 				NSLog(":SYNC:LOG: Setting \(name) \(value)")
 				defaults.set(value, forKey: name)
 				defaults.set(value, forKey: name)
 			}
 			}
-
 		}
 		}
 	}
 	}
 }
 }

+ 4 - 3
app/SyncController.swift

@@ -51,6 +51,10 @@ class SyncController: UIViewController{
 		
 		
 	}
 	}
 	
 	
+	
+	/**
+	Signal to update the progressbar and, maybe, the tag.
+	*/
 	func progress(){
 	func progress(){
 		
 		
 		if (Int(completion * 100) % 20) == 0 {
 		if (Int(completion * 100) % 20) == 0 {
@@ -64,9 +68,6 @@ class SyncController: UIViewController{
 			completion = 0.0
 			completion = 0.0
 		}
 		}
 		pb.progress = completion
 		pb.progress = completion
-		
-		
-		
 	}
 	}
 	
 	
 }
 }

+ 5 - 0
app/UIApplcation.swift

@@ -25,6 +25,11 @@ import UIKit
 Extension of UIApplication to get the root view controller.
 Extension of UIApplication to get the root view controller.
 */
 */
 extension UIApplication {
 extension UIApplication {
+	
+	/**
+	Gets the top level controller.
+	:return: Top level view controller.
+	*/
 	class func topViewController(controller: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
 	class func topViewController(controller: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
 		if let navigationController = controller as? UINavigationController {
 		if let navigationController = controller as? UINavigationController {
 			return topViewController(controller: navigationController.visibleViewController)
 			return topViewController(controller: navigationController.visibleViewController)

+ 11 - 13
app/UIImageView.swift

@@ -33,14 +33,13 @@ extension UIImageView {
 	:param: remotePath Url of the image to download (if not cached).
 	:param: remotePath Url of the image to download (if not cached).
 	:return: 0 if the file was set form the local path, 1 if the file was downloaded, other for error.
 	:return: 0 if the file was set form the local path, 1 if the file was downloaded, other for error.
 	*/
 	*/
-	func setImage(localPath: String, remotePath: String) -> Int{
+	func setImage(localPath: String, remotePath: String){
 		//Check if the local image exists.
 		//Check if the local image exists.
 		let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
 		let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
 		let url = NSURL(fileURLWithPath: path)
 		let url = NSURL(fileURLWithPath: path)
 		let filePath = url.appendingPathComponent(localPath)?.path
 		let filePath = url.appendingPathComponent(localPath)?.path
 		let fileManager = FileManager.default
 		let fileManager = FileManager.default
 		if fileManager.fileExists(atPath: filePath!) {
 		if fileManager.fileExists(atPath: filePath!) {
-			print("IMAGE:LOG: File available: \(filePath)")
 			
 			
 			//Set image
 			//Set image
 			do{
 			do{
@@ -49,13 +48,12 @@ extension UIImageView {
 				self.image = UIImage(data: idata as Data)
 				self.image = UIImage(data: idata as Data)
 			}
 			}
 			catch (let error){
 			catch (let error){
-				print("IMAGE:ERROR: Error setting image: \(error.localizedDescription)")
-				return -1
+				NSLog(":IMAGE:ERROR: Error setting image: \(error.localizedDescription)")
+				return
 			}
 			}
-			return 0
+			return
 		} else {
 		} else {
-			print("IMAGE:LOG: File not available: \(filePath)")
-			print("IMAGE:LOG: Downloading from \(remotePath)")
+			NSLog(":IMAGE:LOG: Downloading image from \(remotePath)")
 			
 			
 			//Create required directories
 			//Create required directories
 			var fileFolderUrl = URL(fileURLWithPath: filePath!)
 			var fileFolderUrl = URL(fileURLWithPath: filePath!)
@@ -64,7 +62,7 @@ extension UIImageView {
 				try fileManager.createDirectory(at:  fileFolderUrl, withIntermediateDirectories: true, attributes: nil)
 				try fileManager.createDirectory(at:  fileFolderUrl, withIntermediateDirectories: true, attributes: nil)
 			}
 			}
 			catch(let error){
 			catch(let error){
-				print("IMAGE:ERROR: Error creating directories at \(fileFolderUrl.path): \(error.localizedDescription)")
+				NSLog(":IMAGE:ERROR: Error creating directories at \(fileFolderUrl.path): \(error.localizedDescription)")
 			}
 			}
 			
 			
 			// Create destination URL
 			// Create destination URL
@@ -83,13 +81,13 @@ extension UIImageView {
 					
 					
 					// Success
 					// Success
 					if let statusCode = (response as? HTTPURLResponse)?.statusCode {
 					if let statusCode = (response as? HTTPURLResponse)?.statusCode {
-						print("IMAGE:LOG: Successfully downloaded. Status code: \(statusCode)")
+						// TODO something.
 					}
 					}
 					
 					
 					do {
 					do {
 						try FileManager.default.copyItem(at: tempLocalUrl, to: destinationFileUrl)
 						try FileManager.default.copyItem(at: tempLocalUrl, to: destinationFileUrl)
 					} catch (let writeError) {
 					} catch (let writeError) {
-						print("IMAGE:ERROR: Error creating a file \(destinationFileUrl) : \(writeError)")
+						NSLog(":IMAGE:ERROR: Error creating a file \(destinationFileUrl) : \(writeError)")
 					}
 					}
 					
 					
 					// Set the image
 					// Set the image
@@ -98,17 +96,17 @@ extension UIImageView {
 						self.image = UIImage(data: idata as Data)
 						self.image = UIImage(data: idata as Data)
 					}
 					}
 					catch (let error){
 					catch (let error){
-						print("IMAGE:ERROR: Error setting image: \(error.localizedDescription)")
+						NSLog(":IMAGE:ERROR: Error setting image: \(error.localizedDescription)")
 					}
 					}
 					
 					
 				} else {
 				} else {
-					print("IMAGE:ERROR: Error took place while downloading a file: %@", error?.localizedDescription);
+					NSLog(":IMAGE:ERROR: Error took place while downloading a file.");
 				}
 				}
 			}
 			}
 			task.resume()
 			task.resume()
 		
 		
 		
 		
-			return 1
+			return
 		}
 		}
 
 
 	}
 	}

+ 1 - 3
app/UIView.swift

@@ -60,18 +60,16 @@ import UIKit
 		}
 		}
 	}
 	}
 	
 	
+	
 	var parentViewController: ViewController? {
 	var parentViewController: ViewController? {
 		var parentResponder: UIResponder? = self
 		var parentResponder: UIResponder? = self
 		var i = 0
 		var i = 0
 		while parentResponder != nil {
 		while parentResponder != nil {
-			print("UIVIEW:DEBUG: parentViewController level \(i)")
 			parentResponder = parentResponder!.next
 			parentResponder = parentResponder!.next
 			if let viewController = parentResponder as? ViewController {
 			if let viewController = parentResponder as? ViewController {
-				print("UIVIEW:DEBUG: parentViewController found  controller.")
 				return viewController
 				return viewController
 			}
 			}
 		}
 		}
-		print("UIVIEW:DEBUG: parentViewController no controller found.")
 		return nil
 		return nil
 	}
 	}
 	
 	

+ 52 - 31
app/ViewController.swift

@@ -43,23 +43,27 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	@IBOutlet var containerViewLocation: LocationView!
 	@IBOutlet var containerViewLocation: LocationView!
 	@IBOutlet var containerViewHome: HomeView!
 	@IBOutlet var containerViewHome: HomeView!
 	
 	
+	// Passed id to perform segues.
 	var passId: Int = -1
 	var passId: Int = -1
 	
 	
-	// Location-related variables
+	// Location-related variables.
 	var locationManager = CLLocationManager()
 	var locationManager = CLLocationManager()
 	var didFindMyLocation = false
 	var didFindMyLocation = false
 	
 	
+	
 	/**
 	/**
-	 Controller initializer.
+	Controller initializer.
+	:param: coder Coder.
 	*/
 	*/
 	required init?(coder aDecoder: NSCoder) {
 	required init?(coder aDecoder: NSCoder) {
 		NSLog(":CONTROLLER:DEBUG: Init!")
 		NSLog(":CONTROLLER:DEBUG: Init!")
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 	}
 	}
 	
 	
+	
 	/**
 	/**
-	 Retrieves the application context.
-	 :return: The application context.
+	Retrieves the application context.
+	:return: The application context.
 	*/
 	*/
 	func getContext () -> NSManagedObjectContext {
 	func getContext () -> NSManagedObjectContext {
 		//let appDelegate = UIApplication.shared.delegate as! AppDelegate
 		//let appDelegate = UIApplication.shared.delegate as! AppDelegate
@@ -67,9 +71,10 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
 		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
 	}
 	}
 	
 	
+	
 	/**
 	/**
-	 Shows a post by loading the controller.
-	 :param: id The post id.
+	Shows a post.
+	:param: id The post id.
 	*/
 	*/
 	func showPost(id: Int){
 	func showPost(id: Int){
 		NSLog(":CONTROLLER:DEBUG: Showing Post \(id)")
 		NSLog(":CONTROLLER:DEBUG: Showing Post \(id)")
@@ -77,9 +82,10 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 		performSegue(withIdentifier: "SeguePost", sender: nil)
 		performSegue(withIdentifier: "SeguePost", sender: nil)
 	}
 	}
 	
 	
+	
 	/**
 	/**
-	 Shows a post by loading the controller.
-	 :param: id The album id.
+	Shows an album.
+	:param: id The album id.
 	*/
 	*/
 	func showAlbum(id: Int){
 	func showAlbum(id: Int){
 		NSLog(":CONTROLLER:DEBUG: Showing album \(id)")
 		NSLog(":CONTROLLER:DEBUG: Showing album \(id)")
@@ -87,6 +93,11 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 		performSegue(withIdentifier: "SegueAlbum", sender: nil)
 		performSegue(withIdentifier: "SegueAlbum", sender: nil)
 	}
 	}
 	
 	
+	
+	/**
+	Shows a schedule.
+	:param: margolari True for the margolari schedule, false for the city one.
+	*/
 	func showSchedule(margolari: Bool){
 	func showSchedule(margolari: Bool){
 		NSLog(":CONTROLLER:DEBUG: Showing schedule. Margolari: \(margolari)")
 		NSLog(":CONTROLLER:DEBUG: Showing schedule. Margolari: \(margolari)")
 		if margolari == true{
 		if margolari == true{
@@ -95,14 +106,14 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 		else{
 		else{
 			self.passId = 0
 			self.passId = 0
 		}
 		}
-		// TODO: Uncomment when ready
 		performSegue(withIdentifier: "SegueSchedule", sender: nil)
 		performSegue(withIdentifier: "SegueSchedule", sender: nil)
 	}
 	}
 	
 	
+	
 	/**
 	/**
-	 Handles the initial sync process.
-	 It can start it, showing the sync screen, or finish it, hidding the screen.
-	 :param: showScreen True to start the sync, false to end it.
+	Handles the initial sync process.
+	It can start it, showing the sync screen, or finish it, hidding the screen.
+	:param: showScreen True to start the sync, false to end it.
 	*/
 	*/
 	func initialSync(showScreen: Bool){
 	func initialSync(showScreen: Bool){
 		if showScreen == true{
 		if showScreen == true{
@@ -119,13 +130,13 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	}
 	}
 	
 	
 	/**
 	/**
-	 Run before performing a segue.
-	 Assigns id if neccessary.
-	 :param: segue The segue to perform.
-	 :sender: The calling view.
+	Run before performing a segue.
+	Assigns id if neccessary.
+	:param: segue The segue to perform.
+	:sender: The calling view.
 	*/
 	*/
 	override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
 	override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
-		NSLog(":CONTROLLER:DEBUG: preparing for segue '\(segue.identifier)' with id \(self.passId)")
+		NSLog(":CONTROLLER:DEBUG: preparing for segue '\(String(describing: segue.identifier))' with id \(self.passId)")
 		if segue.identifier == "SeguePost"{
 		if segue.identifier == "SeguePost"{
 			(segue.destination as! PostViewController).id = passId
 			(segue.destination as! PostViewController).id = passId
 		}
 		}
@@ -146,7 +157,7 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	}
 	}
 	
 	
 	/**
 	/**
-	 Run when the app loads.
+	Run when the app loads.
 	*/
 	*/
 	override func viewDidLoad() {
 	override func viewDidLoad() {
 		
 		
@@ -161,11 +172,9 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 		self.containerViewBlog.alpha = 0
 		self.containerViewBlog.alpha = 0
 		self.containerViewGallery.alpha = 0
 		self.containerViewGallery.alpha = 0
 				
 				
-		NSLog(":CONTROLLER:LOG: viewDidLoad()")
-		NSLog(":CONTROLLER:DEBUG: Skyp sync")
-		//Sync()
+		NSLog(":CONTROLLER:DEBUG: Don't skyp sync")
+		Sync()
 
 
-		//self.containerViewBlog.setController(controller: self as ViewController)
 		
 		
 		self.delegate = UIApplication.shared.delegate as? AppDelegate
 		self.delegate = UIApplication.shared.delegate as? AppDelegate
 		self.delegate?.controller = self
 		self.delegate?.controller = self
@@ -177,6 +186,10 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 		
 		
 	}
 	}
 
 
+	/**
+	Actually populates all sections.
+	As of now, not working.
+	*/
 	func populate(){
 	func populate(){
 		if (self.containerViewHome != nil){
 		if (self.containerViewHome != nil){
 			//(self.containerViewHome as HomeView).populate2()
 			//(self.containerViewHome as HomeView).populate2()
@@ -194,10 +207,10 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	}
 	}
 	
 	
 	/**
 	/**
-	 Executed when the view is actually shown.
-	 Performs the initial sync in the first run.
-	 It also generates a user id if none exists.
-	 :param: animated Wether the controller appearance must be animated or not.
+	Executed when the view is actually shown.
+	Performs the initial sync in the first run.
+	It also generates a user id if none exists.
+	:param: animated Wether the controller appearance must be animated or not.
 	*/
 	*/
 	override func viewDidAppear(_ animated: Bool) {
 	override func viewDidAppear(_ animated: Bool) {
 		super.viewDidAppear(animated)
 		super.viewDidAppear(animated)
@@ -211,9 +224,9 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	}
 	}
 	
 	
 	/**
 	/**
-	 Generates a random string to be used as a user identifier.
-	 :param: length The length of the generated string.
-	 :return: A random alphanumeric string with the indicated length.
+	Generates a random string to be used as a user identifier.
+	:param: length The length of the generated string.
+	:return: A random alphanumeric string with the indicated length.
 	*/
 	*/
 	func randomString(length: Int) -> String {
 	func randomString(length: Int) -> String {
 		
 		
@@ -232,7 +245,7 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	}
 	}
 
 
 	/**
 	/**
-	 Dispose of any resources that can be recreated.
+	Dispose of any resources that can be recreated.
 	*/
 	*/
 	override func didReceiveMemoryWarning() {
 	override func didReceiveMemoryWarning() {
 		super.didReceiveMemoryWarning()
 		super.didReceiveMemoryWarning()
@@ -246,7 +259,11 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	
 	
 	// MARK: - UICollectionViewDataSource protocol
 	// MARK: - UICollectionViewDataSource protocol
 	
 	
-	//Tell the collection view how many cells to make
+	/**
+	Sets a collection of menu items.
+	:param: numberOfItemsInSection The number of entries of the menu.
+	:return: The number of entries of the menu.
+	*/
 	func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
 	func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
 		return self.items.count
 		return self.items.count
 	}
 	}
@@ -282,6 +299,10 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 		showComponent(selected: indexPath.item)
 		showComponent(selected: indexPath.item)
 	}
 	}
 	
 	
+	/**
+	Caled when an item of the menu bar is selected.
+	:param: selected Index of the selected item.
+	*/
 	@IBAction func showComponent(selected: Int) {
 	@IBAction func showComponent(selected: Int) {
 		//Activate label
 		//Activate label
 		var i = 0
 		var i = 0