Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mack255

macrumors member
Original poster
Jul 4, 2008
33
0
Whats wrong with my code i said to change the button title to orange when it says what color is the sun but instead it changes when it says wrong please help
 

Attachments

  • Picture 1.png
    Picture 1.png
    10.9 KB · Views: 53
  • Picture 2.png
    Picture 2.png
    10.5 KB · Views: 50
  • Picture 3.png
    Picture 3.png
    11.4 KB · Views: 41
  • Picture 4.png
    Picture 4.png
    16.4 KB · Views: 93

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
= doesn't compare things. It assigns values. Use == to compare. But you can't in this case as you'd be comparing an object's address against a literal string. You need to use the isEqualToString: method.
 

mack255

macrumors member
Original poster
Jul 4, 2008
33
0
im new can you please tell me the full code im brand new started a couple days ago
 

mack255

macrumors member
Original poster
Jul 4, 2008
33
0
please just tell me i don't understand i couldn't find any good websites to teach me and im broke and can't buy any books
 

eddietr

macrumors 6502a
Oct 29, 2006
807
0
Virginia
im new can you please tell me the full code im brand new started a couple days ago

Well, if you're learning you probably want to understand the concepts rather than assign someone to write code for you. The Apple developer docs are more than sufficient if you don't want to buy a book right now.

So do you understand the concept that objects belong to a class and can respond to messages (also called instance methods)? If so, then the strings you have belong to the class NSString, and so you can find various instance methods in the docs for NSString. There is a method there that allows you to compare one instance of NSString to another.

Your overall approach to managing questions and answers like this will get pretty painful quickly. But it's a good learning exercise, and then you can learn ways to make this easier and more efficient.

But I would point out that string comparison is not your main problem. The issue is the logic itself. The method that is fired by the top button won't be executed until after the user hits that button.

So that's really the reason why you don't get the button "Orange" until after the user has pressed that top button.

Does that make sense?
 

johnnybluejeans

macrumors 6502
Jan 16, 2006
294
0
New York, NY
please just tell me i don't understand i couldn't find any good websites to teach me and im broke and can't buy any books

If someone "just tells you" you won't learn anything. You couldn't find any good websites??? Did you even look? Here, I have a link that will help you:

http://******.com/?q=objective+c+tutorial+iphone
 

mack255

macrumors member
Original poster
Jul 4, 2008
33
0
actually i learn really well if someone tells me the code
 

eddietr

macrumors 6502a
Oct 29, 2006
807
0
Virginia
actually i learn really well if someone tells me the code

Read my post again, I told you exactly which class to look in.

I think the point you may be missing is that coding with Cocoa or any similar framework is a process of looking through the framework documentation for something you need, and then using it in your code. This is true even after you've done this for decades.

So if you don't have the time or focus or energy or whatever to crack open the documentation, then you've just picked a bad hobby for yourself. Not trying to be mean, it's just how programming works. If you don't want to do it, then save yourself a lot of trouble and just don't do it. It's that easy.

But if you do decide to put the effort in, then we can talk about the logic problems (which I wrote about already in my earlier post.)

Good luck whatever you decide to do. I would recommend the hello world primer on the Apple developer site. Or any of the other video and web primers that people talk about on this forum. Just to get the basics down first.

BTW, your code already has multiple examples of sending messages to objects. This is exactly what you need to do with your NSStrings. So if you wrote your code, then you know what to do. If you just copied that code from someone else, then I think you've proven that you don't really learn from copying code.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.