Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-25-2009, 01:52 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2009
Location: Kijabe, Kenya | Stoney Creek, Hamilton
Age: 19
Posts: 30
kiambogo is on a distinguished road
Default Checking value of a text box

Hey everyone,

I have a text box in an app i am making. The user inputs a number into the text box and it does some stuff from there. Anyways, I want the user to only input numbers 1-12, not higher. How should I input code so that if they inputted a number higher then 12, then an alert message pops up and tells them to put a number lower then 12 in. I have attempted and failed with this code:
Code:
-(void)sidesOfPolygons:(id)sender{
	NSString *msg = nil;
	if (polygonsSides.text > 12) 
		msg = @"Please choose a number between 1 and 12.";
	NSLog(@"MSG worked, moving on to the alert.");
		UIAlertView *alert = [[UIAlertView alloc]
							  initWithTitle:@"Area of Polygons"
							  message:msg
							  delegate:self
							  otherButtonTitles:nil];
		[alert show];
		[alert release];
		[msg release];
		}
I would also like the text box to clear after the message.
Any help is greatly appreciated.

Thanks,
kiambogo
__________________
Math Tools - Geometry (Coming Soon)
kiambogo is offline   Reply With Quote
Old 12-25-2009, 02:51 AM   #2 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 471
WillSDev is on a distinguished road
Default

I may be wrong, but i dont think you can see if a number (int) is less than a label, because the label isnt an int.

do something like this:
Code:
int pSides = polygonsSides.text;

-(void)sidesOfPolygons:(id)sender{
	NSString *msg = nil;
	if (pSides > 12) 
		msg = @"Please choose a number between 1 and 12.";
	NSLog(@"MSG worked, moving on to the alert.");
		UIAlertView *alert = [[UIAlertView alloc]
							  initWithTitle:@"Area of Polygons"
							  message:msg
							  delegate:self
							  otherButtonTitles:nil];
		[alert show];
		[alert release];
		[msg release];
		}
HTH
__________________
01010111 01101111 01110111 00101100 00100000 01001010 01110101 01110011 01110100 01101001 01101100 01101100 00110100 00110101 00101100 00100000 01111001 01101111 01110101 01110010 00100000 01110011 01101111 01101111 01101111 00100000 01100011 01101111 01101111 01101111 01101100
WillSDev is offline   Reply With Quote
Old 12-25-2009, 04:46 AM   #3 (permalink)
Registered Member
 
Join Date: Aug 2009
Location: Kijabe, Kenya | Stoney Creek, Hamilton
Age: 19
Posts: 30
kiambogo is on a distinguished road
Default

Thanks for the quick reply,

I get two warnings though. First, is about the 'int pSides = polygonsSides.text'
The message says "warning: initializaition makes integer from pointer without a cast." the second message is about 'otherButtonTitles:nil];' the message is "warning: no '-initWithTitle:message:delegatetherButtonTitles:' method found"

Any help to solve these problems is appreciated.

Thanks,
kiambogo
__________________
Math Tools - Geometry (Coming Soon)
kiambogo is offline   Reply With Quote
Old 12-25-2009, 03:18 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 471
WillSDev is on a distinguished road
Default

check out this example:
http://www.aniphonecoder.com/30-days/GetLetter.zip
__________________
01010111 01101111 01110111 00101100 00100000 01001010 01110101 01110011 01110100 01101001 01101100 01101100 00110100 00110101 00101100 00100000 01111001 01101111 01110101 01110010 00100000 01110011 01101111 01101111 01101111 00100000 01100011 01101111 01101111 01101111 01101100
WillSDev is offline   Reply With Quote
Old 12-28-2009, 04:24 AM   #5 (permalink)
Registered Member
 
Join Date: Aug 2009
Location: Kijabe, Kenya | Stoney Creek, Hamilton
Age: 19
Posts: 30
kiambogo is on a distinguished road
Default

Quote:
Originally Posted by WillSDev View Post
Thanks for the input. This has helped me quite a bit. However, I am still stuck trying to figure out how to set a string as a value of integers between 12 and 100. I just need to know what to put. As of now, I have this:
Code:
NSString *higher12 = [int => 12];
	if([polygonsSides.text isEqualToString:higher12])
	{
Everything else works besides this.

Any help is greatly appreciated!

Thanks,
kiambogo
__________________
Math Tools - Geometry (Coming Soon)
kiambogo is offline   Reply With Quote
Old 12-28-2009, 07:04 PM   #6 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 471
WillSDev is on a distinguished road
Default

my only idea is to make an int
like: myInt => 12

then make it a string like:
NSString *higher12 = [NSString stringWithFormat:@"%d", myInt];

then your if statement here
__________________
01010111 01101111 01110111 00101100 00100000 01001010 01110101 01110011 01110100 01101001 01101100 01101100 00110100 00110101 00101100 00100000 01111001 01101111 01110101 01110010 00100000 01110011 01101111 01101111 01101111 00100000 01100011 01101111 01101111 01101111 01101100
WillSDev is offline   Reply With Quote
Old 12-30-2009, 01:48 AM   #7 (permalink)
Registered Member
 
Join Date: Aug 2009
Location: Kijabe, Kenya | Stoney Creek, Hamilton
Age: 19
Posts: 30
kiambogo is on a distinguished road
Default

Quote:
Originally Posted by WillSDev View Post
my only idea is to make an int
like: myInt => 12

then make it a string like:
NSString *higher12 = [NSString stringWithFormat:@"%d", myInt];

then your if statement here
Thanks for your input. I get one error message on
Code:
int *myInt => 12;
The error says "expected expression before '>' token".

Any idea what to do?

Thanks,
kiambogo
__________________
Math Tools - Geometry (Coming Soon)
kiambogo is offline   Reply With Quote
Old 08-09-2010, 06:58 PM   #8 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 2
Davcom is on a distinguished road
Default

Quote:
Originally Posted by kiambogo View Post
Thanks for your input. I get one error message on
Code:
int *myInt => 12;
The error says "expected expression before '>' token".

Any idea what to do?

Thanks,
kiambogo
You need to convert that textbox text to a number first like this : textbox.text.integerValue

Now , you can use that in your like if(textbox.text.integerValue > 100)..etc
Davcom is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 331
12 members and 319 guests
akacaj, alexP, ClerurcifeDer, Duncan C, givensur, GraffitiCircus, guusleijsten, JmayLive, NetGuru, Paul Slocum, Punkjumper, Sloshmonster
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:47 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0