PDA

View Full Version : Can't Use "setIntValue"




sheepopo39
Aug 15, 2010, 11:45 AM
I've recently started programming for the iphone/ipad. I can program in Objective-C on the Mac.

For some odd reason, "setIntValue" is not available on the iphone/ipad sdk, and I was wondering what the equivalent of it was?

Edit: Found you had to use SetValue, but you have to convert it to a string first. Anyone know another way to do it without having to convert it to a string, as this is a waste of time. Why did apple remove the setXValue from the UIKit?



chown33
Aug 15, 2010, 12:54 PM
Add a category.


Why did apple remove the setXValue from the UIKit?
http://en.wikipedia.org/wiki/Minimalism_(computing)

sheepopo39
Aug 15, 2010, 01:55 PM
Okay, so I got it to work by adding this line of code
"[label setValue:[NSString stringWithFormat:@"%d", i]];"

But it over laps anything that was there before, is there any other way?

So the question is, is there a method in the iphone/ipad sdk that will have the same function as setXValue?

Edit: All of the other methods of doing it that I found, all had the new text overlapping the old text. Won't this be a problem if you need to often change the value in the same textField?

chown33
Aug 15, 2010, 02:33 PM
Okay, so I got it to work by adding this line of code
"[label setValue:[NSString stringWithFormat:@"%d", i]];"

But it over laps anything that was there before, is there any other way?

The text property of UILabel?

I see no value property for UILabel or its superclasses. Is there a compiler warning for setValue:?

What type is your 'label' variable? Its name suggests UILabel type, but you mention "textField", so it's unclear. FWIW, UITextField has no value property, either, but it has a text property.

Are you running on the simulator?


All of the other methods of doing it that I found, all had the new text overlapping the old text.
What are the other methods? Be specific.

How did you find those other methods?
I found the text property quite easily in the UILabel and UITextField reference docs.
http://developer.apple.com/iphone/library/documentation/uikit/reference/UILabel_Class/Reference/UILabel.html
http://developer.apple.com/iphone/library/documentation/uikit/reference/UITextField_Class/Reference/UITextField.html

Google search terms:
uilabel iphone reference
uitextfield iphone reference

pflau
Aug 15, 2010, 03:05 PM
Edit: All of the other methods of doing it that I found, all had the new text overlapping the old text. Won't this be a problem if you need to often change the value in the same textField?

There would not be a problem. Reason being that you don't know how the property setter is implemented and you shouldn't care. You just need to supply a NSString object. If you don't want to keep creating new NSString objects, maybe you can try NSMutableString.