My Code Is Wacked - MacRumors Forums
Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 3, 2009, 09:46 AM   #1
mack255
Banned
 
Join Date: Jul 2008
My Code Is Wacked

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
Attached Thumbnails
Click image for larger version

Name:	Picture 1.png
Views:	3
Size:	10.9 KB
ID:	165556   Click image for larger version

Name:	Picture 2.png
Views:	4
Size:	10.5 KB
ID:	165557   Click image for larger version

Name:	Picture 3.png
Views:	5
Size:	11.4 KB
ID:	165558  

Click image for larger version

Name:	Picture 4.png
Views:	47
Size:	16.4 KB
ID:	165559  
mack255 is offline   0 Reply With Quote
Old Apr 3, 2009, 09:53 AM   #2
caveman_uk
Guest
 
caveman_uk's Avatar
 
Join Date: Feb 2003
Location: 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.
caveman_uk is offline   0 Reply With Quote
Old Apr 3, 2009, 09:55 AM   #3
mack255
Thread Starter
Banned
 
Join Date: Jul 2008
how do i use that method
mack255 is offline   0 Reply With Quote
Old Apr 3, 2009, 09:58 AM   #4
mack255
Thread Starter
Banned
 
Join Date: Jul 2008
a better question is how would i write the code
mack255 is offline   0 Reply With Quote
Old Apr 3, 2009, 10:12 AM   #5
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by mack255 View Post
a better question is how would i write the code
The same way you call any Objective-C method. With a
Code:
[receiver message]
where "receiver" is the class or instance and "message" is the method, with arguments, if necessary.
__________________
dejo is offline   0 Reply With Quote
Old Apr 3, 2009, 10:16 AM   #6
lazydog
macrumors 6502a
 
Join Date: Sep 2005
Location: Cramlington, UK
Send a message via MSN to lazydog
Actually, the Sun is white!

b e n
lazydog is offline   0 Reply With Quote
Old Apr 3, 2009, 10:25 AM   #7
mack255
Thread Starter
Banned
 
Join Date: Jul 2008
im new can you please tell me the full code im brand new started a couple days ago
mack255 is offline   0 Reply With Quote
Old Apr 3, 2009, 10:28 AM   #8
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by mack255 View Post
im new can you please tell me the full code im brand new started a couple days ago
This is pretty basic Objective-C programming concepts. I'd suggest you step back and learn the basics before you continue with any real coding.
__________________
dejo is offline   0 Reply With Quote
Old Apr 3, 2009, 10:33 AM   #9
mack255
Thread Starter
Banned
 
Join Date: Jul 2008
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
mack255 is offline   0 Reply With Quote
Old Apr 3, 2009, 10:37 AM   #10
eddietr
macrumors 6502a
 
Join Date: Oct 2006
Location: Virginia
Quote:
Originally Posted by mack255 View Post
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?
eddietr is offline   0 Reply With Quote
Old Apr 3, 2009, 10:41 AM   #11
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by mack255 View Post
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
Have you checked out the guides and stickies at the top of the iPhone Programming forum?
__________________
dejo is offline   0 Reply With Quote
Old Apr 3, 2009, 10:45 AM   #12
johnnybluejeans
macrumors 6502
 
Join Date: Jan 2006
Location: New York, NY
Quote:
Originally Posted by mack255 View Post
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://***********/?q=objective+c+tutorial+iphone
__________________

Apple Everything
johnnybluejeans is offline   0 Reply With Quote
Old Apr 3, 2009, 10:54 AM   #13
mack255
Thread Starter
Banned
 
Join Date: Jul 2008
actually i learn really well if someone tells me the code
mack255 is offline   0 Reply With Quote
Old Apr 3, 2009, 11:09 AM   #14
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by mack255 View Post
actually i learn really well if someone tells me the code
Of course! No learning required then. You've already got the answer!
__________________
dejo is offline   0 Reply With Quote
Old Apr 3, 2009, 11:59 AM   #15
eddietr
macrumors 6502a
 
Join Date: Oct 2006
Location: Virginia
Quote:
Originally Posted by mack255 View Post
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.
eddietr is offline   0 Reply With Quote
Old Apr 3, 2009, 12:38 PM   #16
johnnybluejeans
macrumors 6502
 
Join Date: Jan 2006
Location: New York, NY
I'm an awesome physicist when someone writes all the proofs for me.
__________________

Apple Everything
johnnybluejeans is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Library for simple Face and QR Code/Bar Code/Etc detection DarthFoley iPhone/iPad Programming 0 Jan 26, 2014 12:11 PM
Resolved: ML code for OSX server code Processor OS X 10.8 Mountain Lion 5 Jul 27, 2012 11:51 PM
AppStore:"The code you entered is not recognized as valid code" (or Already Redeemed) sevimli OS X 10.8 Mountain Lion 223 Jul 27, 2012 04:50 AM

Forum Jump

All times are GMT -5. The time now is 11:44 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC