Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Simple iPhone App with Swift Creating a Data Model Finishing Up Our Model

the app won't run

It gives me an error and says that I have to change 'var' to 'let' by the functions randomFact, anybody who's got a solution?

Code:

// // factBook.swift // Random Facts Guy // // Created by Nils Garland on 27/12/15. // Copyright © 2015 Andaz AB. All rights reserved. //

import Foundation

// This is my factbook where all the facts on the app are stored.

struct factBook {

let factArray = [ "Pteronophobia is the fear of being tickled by feathers!", "In Sweden, it is illegal to name a child superman or ikea.", "The average woman uses her height in lipstick every 5 years.", "During your lifetime, you will produce enough saliva to fill two swimming pools.", "If you consistently fart for 6 years & 9 months, enough gas is produced to create the energy of an atomic bomb!", "King Henry VIII slept with a gigantic axe beside him.", "The capacity of Wembley stadium in London is 90,000", "Steve Jobs the founder of apple was once homeless", "The first word on the moon was 'okay'", "Fanta was invented in 1940 because the Germans could not get the ingrediances for coca cola during the war.", "Jamie Vardy of Leicester city FC has the record for most consecutive goals in the EPL", "Mark Zuckerberg founder of Facebook is the youngest billionare in the world.", "Justin Bieber has the most dislikes on youtube on the video 'Baby'.", "Bill Gates is not allowed to comment about apple products.", "Al the players for Arsenal FC once gave there wages to charity.", "Sweden is 5 times the size of the UK and the UK has 5 times as many people", ] func randomFact() -> String {

    var unsignedArrayCount = UInt32(factArray.count)
    var unsignedRandomNumber = arc4random_uniform(unsignedArrayCount)
    var randomNumber = Int(unsignedRandomNumber)

    return factArray[randomNumber]

}

}

2 Answers

Piotr Nejman
Piotr Nejman
3,374 Points

For all I remember had the same issue. Just change it and it should work

I have the same issue, but everything works anyway.