0

Adding this line to my App import AlgoliaSearch returns this error:

2017-05-08 22:35:07.814593 XXXXXX[6255:2627487] -[__NSDictionaryI length]: unrecognized selector sent to instance 0x1702f0980 2017-05-08 22:35:07.816565 XXXXXX[6255:2627487] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI length]: unrecognized selector sent to instance 0x1702f0980' * First throw call stack: (0x192f351b8 0x19196c55c 0x192f3c268 0x192f39270 0x192e3280c 0x1015c8608 0x10158d72c 0x10194a198 0x1001f6c24 0x1001f8c9c 0x100091fd4 0x1003973d4 0x100397690 0x1003be2c0 0x101a5d258 0x101a5d218 0x101a62280 0x192ee2810 0x192ee03fc 0x192e0e2b8 0x1948c2198 0x198e557fc 0x198e50534 0x10013c734 0x191df15b8) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

The line of code it is referring to is as below:

self.ref.child("users").observeSingleEventOfType(.Value, withBlock: { (snapshot) in

    for user in snapshot.children{
        var numVids = NSDictionary()
        if ((user.hasChild("videos")) == true){
   -->    numVids = user.value["videos"] as! NSDictionary
        }

    }

As soon as I remove the import Algolia module the error is removed, I have tried changing the version of the module and even switching to use the objc version but the error was the same.

Anyone seen something like this before?

https://github.com/algolia/algoliasearch-client-swift

https://github.com/algolia/algoliasearch-client-objc

russell
  • 176
  • 1
  • 12
  • are you sure that user.value["videos"] is a Dictionary not String? Can you post the data structure to this question ? – Grzegorz Krukowski May 08 '17 at 22:02
  • Yep, the same line works as intended when the Algolia module in not added. Here is an example of the data: `Snap (XXXX) { avatar = “path/to/image”; bio = “User bio here..! "; category = “Blog”; email = “email@gmail”; name = “User Name”; videos = { “LONG-ID-HERE“ = "1485288673.82"; “LONg-ID-HERE” = "1486655595.68705"; }; }; }` – russell May 08 '17 at 22:09
  • 1
    Couple of questions in order to understand more: 1- When you put a breakpoint at the crashing line, what do you see for the `videos` values? are you sure it is an `NSDictionary`? 2- I don't see an obvious reason why adding `import AlgoliaSearch` will give you an `unrecognized selector` error. What version of AlgoliaSearch you're using? The latest one uses Swift 3, and you seem to be using Swift 2 in your project, so there might be something going on there. which lead me to question 3: 3- Were you able to use the `AlgoliaSearch` successfully in your project elsewhere? – Guy Daher May 09 '17 at 08:53
  • Its really strange - The breakpoint shows the videos as nil but when I build and run without AlgoliaSearch it is not nil and works again. It is version 3.7 & yep i'm using Swift 2 in the project. – russell May 09 '17 at 12:36
  • I see.. but is it only `user.value["videos"] that is nil or the whole `user` response that is nil? and what about question 3, were you able to use AlgoliaSearch elsewhere? You seem to be using Firebase here, and maybe _somehow_, ` `AlgoliaSearch` is interfering with the request of Firebase, although I currently don't have a guess now. The best way for me to help you is if you can post a snippet of code so that I can reproduce the bug on my side. Like that I can investigate and try to find the root cause. We can also move the conversation to a [Github Issue](https://git.io/v96xf) if you want! – Guy Daher May 09 '17 at 13:46

0 Answers0