Skip to content

Apparent caching issue with Array of Custom Objects stored in Custom Object #518

Closed
@craiggrummitt

Description

@craiggrummitt

There seems to be some sort of caching issue with an Array of Custom Objects. I have included a link to a bare bones example of this problem. Let me describe the bare bones app, then the issue:

App:
Simple chat app with one channel, only functionality is displaying all messages, and add message. I have a custom class 'Message' and 'Chat' (which stores an array of Messages). Messages are displayed in a UITableView, and there is a button to 'reload' the chat using a query. The query uses 'includeKey' to ensure that the messages array is included. When the app starts up, if no chat exists, it creates one with a blank messages array.

The only changes to this app from the Parse Starter Project are: Chat.swift, Message.swift, AppDelegate.swift(to set the application id and register subclasses), ViewController.swift and the storyboard.

Problem:
The query seems to retrieve cached data (i.e. it doesn't update with updates in the data).

From my testing, the device that generates the 'Chat' object initially does not present this problem. However, the device that did not initially generate the 'Chat' object, does present this problem.

Steps to produce this problem:

  1. Download the sample code here.
  2. You will need two devices. Install the app on first device(Device A). Note that as the query came back with no 'Chat' objects that it generated one. Double check in Parse Core that this 'Chat' object was generated.
  3. Run the app on the other device (Device B) This time the query comes back with a Chat object.
  4. Add a message on Device A by tapping the plus button and then save. Note this saves the message, and then reloads the query and the table. Double check the message was saved in Core.
  5. Reload the table on Device B - message should appear. Great!
  6. Add a message on Device B, same as step 3. The message should be returned by the query. Double check the message was saved in Core.
  7. Reload the table on Device A - huh? The message doesn't appear. Triple check the message was saved in Core. It was right? Why doesn't the query return it?
  8. Scratch head.
  9. Build and run the app on Device A again - now the message does appear. What the? Is this a caching problem?

Additional diagnostic notes:
In my actual app I had implemented a limit of 20 messages, and after that the first message was deleted. I noticed that after I started deleting messages, that this apparent caching problem stopped occurring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions