Swift / iOS 9.2:
I have got some strange behavior with the code below. It fetches all groups, then imports all users related to that group. BLGroup ->> (One to Many) BackendlessUser
In the code below I removed all core data calls, it’s just to demo where / when the app crashes
Currently this crashes on line 10, but not for the first group. The first group outputs (prints email address) its users correctly, however when looping the second group the app crashes with:
-[NSNull length]: unrecognized selector sent to instance 0x109175af0
This did not happen on friday, everything worked -> weekend I had off, no code changes -> this morning I run the app the first time: Crashes. Just as a note: I also had this last week, after waiting for several hours all worked again. I didn’t report it back then as I was busy with other support tickets and I didn’t want to create too much of them at once.
If you need more info, please let me know.
private func importGroups() {
func importGroup(group:BLGroup) {
let backendID = group.objectId!
let name = group.name!
for user in group.users {
print ("User: \(user.email)")
}
}
let query = BackendlessDataQuery()
query.whereClause = "users.email = '\(backendless.userService.currentUser.email)'"
let dataStore = backendless.data.of(BLGroup.ofClass())
dataStore.find(
query,
response: {(bc : BackendlessCollection!) -> () in
let groups = bc.getCurrentPage() as! [BLGroup]
// import groups
for group in groups {
importGroup(group)
}
},
error: { (fault : Fault!) -> () in
print("Server reported an error (ASYNC): \(fault)")
})
}
Stack:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x111285af0'
*** First throw call stack:
(
0 CoreFoundation 0x0000000111060e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000110ad1deb objc_exception_throw + 48
2 CoreFoundation 0x000000011106948d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000110fb690a ___forwarding___ + 970
4 CoreFoundation 0x0000000110fb64b8 _CF_forwarding_prep_0 + 120
5 libswiftCore.dylib 0x0000000111e852f3 _TTSf4g_d___TFSSCfMSSFT12_cocoaStringPSs9AnyObject__SS + 131
6 libswiftCore.dylib 0x0000000111e4c9c3 _TFSSCfMSSFT12_cocoaStringPSs9AnyObject__SS + 19
7 libswiftFoundation.dylib 0x0000000112233260 _TF10Foundation24_convertNSStringToStringFGSqCSo8NSString_SS + 16
8 ProProject 0x000000010cd4ad6d _TFFC10ProProject22BackendlessUserManagerP33_4294ECCEE85D050961C84ABEF70E804F12importGroupsFS0_FT_T_L_11importGroupfCS_7BLGroupT_ + 1885
9 ProProject 0x000000010cd4ba09 _TFFC10ProProject22BackendlessUserManagerP33_4294ECCEE85D050961C84ABEF70E804F12importGroupsFS0_FT_T_U_FGSQCSo21BackendlessCollection_T_ + 1033
10 ProProject 0x000000010ccbc5a7 _TTRXFo_oGSQCSo21BackendlessCollection__dT__XFo_iGSQS___iT__ + 23
11 ProProject 0x000000010cd48cf1 _TPA__TTRXFo_oGSQCSo21BackendlessCollection__dT__XFo_iGSQS___iT__ + 81
12 ProProject 0x000000010ccbc5e0 _TTRXFo_iGSQCSo21BackendlessCollection__iT__XFo_oGSQS___dT__ + 32
13 ProProject 0x000000010ccbc628 _TTRXFo_oGSQCSo21BackendlessCollection__dT__XFdCb_dGSQS___dT__ + 56
14 ProProject 0x000000010ce53ac4 -[ResponderBlocksContext responseHandler:] + 52
15 ProProject 0x000000010ce53276 -[Responder responseHandler:] + 262
16 ProProject 0x000000010ce532b1 -[Responder responseHandler:] + 321
17 ProProject 0x000000010ce13c98 -[HttpEngine processAsyncAMFResponse:] + 2616
18 ProProject 0x000000010ce15b5a __41-[HttpEngine connectionDidFinishLoading:]_block_invoke + 42
19 libdispatch.dylib 0x000000011240ee5d _dispatch_call_block_and_release + 12
20 libdispatch.dylib 0x000000011242f49b _dispatch_client_callout + 8
21 libdispatch.dylib 0x00000001124172af _dispatch_main_queue_callback_4CF + 1738
22 CoreFoundation 0x0000000110fc0d09 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
23 CoreFoundation 0x0000000110f822c9 __CFRunLoopRun + 2073
24 CoreFoundation 0x0000000110f81828 CFRunLoopRunSpecific + 488
25 GraphicsServices 0x00000001134bfad2 GSEventRunModal + 161
26 UIKit 0x000000010d523610 UIApplicationMain + 171
27 ProProject 0x000000010ccef5ad main + 109
28 libdyld.dylib 0x000000011246392d start + 1
29 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException