string to interger comparison?
how do i compare what i have inputted in a text box to an interger?
my main goal is to compare the number of inputted characters to an amount i want.
my main goal is to compare the number of inputted characters to an amount i want.
What language, API, etc. are you using?
if Cocoa:
if([[textbox objectValue] intValue] == int)
If you want to compare the amount of characters entered though you will need to get the length of the string in the textbox with [[textbox ObjectValue] length]
if([[textbox objectValue] intValue] == int)
If you want to compare the amount of characters entered though you will need to get the length of the string in the textbox with [[textbox ObjectValue] length]
if([[textbox stringValue] length] == int)
If you use kodex's code, you will need to make sure that you make the "O" in ObjectValue lowercase: [[textbox objectValue] length]
Hope this helps
BTW kodex: What is the difference between objectValue and stringValue? Is there an advantage to using objectValue?
If you use kodex's code, you will need to make sure that you make the "O" in ObjectValue lowercase: [[textbox objectValue] length]
Hope this helps
BTW kodex: What is the difference between objectValue and stringValue? Is there an advantage to using objectValue?
[[textBox stringValue] length] is utterly irrelevant...
OSC - Why? Did you see the second line of the OP?
Hairball183 Wrote:If you use kodex's code, you will need to make sure that you make the "O" in ObjectValue lowercase: [[textbox objectValue] length]
Hope this helps
BTW kodex: What is the difference between objectValue and stringValue? Is there an advantage to using objectValue?
Sorry about the Caps error was just typing a quick reply in safari and didn't notice.
As far as using objectValue over stringValue, there was an issue I had in one of my programs a long time ago (that I can't recall) that wasn't functioning correctly with stringValue so I just got into the habit of using objectValue instead, as far as I know objectValue just uses stringValue if a string value is present.
OSC: I wasn't sure if he was asking about the length of a string because he said his goal was to compare the number of inputed characters which would make his first question irrelevant, I figured I would supply both answers to prevent the classic "No I meant this...." reply.
Whoops, serves me right for not reading closely enough
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| formatting value in a string | sefiroths | 3 | 3,527 |
Dec 12, 2011 02:41 AM Last Post: sefiroths |
|
| Getting a value from a String | Megamac04 | 5 | 3,322 |
Jan 31, 2010 04:23 PM Last Post: smasher |
|
| Parsing from a string to something faster? | Madrayken | 3 | 2,707 |
Aug 10, 2009 03:32 PM Last Post: smasher |
|
| Is -fconstant-string-class broken under the XCode/Next runtime | Justin Brimm | 17 | 6,700 |
Jun 12, 2008 01:04 PM Last Post: Justin Brimm |
|
| char array versus pointer to string constant question | WhatMeWorry | 7 | 6,642 |
Jan 30, 2007 12:26 PM Last Post: bronxbomber92 |
|

