Start a new topic

kKCSAll craches the program

What is the right way of using kKCSAll? I am using it like this and the program crashes:



KCSQuery *findSenders = [KCSQuery queryOnField:@"recipients._id"

usingConditional:kKCSAll forValue:@[[KCSUser activeUser].userId]];

KCSCollection* collection = [KCSCollection collectionFromString:@"inbox" ofClass:[TSSMessage class]];

KCSLinkedAppdataStore* store = [KCSLinkedAppdataStore storeWithOptions:@{KCSStoreKeyResource: collection,

KCSStoreKeyCachePolicy: @(KCSCachePolicyNetworkFirst)}];



[store queryWithQuery:findSenders withCompletionBlock:^(NSArray *objectsOrNil, NSError *errorOrNil) {

if (objectsOrNil)

self.senderList = objectsOrNil;

else

[self refreshFailed:errorOrNil.description];

} withProgressBlock:nil];



crash log:

0 CoreFoundation 0x035605e4 __exceptionPreprocess + 180

1 libobjc.A.dylib 0x032e38b6 objc_exception_throw + 44

2 CoreFoundation 0x035ea578 -[__NSDictionaryM setObject:forKey:] + 888

3 Remember Me 0x000b24ee -[KCSEntityCache setResults:forQuery:] + 654

4 Remember Me 0x0008b078 -[KCSCachedStore cacheQuery:value:error:policy:] + 216

5 Remember Me 0x0008b317 __76-[KCSCachedStore queryNetwork:withCompletionBlock:withProgressBlock:policy:]_block_invoke + 103

6 Remember Me 0x00085b4b __72-[KCSAppdataStore queryWithQuery:withCompletionBlock:withProgressBlock:]_block_invoke_2 + 43

7 Remember Me 0x00083d9c __51-[KCSAppdataStore makeProcessDictBlockForNewObject]_block_invoke + 1308

8 Remember Me 0x00085afb __72-[KCSAppdataStore queryWithQuery:withCompletionBlock:withProgressBlock:]_block_invoke + 251

9 Remember Me 0x0004dbf5 __49-[KCSAsyncConnection connectionDidFinishLoading:]_block_invoke + 885

10 Remember Me 0x0004d3b1 -[KCSAsyncConnection runBlockInForeground:] + 161

11 Remember Me 0x0004d860 -[KCSAsyncConnection connectionDidFinishLoading:] + 112

12 Foundation 0x030adb59 ___NSURLConnectionDidFinishLoading_block_invoke + 40

13 Foundation 0x030443e1 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 62

14 Foundation 0x02ecca6e -[NSURLConnectionInternalConnection invokeForDelegate:] + 119

15 Foundation 0x02ecc9d6 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 208

16 Foundation 0x02ecc8e8 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 76

17 Foundation 0x02eccc98 _NSURLConnectionDidFinishLoading + 43

18 CFNetwork 0x00614e6f ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 111

19 CFNetwork 0x00612bac ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 104

20 CFNetwork 0x0065d0ef ___ZNK17CoreSchedulingSet13_performAsyncEPKcU13block_pointerFvvE_block_invoke + 25

21 CoreFoundation 0x03501d59 CFArrayApplyFunction + 57

22 CFNetwork 0x0057c5af _ZN19RunloopBlockContext7performEv + 139

23 CFNetwork 0x0065d6d2 _ZThn16_N19RunloopBlockContext24multiplexerClientPerformEv + 20

24 CFNetwork 0x0057c3dd _ZN17MultiplexerSource7performEv + 299

25 CFNetwork 0x0057c1f2 _ZN17MultiplexerSource8_performEPv + 76

26 CoreFoundation 0x034e983f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15

27 CoreFoundation 0x034e91cb __CFRunLoopDoSources0 + 235

28 CoreFoundation 0x0350629e __CFRunLoopRun + 910

29 CoreFoundation 0x03505ac3 CFRunLoopRunSpecific + 467

30 CoreFoundation 0x035058db CFRunLoopRunInMode + 123

31 GraphicsServices 0x055259e2 GSEventRunModal + 192

32 GraphicsServices 0x05525809 GSEventRun + 104

33 UIKit 0x00f42d3b UIApplicationMain + 1225

34 Remember Me 0x0000242d main + 141

35 libdyld.dylib 0x03cf470d start + 1

)

libc++abi.dylib: terminating with uncaught exception of type NSException


That's ok Caroline, I changed the way I handle it and I am not using kKCSAll any more, but as I mentioned earlier suppose I want to find all of the events that some user sent some other users an egg. Suppose recipients is an array of users that received an egg in each event, Then for example this should find all of events that in those an egg is sent to user1 and user2:



KCSQuery findEvents = [KCSQuery queryOnField:@"recipients._id" usingConditional:kKCSAll forValue:@[user1.userId, user2.userId]];
Hi Ali, We'd really like to help, we're just having trouble trying to figure out exactly what you're trying to do and where you're getting stuck. Can you give us some background on the use case? Also, are you on the latest SDK version?
Well, I still don't know how to match an array of values
Hi Ali, Are you still stuck?
I have use case for both.
Does it have to match both user1 and user2 or does it match user1 OR user2?
Suppose I want all the users that sent a message to user1 and user2. I thought this should do it



KCSQuery findSenders = [KCSQuery queryOnField:@"recipients._id" usingConditional:kKCSAll forValue:@[user1.userId, user2.userId]];
I am not sure what you mean, can you give an example of exactly what you want to load?
queryOnField:withExactMatchForValue works for on value. But how can match the field with a last of values?
I have a list of users in "recipients" field. I want to find the records that has specific user/usres in recipients field. How should I do that?
You probably want to use queryOnField:withExactMatchForValue: instead.



http://devcenter.kinvey.com/ios/guides/datastore#Querying
KCSQuery findSenders = [KCSQuery queryOnField:@"recipients._id" usingConditional:kKCSAll forValue:@[[KCSUser activeUser].userId]];



KCSCollection collection = [KCSCollection collectionFromString:@"inbox" ofClass:[TSSMessage class]];

KCSLinkedAppdataStore* store = [KCSLinkedAppdataStore storeWithOptions:@{KCSStoreKeyResource: collection,

KCSStoreKeyCachePolicy: @(KCSCachePolicyNetworkFirst)}];



[store queryWithQuery:findSenders withCompletionBlock:^(NSArray *objectsOrNil, NSError *errorOrNil) {

if (objectsOrNil)

self.senderList = objectsOrNil;

else

[self refreshFailed:errorOrNil.description];

} withProgressBlock:nil];

Login or Signup to post a comment