Dictionary - remove entry for key crash problem

Hey, I'm working on a flag quiz app using dictionary for the questions. I encountered a problem that couldn't be fixed for me, After 2 or 5 questions the app immediately crashes. Apparently it's a problem with my "removeQuestion" procedure, And I can't find the issue. I would be happy for help. thanks (by the way don't mind about the different language)

1 Like

It would be easier if you post a test aia in order to check it because we can see your dictionary structure

2 Likes

image
You're trying to remove "q"+Question+"A3"'s value twice in the procedure that's causing the problem. Since you've already removed the pair, I presume that the 2nd block in the screenshot's causing your problem, as it cannot find the key-value pair to remove.

1 Like


That's the dictionary
But anyways :point_down:
Quiz_Game (1).aia (127.1 KB)
Go to "Flag Quiz" screen

Thanks, I didn't put attention on that. but unfortunately when I changed from A3 to A4 nothing changed, the same thing still happens

So how do I basically remove a question to prevent it from duplicating using dictionary?

Make changes to this code block as

I tested, now it is not causing to breack screen or app close after answering few questions, and it also make your code modular/concise.

2 Likes

And need to change here also

Increment to row after calling removingQuestions procedure.

1 Like

Thanks so much, it worked. There are 2 problems - Firstly after 1 random question it does the same sequence of questions, secondly When you play again then the question itself is deleted and there's no block of "insert a dictionary key". I need help with that, thanks

One solution could be not to work on original dictionary, instead work on a copy of it, making origoinal dictionary keep intect, and when you start you app again do work on the copy of original one.

1 Like

Alright, but every question still duplicates though.

Yes, copy dictionary won't suppurt as it is having some know issue

1 Like

Oh, alright. thanks for helping

You can have deepCopy function created by ABG and these blocks can be dragged directly into your Blocks Editor workspace. Just pass your original dictionary and you will be returned a copy.

Now you can work on the copy not the original dictionary, so when you delete items from copy dictionary it woun't affect the original. Whenever you restart the quize you can again create copy and work on that.

1 Like

In case any one has not mentioned it, dictionaries don't work on iOS, only on Android.

Thank you everyone for the help, at last I fixed the problem

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.