EDIT: Dopo aver trascorso molto tempo a esaminare il progetto, ho riscontrato il problema.
Fare clic sul file Main.Storyboard. Clicca sull'Ispettore File. Deseleziona Classi di dimensioni. Fatto. Il tuo progetto funziona!
Questo sembra essere un bug XCode. Se controlli nuovamente Classi di Dimensioni, il tuo progetto dovrebbe ancora funzionare.
La correzione è quindi di deselezionare e quindi selezionare Classi dimensioni in File Inspector del file Main.storyboard.
TUTTAVIA: Il mio consiglio sintassi è ancora valida, rende il codice più pulito:
Beh, avete controllato the solution of the exercise?
C'è un link alla fine della pagina;)
prima differenza:
var workouts = [Workout]()
var numbers = [Workout]()
func loadSampleMeals() {
let workouts1 = Workout(name: "Run", number: "1000")!
let workouts2 = Workout(name: "Walk", number: "2000")!
let workouts3 = Workout(name: "Push-Ups", number: "20")!
workouts += [workouts1, workouts2, workouts3]
numbers += [workouts1, workouts2, workouts3]
}
dovrebbe essere:
var workouts = [Workout]()
func loadSampleMeals() {
let workouts1 = Workout(name: "Run", number: "1000")!
let workouts2 = Workout(name: "Walk", number: "2000")!
let workouts3 = Workout(name: "Push-Ups", number: "20")!
workouts += [workouts1, workouts2, workouts3]
}
seconda differenza:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
// Table view cells are reused and should be dequeued using a cell identifier.
let cellIdentifier = "DhikrTableViewCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! GoalsTableViewCell
// Fetches the appropriate meal for the data source layout.
let dhikr = workouts[indexPath.row]
let number = numbers[indexPath.row]
cell.nameLabel.text = dhikr.name
cell.numberLabel.text = number.number
//cell.photoImageView.image = dhikr.photo
//cell.ratingControl.rating = dhikr.rating
return cell
}
dovrebbe essere:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
// Table view cells are reused and should be dequeued using a cell identifier.
let cellIdentifier = "DhikrTableViewCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! GoalsTableViewCell
// Fetches the appropriate meal for the data source layout.
let dhikr = workouts[indexPath.row]
cell.nameLabel.text = dhikr.name
cell.numberLabel.text = dhikr.number
//cell.photoImageView.image = dhikr.photo
//cell.ratingControl.rating = dhikr.rating
return cell
}
P.S .:
class Workout {
// MARK: Properties
var name: String
//var notifications: Int
var number: Int
// MARK: Initialization
init?(name: String, number: Int) {
// Initialize stored properties.
self.name = name
//self.notifications = notifications
self.number = number
// Initialization should fail if there is no name or if the rating is negative.
if name.isEmpty || number < 0{
return nil
}
}
}
number
sarà mai < 0, Forse volevi dire == 0
?.
Davvero non hai ricevuto la tua domanda. Dove stai affrontando un problema su tableview o addgoals e qual è il problema –
C'è stato un problema? Quale problema? – FredericP
Dovresti mostrare il tuo codice (può essere caricato su google drive e fornire un link) e indicare esattamente qual è il problema che stai affrontando. – Mathews