title: Weird crash in iphone app with iOS 9
body: <p>I'm getting this crash report on crashlytics for my app on a device running iOS 9.2. It doesn't happen every time and it doesn't always happen at the same point in the app. sometimes when the user has just opened the other times when he has gone further into it. I can see in the report which line is problematic but I don't understand the error.</p>
  
  <pre><code># OS Version: 9.2.1
  # Device: iPhone 6
  # RAM Free: 27.6%
  # Disk Free: 20.6%
  
  #0. Crashed: com.apple.main-thread
  0  libswiftCore.dylib             0x100a71c5c _assertionFailed(StaticString, String, StaticString, UInt, flags : UInt32) -&gt; Never (__hidden#16085_:167)
  1  libswiftCore.dylib             0x100a919c0 _hidden#1062_ + 504
  2  libswiftCore.dylib             0x100a917c8 swift_errorInMain + 26
  3  Matura                         0x10010b570 specialized APIAsync.getRealmObjectBasedOnString(type : String) -&gt; Object.Type? (APIAsync.swift)
  4  Matura                         0x10010cec0 specialized APIAsync.checkUserExists(email : String) -&gt; [AnyObject] (APIAsync.swift)
  5  Matura                         0x10010dacc specialized APIAsync.login(email : String, password : String, callback : (Bool, String) -&gt; ()) -&gt; () (APIAsync.swift)
  6  Matura                         0x1000cf444 specialized LoginViewController.login(UIButton) -&gt; () (LoginViewController.swift)
  7  Matura                         0x1000ce644 @objc LoginViewController.login(UIButton) -&gt; () (LoginViewController.swift)
  8  UIKit                          0x18852fe50 -[UIApplication sendAction:to:from:forEvent:] + 100
  9  UIKit                          0x18852fdcc -[UIControl sendAction:to:forEvent:] + 80
  10 UIKit                          0x188517a88 -[UIControl _sendActionsForEvents:withEvent:] + 416
  11 UIKit                          0x18852f6e4 -[UIControl touchesEnded:withEvent:] + 572
  12 UIKit                          0x18852f314 -[UIWindow _sendTouchesForEvent:] + 804
  13 UIKit                          0x188527e30 -[UIWindow sendEvent:] + 784
  14 UIKit                          0x1884f84cc -[UIApplication sendEvent:] + 248
  15 UIKit                          0x1884f6794 _UIApplicationHandleEventQueue + 5528
  16 CoreFoundation                 0x1837bcefc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
  17 CoreFoundation                 0x1837bc990 __CFRunLoopDoSources0 + 540
  18 CoreFoundation                 0x1837ba690 __CFRunLoopRun + 724
  19 CoreFoundation                 0x1836e9680 CFRunLoopRunSpecific + 384
  20 GraphicsServices               0x184bf8088 GSEventRunModal + 180
  21 UIKit                          0x188560d90 UIApplicationMain + 204
  22 Matura                         0x1000c5748 main (EngleskiPitanja.swift:15)
  23 libdispatch.dylib              0x18328a8b8 (Missing)
  
  --
  
  #0. Crashed: com.apple.main-thread
  0  libswiftCore.dylib             0x100a71c5c _assertionFailed(StaticString, String, StaticString, UInt, flags : UInt32) -&gt; Never (__hidden#16085_:167)
  1  libswiftCore.dylib             0x100a919c0 _hidden#1062_ + 504
  2  libswiftCore.dylib             0x100a917c8 swift_errorInMain + 26
  3  Matura                         0x10010b570 specialized APIAsync.getRealmObjectBasedOnString(type : String) -&gt; Object.Type? (APIAsync.swift)
  4  Matura                         0x10010cec0 specialized APIAsync.checkUserExists(email : String) -&gt; [AnyObject] (APIAsync.swift)
  5  Matura                         0x10010dacc specialized APIAsync.login(email : String, password : String, callback : (Bool, String) -&gt; ()) -&gt; () (APIAsync.swift)
  6  Matura                         0x1000cf444 specialized LoginViewController.login(UIButton) -&gt; () (LoginViewController.swift)
  7  Matura                         0x1000ce644 @objc LoginViewController.login(UIButton) -&gt; () (LoginViewController.swift)
  8  UIKit                          0x18852fe50 -[UIApplication sendAction:to:from:forEvent:] + 100
  9  UIKit                          0x18852fdcc -[UIControl sendAction:to:forEvent:] + 80
  10 UIKit                          0x188517a88 -[UIControl _sendActionsForEvents:withEvent:] + 416
  11 UIKit                          0x18852f6e4 -[UIControl touchesEnded:withEvent:] + 572
  12 UIKit                          0x18852f314 -[UIWindow _sendTouchesForEvent:] + 804
  13 UIKit                          0x188527e30 -[UIWindow sendEvent:] + 784
  14 UIKit                          0x1884f84cc -[UIApplication sendEvent:] + 248
  15 UIKit                          0x1884f6794 _UIApplicationHandleEventQueue + 5528
  16 CoreFoundation                 0x1837bcefc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
  17 CoreFoundation                 0x1837bc990 __CFRunLoopDoSources0 + 540
  18 CoreFoundation                 0x1837ba690 __CFRunLoopRun + 724
  19 CoreFoundation                 0x1836e9680 CFRunLoopRunSpecific + 384
  20 GraphicsServices               0x184bf8088 GSEventRunModal + 180
  21 UIKit                          0x188560d90 UIApplicationMain + 204
  22 Matura                         0x1000c5748 main (EngleskiPitanja.swift:15)
  23 libdispatch.dylib              0x18328a8b8 (Missing)
  
  #1. com.apple.libdispatch-manager
  0  libsystem_kernel.dylib         0x1833a94fc kevent_qos + 8
  1  libdispatch.dylib              0x18326c94c _dispatch_mgr_invoke + 232
  2  libdispatch.dylib              0x18325b7bc _dispatch_source_invoke + 50
  
  #2. Thread
  0  libsystem_kernel.dylib         0x1833a8b6c __workq_kernreturn + 8
  1  libsystem_pthread.dylib        0x18346d530 _pthread_wqthread + 1284
  2  libsystem_pthread.dylib        0x18346d020 start_wqthread + 4
  
  #3. Thread
  0  libsystem_kernel.dylib         0x1833a8b6c __workq_kernreturn + 8
  1  libsystem_pthread.dylib        0x18346d530 _pthread_wqthread + 1284
  2  libsystem_pthread.dylib        0x18346d020 start_wqthread + 4
  
  #4. Thread
  0  libsystem_kernel.dylib         0x1833a8b6c __workq_kernreturn + 8
  1  libsystem_pthread.dylib        0x18346d530 _pthread_wqthread + 1284
  2  libsystem_pthread.dylib        0x18346d020 start_wqthread + 4
  
  #5. Thread
  0  libsystem_kernel.dylib         0x1833a8b6c __workq_kernreturn + 8
  1  libsystem_pthread.dylib        0x18346d530 _pthread_wqthread + 1284
  2  libsystem_pthread.dylib        0x18346d020 start_wqthread + 4
  
  #6. Thread
  0  libsystem_kernel.dylib         0x1833a8b6c __workq_kernreturn + 8
  1  libsystem_pthread.dylib        0x18346d530 _pthread_wqthread + 1284
  2  libsystem_pthread.dylib        0x18346d020 start_wqthread + 4
  
  #7. com.twitter.crashlytics.ios.MachExceptionServer
  0  Matura                         0x10013615c CLSProcessRecordAllThreads (CLSProcess.c:376)
  1  Matura                         0x10013615c CLSProcessRecordAllThreads (CLSProcess.c:376)
  2  Matura                         0x10013600c CLSProcessRecordAllThreads (CLSProcess.c:407)
  3  Matura                         0x1001262b0 CLSHandler (CLSHandler.m:26)
  4  Matura                         0x100121278 CLSMachExceptionServer (CLSMachException.c:446)
  5  libsystem_pthread.dylib        0x18346fb28 _pthread_body + 156
  6  libsystem_pthread.dylib        0x18346fa8c _pthread_body + 154
  7  libsystem_pthread.dylib        0x18346d028 thread_start + 4
  
  #8. Thread
  0  libsystem_kernel.dylib         0x1833a8b6c __workq_kernreturn + 8
  1  libsystem_pthread.dylib        0x18346d530 _pthread_wqthread + 1284
  2  libsystem_pthread.dylib        0x18346d020 start_wqthread + 4
  
  #9. Thread
  0  libsystem_kernel.dylib         0x1833a8b6c __workq_kernreturn + 8
  1  libsystem_pthread.dylib        0x18346d530 _pthread_wqthread + 1284
  2  libsystem_pthread.dylib        0x18346d020 start_wqthread + 4
  
  #10. com.apple.NSURLConnectionLoader
  0  libsystem_kernel.dylib         0x18338d4bc mach_msg_trap + 8
  1  libsystem_kernel.dylib         0x18338d338 mach_msg + 72
  2  CoreFoundation                 0x1837bcac0 __CFRunLoopServiceMachPort + 196
  3  CoreFoundation                 0x1837ba7c4 __CFRunLoopRun + 1032
  4  CoreFoundation                 0x1836e9680 CFRunLoopRunSpecific + 384
  5  CFNetwork                      0x183e59434 +[NSURLConnection(Loader) _resourceLoadLoop:] + 412
  6  Foundation                     0x1841c7c40 __NSThread__start__ + 1000
  7  libsystem_pthread.dylib        0x18346fb28 _pthread_body + 156
  8  libsystem_pthread.dylib        0x18346fa8c _pthread_body + 154
  9  libsystem_pthread.dylib        0x18346d028 thread_start + 4
  
  #11. Thread
  0  libsystem_kernel.dylib         0x1833a8b6c __workq_kernreturn + 8
  1  libsystem_pthread.dylib        0x18346d530 _pthread_wqthread + 1284
  2  libsystem_pthread.dylib        0x18346d020 start_wqthread + 4
  
  #12. Thread
  0  libsystem_kernel.dylib         0x1833a8b6c __workq_kernreturn + 8
  1  libsystem_pthread.dylib        0x18346d530 _pthread_wqthread + 1284
  2  libsystem_pthread.dylib        0x18346d020 start_wqthread + 4
  
  #13. Thread
  0  libsystem_kernel.dylib         0x1833a8b6c __workq_kernreturn + 8
  1  libsystem_pthread.dylib        0x18346d530 _pthread_wqthread + 1284
  2  libsystem_pthread.dylib        0x18346d020 start_wqthread + 4
  
  #14. com.apple.CFSocket.private
  0  libsystem_kernel.dylib         0x1833a8368 __select + 8
  1  CoreFoundation                 0x1837c3028 __CFSocketManager + 648
  2  libsystem_pthread.dylib        0x18346fb28 _pthread_body + 156
  3  libsystem_pthread.dylib        0x18346fa8c _pthread_body + 154
  4  libsystem_pthread.dylib        0x18346d028 thread_start + 4
  </code></pre>
  
  <p>Does it mean to say that the class "EngleskiPitanja" is missing? If so I don't understand why because it is in the project.</p>
  
  <p>This is the method that causes the crash</p>
  
  <pre><code>func getRealmObjectBasedOnString(type: String) -&gt; Object.Type?{
      guard let objectType = NSClassFromString("Matura.\(type)") else {
          //print("fail \(type)")
          return nil
      }
      return objectType as? Object.Type
  }
  </code></pre>