title: Realm, -[__NSCFString timeIntervalSince1970]: unrecognized selector sent to instance
body: <p>I ask for your help. 
  I want to save my response to Realm db. </p>
  
  <p>it`s my test model</p>
  
  <pre><code> @interface CurrencyInfo : RLMObject
  
      @property (strong, nonatomic) NSDate *date;
  
      - (instancetype)initWithJSONDictionary:(NSDictionary *)jsonDictionary;
  
      @end
      RLM_ARRAY_TYPE(CurrencyInfo)
  
  
      @implementation CurrencyInfo
  
      - (instancetype)initWithJSONDictionary:(NSDictionary *)jsonDictionary {
          self = [super init];
          if(self) {
              _date = jsonDictionary[@"date"];
          }
  
          return self;
      }
  
  @end
  </code></pre>
  
  <p>it`s my api manager class </p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  typedef void(^ResponseHandler)(BOOL success, id object, NSError *error);
  
  @interface RestApiManager : NSObject &lt;NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSessionTaskDelegate&gt;
  
  +(instancetype)sharedManager;
  
  -(void)fetchCurrencyInfoWithCompletionHandler:(ResponseHandler)handler;
  
  @end
  
  @implementation RestApiManager {
  
      NSURLSession *_session;
      NSURLSessionDataTask *_dataTask;
  
  }
  
  + (instancetype)sharedManager {
      static id sharedInstance = nil;
      static dispatch_once_t onceToken;
      dispatch_once(&amp;onceToken, ^(void) {
          sharedInstance = [self new];
      });
  
      return sharedInstance;
  }
  
  - (void)fetchCurrencyInfoWithCompletionHandler:(ResponseHandler)handler {
  
      _dataTask = [self.session dataTaskWithURL:[NSURL URLWithString:@"http://resources.finance.ua/ru/public/currency-cash.json"] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
          NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
          if (httpResponse.statusCode == 200) {
              NSDictionary *result = [NSJSONSerialization JSONObjectWithData:data options:nil error:&amp;error];
              CurrencyInfo *info = [[CurrencyInfo alloc] initWithJSONDictionary:result];
              NSLog(@"%@", info.date);
              handler(YES, info, error);
          }
      }];
      [_dataTask resume];
  }
  
  - (NSURLSession *)session {
      if (!_session) {
          NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
          _session = [NSURLSession sessionWithConfiguration:sessionConfiguration];
      }
      return _session;
  }
  
  @end
  </code></pre>
  
  <p>and here is my ViewController class</p>
  
  <pre><code>@implementation ViewController
  
  - (void)viewDidLoad {
      [super viewDidLoad];
  
      __weak typeof(self) weakSelf = self;
  
      [[RestApiManager sharedManager] fetchCurrencyInfoWithCompletionHandler:^(BOOL success, CurrencyInfo * object, NSError *error) {
  
          [weakSelf saveInDB:object];
  
      }];
  }
  
  - (void)saveInDB:(CurrencyInfo *) info{
      RLMRealm *realm = [RLMRealm defaultRealm];
      [realm transactionWithBlock:^(void) {
          [realm addObject:info];
      }];
  }
  
  @end
  </code></pre>
  
  <p>So, nothing special, I just want to save response to db. 
  But I have next issue </p>
  
  <blockquote>
    <p>-[__NSCFString timeIntervalSince1970]: unrecognized selector sent to instance 0x78784c60</p>
  </blockquote>
  
  <p>full stacktrace </p>
  
  <pre><code>2016-02-14 18:12:45.784 TestRealmDB[4814:240669] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString timeIntervalSince1970]: unrecognized selector sent to instance 0x78784c60'
  *** First throw call stack:
  (
      0   CoreFoundation                      0x0150da14 __exceptionPreprocess + 180
      1   libobjc.A.dylib                     0x00fcee02 objc_exception_throw + 50
      2   CoreFoundation                      0x01516d63 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
      3   CoreFoundation                      0x014546bd ___forwarding___ + 1037
      4   CoreFoundation                      0x0145428e _CF_forwarding_prep_0 + 14
      5   TestRealmDB                         0x0013da14 _ZL20RLMDateTimeForNSDateP6NSDate + 36
      6   TestRealmDB                         0x00133699 _ZL11RLMSetValueP13RLMObjectBasejP6NSDate + 89
      7   TestRealmDB                         0x001320c6 RLMDynamicSet + 1334
      8   TestRealmDB                         0x00176ffa RLMAddObjectToRealm + 2810
      9   TestRealmDB                         0x002729b8 -[RLMRealm addObject:] + 56
      10  TestRealmDB                         0x000cc3c3 __27-[ViewController saveInDB:]_block_invoke + 51
      11  TestRealmDB                         0x00271c6b -[RLMRealm transactionWithBlock:error:] + 107
      12  TestRealmDB                         0x00271bab -[RLMRealm transactionWithBlock:] + 91
      13  TestRealmDB                         0x000cc320 -[ViewController saveInDB:] + 224
      14  TestRealmDB                         0x000cc18d __29-[ViewController viewDidLoad]_block_invoke + 141
      15  TestRealmDB                         0x000cd214 __57-[RestApiManager fetchCurrencyInfoWithCompletionHandler:]_block_invoke + 436
      16  CFNetwork                           0x039cd087 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 48
      17  CFNetwork                           0x039e1153 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 353
      18  Foundation                          0x00c7b96f __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 12
      19  Foundation                          0x00b9f85f -[NSBlockOperation main] + 108
      20  Foundation                          0x00b7fce4 -[__NSOperationInternal _start:] + 697
      21  Foundation                          0x00b7fa24 -[NSOperation start] + 83
      22  Foundation                          0x00b7f862 __NSOQSchedule_f + 245
      23  libdispatch.dylib                   0x02e756fd _dispatch_client_callout + 14
      24  libdispatch.dylib                   0x02e5d33e _dispatch_queue_drain + 1065
      25  libdispatch.dylib                   0x02e5cc89 _dispatch_queue_invoke + 563
      26  libdispatch.dylib                   0x02e5e732 _dispatch_root_queue_drain + 442
      27  libdispatch.dylib                   0x02e5e571 _dispatch_worker_thread3 + 108
      28  libsystem_pthread.dylib             0x0319743e _pthread_wqthread + 1050
      29  libsystem_pthread.dylib             0x03194f72 start_wqthread + 34
  )
  libc++abi.dylib: terminating with uncaught exception of type NSException
  </code></pre>