Pārlūkot izejas kodu

Fixes in the schedule.

Iñigo Valentin 9 gadi atpakaļ
vecāks
revīzija
04486e2d6a
4 mainītis faili ar 30 papildinājumiem un 15 dzēšanām
  1. 13 5
      app/EventController.swift
  2. 4 4
      app/HomeView.xib
  3. 2 2
      app/Info.plist
  4. 11 4
      app/ScheduleViewController.swift

+ 13 - 5
app/EventController.swift

@@ -183,11 +183,19 @@ class EventController: UIViewController, UIGestureRecognizerDelegate {
 		fetchRequest.predicate = NSPredicate(format: "id = %i", place)
 		do {
 			let searchResults = try context.fetch(fetchRequest)
-			let r: NSManagedObject = searchResults[0]
-			placeName = r.value(forKey: "name_\(lang)")! as! String
-			placeAddress = r.value(forKey: "address_\(lang)")! as! String
-			lat = r.value(forKey: "lat")! as! Double
-			lon = r.value(forKey: "lon")! as! Double
+			if (searchResults.count > 0){
+				let r: NSManagedObject = searchResults[0]
+				placeName = r.value(forKey: "name_\(lang)")! as! String
+				placeAddress = r.value(forKey: "address_\(lang)")! as! String
+				lat = r.value(forKey: "lat")! as! Double
+				lon = r.value(forKey: "lon")! as! Double
+			}
+			else{
+				placeName = " "
+				placeAddress =  " "
+				lat = 42.8507807
+				lon = -2.8394378
+			}
 		}
 		catch{
 			NSLog(":FUTUREACTIVITY:ERROR: Error getting infor about place \(place): \(error)")

+ 4 - 4
app/HomeView.xib

@@ -160,19 +160,19 @@
                                                             </constraints>
                                                         </imageView>
                                                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="¡Gasteizko Margolariak está por ahí!" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YsW-Bq-7gd" userLabel="Text">
-                                                            <rect key="frame" x="95" y="9.5" width="175" height="70"/>
+                                                            <rect key="frame" x="95" y="9.5" width="175" height="60"/>
                                                             <constraints>
-                                                                <constraint firstAttribute="height" constant="70" id="Txi-or-Pra"/>
+                                                                <constraint firstAttribute="height" constant="60" id="Txi-or-Pra"/>
                                                             </constraints>
                                                             <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                             <nil key="textColor"/>
                                                             <nil key="highlightedColor"/>
                                                         </label>
                                                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0Uj-NF-epp">
-                                                            <rect key="frame" x="95" y="84.5" width="175" height="25"/>
+                                                            <rect key="frame" x="95" y="74.5" width="175" height="35"/>
                                                             <color key="backgroundColor" red="0.070588235289999995" green="0.27058823529999998" blue="0.4039215686" alpha="1" colorSpace="calibratedRGB"/>
                                                             <constraints>
-                                                                <constraint firstAttribute="height" constant="25" id="FLs-1o-qFc"/>
+                                                                <constraint firstAttribute="height" constant="35" id="FLs-1o-qFc"/>
                                                             </constraints>
                                                             <fontDescription key="fontDescription" type="boldSystem" pointSize="13"/>
                                                             <state key="normal" title="Programa Margolari">

+ 2 - 2
app/Info.plist

@@ -17,9 +17,9 @@
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
-	<string>1.0.4</string>
+	<string>1.1</string>
 	<key>CFBundleVersion</key>
-	<string>16</string>
+	<string>17</string>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
 	<key>NSLocationWhenInUseUsageDescription</key>

+ 11 - 4
app/ScheduleViewController.swift

@@ -131,6 +131,9 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 		}
 
 		dayFetchRequest.returnsDistinctResults = true
+		let sortDayDescriptor = NSSortDescriptor(key: "start", ascending: true)
+		let sortDayDescriptors = [sortDayDescriptor]
+		dayFetchRequest.sortDescriptors = sortDayDescriptors
 
 		do {
 			let results = try self.context?.fetch(dayFetchRequest)
@@ -283,10 +286,14 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 				locationFetchRequest.fetchLimit = 1
 				do{
 					var locationSearchResults = try self.context?.fetch(locationFetchRequest)
-					let locationR = locationSearchResults?[0]
-					location = locationR?.value(forKey: "name_\(lang!)")! as! String
-					
-					row.setLocation(text: location)
+					if (locationSearchResults?.count)! > 0{
+						let locationR = locationSearchResults?[0]
+						location = locationR?.value(forKey: "name_\(lang!)")! as! String
+						row.setLocation(text: location)
+					}
+					else{
+						row.setLocation(text: "")
+					}
 				} catch {
 					NSLog(":SCHEDULECONTROLLER:ERROR: Error getting location: \(error)")
 				}