iphone - Obj-C: Incompatible pointer types assigning to 'UITextfield *_strong' from 'NSNumber *_strong -


ok ive looked @ other similar questions cant figure out why nsnumber not compatible uitext field.

my .h

@property (weak, nonatomic) iboutlet uitextfield *initialbudget; @property (weak, nonatomic) iboutlet uitextfield *expenses; @property (weak, nonatomic) iboutlet uitextfield *timespent; @property (weak, nonatomic) iboutlet uitextfield *incomeperhour; 

these calculations

- (ibaction)calculateresults:(id)sender {     double budget = [initialbudget.text doublevalue ];     double expense = [expenses.text doublevalue];     double time = [timespent.text doublevalue];      double hourlyincome = (budget - expense)/time;     nsnumber *resultnumber = [[nsnumber alloc] initwithdouble:hourlyincome];     incomeperhour = resultnumber; } 

any great, thanks

you want set uitextfield's text property.

[incomeperhour settext:[resultnumber stringvalue]]; 

bye !

edit : can without nsnumber :

[incomeperhour settext:[nsstring stringwithformat:@"%f", hourlyincome]]; 

you'll have less precision due %f (rounds 6 decimal default), can use %.42f if want 42 decimals.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -