iphone - Problems with Float on core-data -


the following code largely inspired example found on net seems work fine, core data entity called "contact" , property called "address" having attribute string, in xcdatamodel. saves data no problem. question : how need modify code ? in order make work after change attribute of property "address" string float in xcdatamodel.

coredatatestoneappdelegate *appdelegate = [[uiapplication sharedapplication] delegate];  nsmanagedobjectcontext *context = [appdelegate managedobjectcontext]; nsmanagedobject *newcontact; newcontact = [nsentitydescription insertnewobjectforentityforname:@"contacts" inmanagedobjectcontext:context]; [newcontact setvalue:address_inputfield.text forkey:@"address"]; nserror *error; [context save:&error]; 

to store float in core data float attribute, wrap in nsnumber object this:

[newcontact setvalue:[nsnumber numberwithfloat:floatvalue] forkey:@"address"]; 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -