title: accessing the setMethod of a @property in ios
body: <p>after many hour of tutorials and googling i knew that when we define a property inside the header file the compiler automatically generate the setters and getters here is an example:<br>
  <strong>"example.h"</strong></p>
  
  <pre><code>@property(strong,nonatomic) NSNumber *test;
  </code></pre>
  
  <p><strong>example.m</strong></p>
  
  <pre><code>[self.test setTest [@"3"]];
  </code></pre>
  
  <p>so what i want is to access this method to check the method declaration and here is the reason that i want </p>
  
  <p><strong>Full Scenario</strong></p>
  
  <pre><code>@interface exampleController ()  
  {
  
      int example;
  }
  </code></pre>
  
  <p>// here is a instance variable used to save a value while the app running i am getting this value from a dictionary and then save the value of the example variable to the core data </p>
  
  <p>here is the entity class</p>
  
  <p><strong>exampleEntity.h</strong></p>
  
  <pre><code> @property(strong,nonatomic) NSNumber *example;
  </code></pre>
  
  <p><strong>exampleEntity.m</strong></p>
  
  <pre><code>@dynamic example;
  </code></pre>
  
  <p>// since the instance variable is int we need to cast it to NSNumber so i follow this <a href="https://stackoverflow.com/questions/4358987/objective-c-convert-number-to-nsnumber">link</a></p>
  
  <pre><code>[entry setExample : [NSNumber numberWithInt:example]];
  </code></pre>
  
  <p><strong>Finally</strong> after running this code i go into this exception:</p>
  
  <blockquote>
    <p>*** Terminating app due to uncaught exception 'NSInvalidArgumentException'</p>
  </blockquote>
  
  <p><strong>Full Code</strong></p>
  
  <pre><code>    #import "viewController.h"
      @interface viewController ()  
     {
  
           int example;
      }
  
  
  - (void)viewDidLoad {
  gettingTheExampleValueFromDictionary();
  }
  
  
  
  -(void)gettingTheExampleValueFromDictionary()
  
  
   {
  
                  NSDictionary *dictionary = [NSJSONSerialization    JSONObjectWithData:requestHandler options:0 error:&amp;jsonParsingError];
         example = [[dictionary objectForKey:@"exampleId"] intValue];
  
  
   }
  
  
  
  - (IBAction)doneButton:(id)sender {
  
    [self insertDataToCoreData];
    [self dismissSelf];
  }
  
        -(void)insertDataToCoreData   {
  
     CoreData *coreDataStack = [CoreData defaultStack];
          ExampleEntity *entry = [NSEntityDescription insertNewObjectForEntityForName:
                                      @"ExampleEntity" inManagedObjectContext:coreDataStack.managedObjectContext];
  
              [entry setExample :[NSNumber numberWithInt:example]];
  // here we go into the error //
  
  
  
      [coreDataStack saveContext];
      }
  
  
  
  
  
    @end
  // and if you ask me for entity class here is:
  
   #import &lt;Foundation/Foundation.h&gt;
   @interface ReservationEntity : NSObject
   @property (nonatomic,strong) NSNumber *example;
     @end
  
  
  
   #import "exampleEntity.h"
   @implementation exampleEntity
   @dynamic example;
   @end
   // and if you ask me for core data here is the pic needed //
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/LFp72.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LFp72.png" alt="core data"></a></p>
  
  <pre><code>   // the configuration of xcdatamodel
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/EaXy7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EaXy7.png" alt="configuration of xcdatamodel"></a></p>