How can I retrieve a textfields text and store it as an integer 32 in core data?

I'm trying to get the textfields text, convert it to an int, and store it in a core data integer 32 attribute. I'm getting an error in the process:

Implicit conversion of 'int' to 'NSNumber' disallowed  with arc

Here is What I've tried:

// trying to convert
int intLength = [self.length.text intValue];

// trying to set the current garden attribute to the converted int
self.currentGarden.length = intLength;

How can I fix this?

Answers


NSNumber is an object and is not the same as int. Try creating a NSNumber using the constructor:

self.currentGarden.length = [NSNumber numberWithInt:intLength];

Need Your Help

Choosing the right classes (from nouns) to build my project

java class

The thing is that I've been coding the following exercise and I wanted to ask you something about it:

Dynamically filtering clientdataset content

delphi n-tier datasnap

I'm asking myself a question about the way to filter content of a clientdataset in a 3 tier datasnap architecture : Oracle DB <=> My Datasnap Server <=> My Datasnap clients

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.