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
kirkbyo
15,791 PointsXcode not building and Launching my project
I have been working on a little project recently that is a random quote generator. I have figured out a method to randomize the quotes and have the quotes and the correct author associated with that quote.
I have been adding quotes and when I went to build and launch, Xcode just freezes when compiling the source files (Screenshot)
Here is my code
class quotes: UIViewController {
@IBOutlet weak var quoteDisplay: UILabel!
@IBOutlet weak var authorDisplay: UILabel!
func getQuote() {
var quoteIndex = quoteArray[randomNumber(quoteArray.count)]
quoteDisplay.text = quoteIndex[0]
authorDisplay.text = quoteIndex[1]
}
func randomNumber(arrayLength: Int) -> Int {
var unsignedArrayCount = UInt32(arrayLength)
var unsignedRandomNumber = arc4random_uniform(unsignedArrayCount)
var randomNumber = Int(unsignedRandomNumber)
return randomNumber
}
override func viewDidLoad() {
super.viewDidLoad()
getQuote()
}
@IBAction func newQuote() {
getQuote()
}
//============================//
//********** Quotes **********//
//============================//
let quoteArray = [
["It is during our darkest moments that we must focus to see the light.", "Aristotle Onassis"],
["You only live once, but if you do it right, once is enough", "Mae West"],
["Don't walk behind me; I may not lead. Don't walk in front of me; I may not follow. Just walk beside me and be my friend", "Albert Camus"],
["If you tell the truth, you don't have to remember anything", "Mark Twain"],
["I believe that everything happens for a reason. People change so that you can learn to let go, things go wrong so that you appreciate them when they're right, you believe lies so you eventually learn to trust no one but yourself, and sometimes good things fall apart so better things can fall together", "Marilyn Monroe"],
["Here's to the crazy ones. The misfits. The rebels. The troublemakers. The round pegs in the square holes. The ones who see things differently. They're not fond of rules. And they have no respect for the status quo. You can quote them, disagree with them, glorify or vilify them. About the only thing you can't do is ignore them. Because they change things. They push the human race forward. And while some may see them as the crazy ones, we see genius. Because the people who are crazy enough to think they can change the world, are the ones who do.", "Apple Inc"],
["We accept the love we think we deserve", "Stephen Chbosky, The Perks of Being a Wallflower"],
["Life is what happens to you while you're busy making other plans.", "Allen Saunders"],
["Whenever you find yourself on the side of the majority, it is time to pause and reflect", "Mark Twain"],
["I like nonsense, it wakes up the brain cells. Fantasy is a necessary ingredient in living", "Dr. Seuss"],
["If you can dream it, you can do it.", "Walt Dysney"],
["The more you like yourself, the less you are like anyone else, which makes you unique.", "Walt Dysney"],
["Times and conditions change so rapidly that we must keep our aim constantly focused on the future.", "Walt Dysney"],
["You may not realize it when it happens, but a kick in the teeth may be the best thing in the world for you.", "Walt Dysney"],
["Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.", "Albert Einstein"],
["You have to learn the rules of the game. And then you have to play better than anyone else.", "Albert Einstein"],
["The true sign of intelligence is not knowledge but imagination.", "Albert Einstein"],
["Life is one big road with lots of signs. So when you riding through the ruts, don't complicate your mind. Flee from hate, mischief and jealousy. Don't bury your thoughts, put your vision to reality. Wake Up and Live!", "Bob Marley"],
["Open your eyes, look within. Are you satisfied with the life you're living?", "Bob Marley"],
["Nearly all men can stand adversity, but if you want to test a man's character, give him power.", "Abraham Lincoln"],
["Better to remain silent and be thought a fool than to speak out and remove all doubt.", "Abraham Lincoln"],
["In the end, it's not the years in your life that count. It's the life in your years.", "Abraham Lincoln"],
["When I do good, I feel good. When I do bad, I feel bad. That's my religion.", "Abraham Lincoln"],
["The truth is you don't know what is going to happen tomorrow. Life is a crazy ride, and nothing is guaranteed.", "Eminem"],
["Somewhere deep down there's a decent man in me, he just can't be found.", "Eminem"],
["Dealing with backstabbers, there was one thing I learned. They're only powerful when you got your back turned.", "Eminem"],
["To the people I forgot, you weren't on my mind for some reason and you probably don't deserve any thanks anyway.", "Eminem"],
["I'm selfish, impatient and a little insecure. I make mistakes, I am out of control and at times hard to handle. But if you can't handle me at my worst, then you sure as hell don't deserve me at my best.", "Marilyn Monroe"],
["Be who you are and say what you feel, because those who mind don't matter, and those who matter don't mind", "Bernard M. Baruch"],
["Be yourself; everyone else is already taken", "Oscar Wilde"],
["You know you're in love when you can't fall asleep because reality is finally better than your dreams.", "Dr.Seuss"],
["So many books, so little time.", "Frank Zappa"],
["Be the change that you wish to see in the world.", "Mahatma Gandhi"],
["In three words I can sum up everything I've learned about life: it goes on", "Robert Frost"],
["A friend is someone who knows all about you and still loves you", "Elbert Hubbard"],
["Always forgive your enemies; nothing annoys them so much.", "Oscar Wilde"],
["I've learned that people will forget what you said, people will forget what you did, but people will never forget how you made them feel", "Maya Angelou"],
["Live as if you were to die tomorrow. Learn as if you were to live forever.", "Mahatma Gandhi"],
["Insanity is doing the same thing, over and over again, but expecting different results.", "Narcotics Anonymous"],
["Darkness cannot drive out darkness: only light can do that. Hate cannot drive out hate: only love can do that.", "Martin Luther King Jr."],
["I believe that everything happens for a reason. People change so that you can learn to let go, things go wrong so that you appreciate them when they're right, you believe lies so you eventually learn to trust no one but yourself, and sometimes good things fall apart so better things can fall together.", "Marilyn Monroe"],
["Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover", "H. Jackson Brown Jr., P.S. I Love You"],
["", ""]
]
}
This problem does not happen when I remove most of the quotes and keep around ten of them in the “quoteArray”. My question is how can I stop this from happening? Is their a better way to do this?
Ozzie
1 Answer
kirkbyo
15,791 PointsI decided to use Plist instead, because I found that it did not effect the building and launching of the app. So I guess you mark this question as solved.
Ozzie