title: -[__NSCFNumber length]: unrecognized selector sent to instance 0xb000000000000002
body: <p>I knew there are lots of same kind of question available but I am facing something different. I got this error while saving the data into core data. First let me tell you my scenario. I am calling an API and store it into database. There is no issue but for lazy loading when I am calling the same API (for the next dataset) and when I try to again push it to database each and every time I am getting this error and application crashed. Even I have tried with some static data but in second case it crash.</p>
  
  <p><strong>ActivityViewController</strong></p>
  
  <pre><code>func loadActivity() {
      CISyncManager.sharedManager().pullActivity(complition: { (activities) -&gt; () in
         CILocalStorageManager.sharedManager().storeActivity(activities, complition: { (success, error) -&gt; () in
             // other stuffs
          })
      })
  }
  
  func loadMoreActivity(lastId: String) {
      CISyncManager.sharedManager().pullActivity(lastId: lastId complition: { (activities) -&gt; () in
         CILocalStorageManager.sharedManager().storeActivity(activities, complition: { (success, error) -&gt; () in
             // other stuffs
          })
      })
  }
  </code></pre>
  
  <p><strong>CILocalStorageManager</strong></p>
  
  <pre><code>func storeActivity(activities: [AnyObject], complition:((success: Bool, error: NSError?) -&gt; ())?) {
      let queue = dispatch_queue_create("com.CILSM.activity", nil)
      for object in activities {
          dispatch_async(queue, { () -&gt; Void in
              //design the context with `object`
              self.saveChanges()
          })
      }
  
      if complition != nil {
          complition!(success: true, error: nil)
      }
  }
  
  func saveChanges() {
      if !CIDataManager.sharedManager().managedObjectContext.hasChanges {
          return
      }
  
      CIDataManager.sharedManager().managedObjectContext.performBlock { () -&gt; Void in
          do {
              try CIDataManager.sharedManager().managedObjectContext.save()
              print("save")
          } catch {
              print("Error : \(error)")
          }
      }
  }
  </code></pre>
  
  <p><strong>Crash Log</strong></p>
  
  <pre><code>2016-03-30 13:43:14.323 MyApp[2703:66401] -[__NSCFNumber length]: unrecognized selector sent to instance 0xb000000000000002
  2016-03-30 13:43:27.714 MyApp[2703:66401] CoreData: error: Serious application error.  Exception was caught during Core Data change processing.  This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  -[__NSCFNumber length]: unrecognized selector sent to instance 0xb000000000000002 with userInfo (null)
  2016-03-30 13:43:31.958 MyApp[2703:66401] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0xb000000000000002'
  *** First throw call stack:
  (
      0   CoreFoundation                      0x0000000105bfde65 __exceptionPreprocess + 165
      1   libobjc.A.dylib                     0x0000000105534deb objc_exception_throw + 48
      2   CoreFoundation                      0x0000000105c0648d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
      3   CoreFoundation                      0x0000000105b5390a ___forwarding___ + 970
      4   CoreFoundation                      0x0000000105b534b8 _CF_forwarding_prep_0 + 120
      5   CoreFoundation                      0x0000000105ad5dfa CFStringCompareWithOptionsAndLocale + 202
      6   Foundation                          0x00000001021a1e37 -[NSString compare:options:range:] + 29
      7   Foundation                          0x000000010222d3bd -[NSComparisonPredicateOperator performPrimitiveOperationUsingObject:andObject:] + 365
      8   Foundation                          0x00000001021fb719 -[NSPredicateOperator performOperationUsingObject:andObject:] + 286
      9   Foundation                          0x00000001021fae3c -[NSComparisonPredicate evaluateWithObject:substitutionVariables:] + 313
      10  CoreData                            0x0000000104a1f931 -[NSFetchedResultsController(PrivateMethods) _objectInResults:] + 97
      11  CoreData                            0x0000000104a1fb09 -[NSFetchedResultsController(PrivateMethods) _preprocessInsertedObjects:insertsInfo:newSectionNames:] + 265
      12  CoreData                            0x0000000104a21dc6 __77-[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:]_block_invoke + 1366
      13  CoreData                            0x00000001049348a7 developerSubmittedBlockToNSManagedObjectContextPerform + 199
      14  CoreData                            0x000000010493476e -[NSManagedObjectContext performBlockAndWait:] + 222
      15  CoreData                            0x0000000104a21857 -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] + 119
      16  CoreFoundation                      0x0000000105bca69c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
      17  CoreFoundation                      0x0000000105bca3db _CFXRegistrationPost + 427
      18  CoreFoundation                      0x0000000105bca142 ___CFXNotificationPost_block_invoke + 50
      19  CoreFoundation                      0x0000000105c0f972 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1986
      20  CoreFoundation                      0x0000000105ac5279 _CFXNotificationPost + 633
      21  Foundation                          0x0000000102199109 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
      22  CoreData                            0x000000010491a606 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 70
      23  CoreData                            0x000000010491a58a -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:deletions:updates:refreshes:deferrals:] + 1530
      24  CoreData                            0x0000000104914a0b -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 3147
      25  CoreData                            0x0000000104918444 -[NSManagedObjectContext save:] + 148
      26  MyApp                          0x0000000100f06a29 _TFC10MyApp21CILocalStorageManager11saveChangesfS0_FT_T_ + 217
      27  MyApp                          0x0000000100f06d12 _TToFC10MyApp21CILocalStorageManager11saveChangesfS0_FT_T_ + 34
      28  MyApp                          0x0000000100f037b0 _TFC10MyApp21CILocalStorageManager17storeHomeActivityfS0_FTCSo7NSArray10complitionGSqFT7successSb5errorGSqCSo7NSError__T___T_ + 384
      29  MyApp                          0x0000000100f03a34 _TToFC10MyApp21CILocalStorageManager17storeHomeActivityfS0_FTCSo7NSArray10complitionGSqFT7successSb5errorGSqCSo7NSError__T___T_ + 260
      30  MyApp                          0x0000000100eea766 _TFFFC10MyApp13CIDataManager25requestToLoadHomeActivityFS0_FT24requestToLoadNewActivitySb10completionGSqFT_T__5errorGSqFT9errorTypeOS_9ErrorType7messageGSqSS__T___T_U_FCSo7NSArrayT_U_FT_T_ + 502
      31  MyApp                          0x0000000100ea1f27 _TTRXFo__dT__XFdCb__dT__ + 39
      32  libdispatch.dylib                   0x000000010690ee5d _dispatch_call_block_and_release + 12
      33  libdispatch.dylib                   0x000000010692f49b _dispatch_client_callout + 8
      34  libdispatch.dylib                   0x00000001069172af _dispatch_main_queue_callback_4CF + 1738
      35  CoreFoundation                      0x0000000105b5dd09 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
      36  CoreFoundation                      0x0000000105b1f2c9 __CFRunLoopRun + 2073
      37  CoreFoundation                      0x0000000105b1e828 CFRunLoopRunSpecific + 488
      38  GraphicsServices                    0x00000001083b6ad2 GSEventRunModal + 161
      39  UIKit                               0x00000001026a6610 UIApplicationMain + 171
      40  MyApp                          0x0000000101002f1d main + 109
      41  libdyld.dylib                       0x000000010696492d start + 1
  )
  libc++abi.dylib: terminating with uncaught exception of type NSException
  </code></pre>
  
  <p>If you guys need any other information please let me know.</p>