I made an new "integer 16" entity in core data called "height". I then had core data create a subclass. The entity "height" came up in the subclass as "@property (nonatomic, retain) NSNumber * height;".
I created an outlet by dragging from a "text field" in my storyboard into my "Bedrooms" m-class and it created "@property (strong, nonatomic) IBOutlet UITextField *height;".
I am just trying to hook up: "@property (nonatomic, retain) NSNumber * height;". to: "@property (strong, nonatomic) IBOutlet UITextField *height;"
I dont know why this is so hard for me. Some things are easy others are hard. Help would be great and I will toast a shot of great tequila to you if you can help me!
That's not a connection you can make graphically. Text fields accept NSStrings, not NSNumbers. So you will need to take your number and format it as a string in code, then supply that string to the text field.
So I need to transform the "integer 16" number and transform it to a string, not sure how to do that. Perhaps it is easier to store them as a string in core data, enter them as a string in the interface and then manipulate them as a number when ever I need to do calculations.
I will research how to transform a string into a number. Working with integers in xcode is not easy. Strings and pictures are however. Perhaps core data is not suppose to be used for numbers.
All I want to do is store, display and manipulate an integer that has been entered in a textfield, now I have to find out how to transform the numbers to strings.
Anything you could do for me to help me get a number from the interface into core data would be great.
It does not matter what you use in Core Data for this; it is not something that can be graphically done. There is going to be code involved, no matter what.
Text fields work with strings. If the text field is only supposed to contain digits, then those digits will be treated as a string. If this is on the iPhone, this is easily enforced by using the number pad keyboard. If this is the iPad, then you are going to have to take steps to make sure that letters are not entered. There is going to be work involved.
As far as how you store it in Core Data, do you need it to be a numerical value, or do you only need a string? Are you going to be doing math with it? Are you going to want to format it in different ways, such as currency? If so, then you probably want the number. If not, then a string is probably sufficient.
It doesn't really matter, because ultimately you can switch back and forth as necessary. NSString has methods such as intValue and floatValue that can be used to extract primitive numbers from strings. NSNumber has methods that allow you to construct NSNumber objects from those primitive values.
I thought that there would be an easy way to connect "@property (strong, nonatomic) IBOutlet NSNumber *height;" created by core data, to an IB textfield "height" that will display that value, let the user change it and store it back into core data.
I know there will be code involved, I just want to learn how to code it. I can store pictures, dates, and words, but from what I understand here and in the 1,000 tutorials I have read it is going to take some real heavy lifting and lots of work to force core data to work with the interface in Nib or storyboard to use simple numbers. I understand that and I am willing to do research with anyone that understands this problem.
I just cant believe that it is easier to store pictures than get a two digit number from the interface to core data. But if it takes 1,000 like of code to get this done, I guess I will have to do it.