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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 10-10-2009, 09:07 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 41
Default Numeric var from a textfield

I've make a small project.
In this project i make a simple equations.

I don't know like declaring a numeric variable and assign to var a textField numeric value for execute the calculator.

A small sample are here:

//------ File .h

NSNumber *myNumber;

//------ File .m
- (void)viewDidLoad
{
//.. various var, ..etc.

myNumber = [[NSNumber alloc] init];
//
//myNumber = [[NSNumber alloc] initWithDouble:0];
[self myFunction]
}

-(void) myFunction{

myNumber = [NSNumber numberWithDouble:[myTextField.text doubleValue]];
float calcoloRisultato;
calc = myNumber/0.8;
// ERROR Calc.

}


----- If i make
double myNumber = [myTextField.text doubleValue];
All is OK
Where is the error?
How to solve this?

I want declare the myNumber var in all class and not only in a function.
Thanks for help me.
jj
jhoncybpr is offline   Reply With Quote
Old 10-10-2009, 09:25 AM   #2 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 14
Default What if...

What if you do it like this?


//------ File .h

double myNumber;

//------ File .m
- (void)viewDidLoad
{
//.. various var, ..etc.


[self myFunction]
}

-(void) myFunction{

myNumber = [myTextField.text doubleValue];
double calcoloRisultato;
calcoloRisultato = myNumber/0.8;
// ERROR Calc.

}
jshake11 is offline   Reply With Quote
Reply

Bookmarks

Tags
nsnumber, uitextfield, var

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: 258
20 members and 238 guests
ADY, Alsahir, Dani77, e2applets, iph_s, JasonR, mer10, Monstertaco, piesia, prchn4christ, Promo Dispenser, Robiwan, Rudy, sebasx, sly24, timle8n1, Touchmint, twerner
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,758
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

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