1

When I implement the getLoggedInUserOnSuccess:onFailure method (or the loginWithUsername: password: onSuccess:^(NSDictionary *results)...method in xcode, the results array does not become available until after all of my code has finished running. (If I NSLog the results, they will show up correctly.)

There is one other question that mentions this in Stackoverflow: How to get the sm_owner User object using StackMob as backend

However, the Stackmob Evangelist in the answer here does not suggest that there is any requirement for a completion block or something of this nature. (And in fact, in his own code, it appears to work without such a block or any sort of "waiting.") This was my first hunch as to what might be going wrong.

(Without posting a ton of code, I am trying to use this function to get the sm_owner which then serves as the predicate in the FetchedResultsController's getter, to ensure the user only sees their own creations and not those of other users, when in one view; in another fetch, they might be able to see the creations of users they follow.)

Has anyone else tried to use one of these methods with a results dictionary returned to write the predicate on a FetchedResultsController or similar and been able to make it work?

None of the Stackmob tutorials appear to limit data returned from a database based on its creator as far as I can tell.

Community
  • 1
  • 1
zacharyscott
  • 73
  • 1
  • 5

1 Answers1

1

If you set your schema's read permissions to "Allow to sm_owner", then you don't need to place a predicate on the fetch. Doing a generic fetch will return only those objects owned by the current logged in user.

msv
  • 163
  • 3
  • Thanks msv. Unfortunately, this would be too restrictive, as the solution would only ever allow for the sm_owner to see his/her posts. Think Twitter-style: Sometimes I just want to see what I've created. Other times I want to see the creations of users I follow. In the latter case, I would have an issue if I only allowed sm_owners to see their own creations. Thanks though; I have modified my post to clarify. – zacharyscott Sep 26 '13 at 15:38