Question

I'm attempting to filter custom objects by a particular userID using the iOS6 SDK on an iPhone 4s running 6.0.1. Unfortunately when the code below is executed it returns all the records in the custom object schema that were created.

    NSMutableDictionary *getRequest = [NSMutableDictionary dictionary];
    [getRequest setObject:@"222222" forKey:@"user_id"];
    [QBCustomObjects objectsWithClassName:@"appointments" extendedRequest:getRequest delegate:self];

(i've omitted the authentication code. I am able to authenticate and create a record just fine) For the key i've tried every permutation I can think of for userID. Including looking at the response from the query request and how the field is referenced in the jSON feed. It's almost as if the extendedRequest isn't taking into account any values I put in there - but I clearly see them being passed when view the console logs.

Was it helpful?

Solution 2

I went back and looked at how I was creating a quickblox session and I was using the following method to authenticate with the API.

    [QBUsers logInWithUserEmail:@"" password:@"" delegate:self];

I switched it to use this method instead and I am now able to pull specific records from the Custom Objects module.

    [QBAuth createSessionWithExtendedRequest:extendedAuthRequest delegate:self];

OTHER TIPS

it's quite strange, because i use

NSMutableDictionary *getRequest = [NSMutableDictionary dictionary];
[getRequest setObject:[NSNumber numberWithInt:291] forKey:@"user_id"];

[QBCustomObjects objectsWithClassName:@"SuperSample" extendedRequest:getRequest delegate:self];

If we looked at console, we will see:

GET http://api.quickblox.com/data/SuperSample.xml
headers:{
    "QB-SDK" = "iOS 1.3.1";
    "Qb-Token" = 00fbd4c38b4156975e63882ad660e9a724ae7a3d;
    "QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
    "user_id" = 291;
}

And this code snippet returns me only records with user_id 291 (in this example this a is single record):

<?xml version="1.0" encoding="UTF-8"?>
<data type="array">
  <SuperSample>
    <_id>50bb4c1c535c12306b007ea4</_id>
    <_parent_id nil="true"></_parent_id>
    <born_age nil="true"></born_age>
    <created-at type="integer">1354451996</created-at>
    <my_field nil="true"></my_field>
    <rating nil="true"></rating>
    <sex_ nil="true"></sex_>
    <text nil="true"></text>
    <updated-at type="integer">1354451996</updated-at>
    <user-id type="integer">291</user-id>
    <vote nil="true"></vote>
  </SuperSample>
</data>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top