Start a new topic
Answered

How we convert this this code in swift 4

Hi Pranav, 

I am trying to implement in swift 4. but I did not find pseudo code related to this 

Please help me.


KCSQuery *dateQuery = [KCSQuery queryOnField:KCSMetadataFieldLastModifiedTime usingConditional:kKCSGreaterThan forValue:myDate];

KCSQuerySortModifier* sortingDate = [[KCSQuerySortModifier alloc] initWithField:KCSMetadataFieldLastModifiedTime inDirection:kKCSAscending];

[query addSortModifier: sortingDate];

KCSQuery *mainQuery = [KCSQuery queryOnField:KCSMetadataFieldCreator withExactMatchForValue:[[KCSClient sharedClient] appKey]];

    KCSQuery *actualQuery = [KCSQuery queryForJoiningOperator:kKCSAnd onQueries: mainQuery, dateQuery, nil];


Best Answer

Wasim,


Have you tried implementing all the queries mentioned on this link in Swift 4 directly? Please elaborate on what you are trying to achieve so that I can try implementing it in my environment.


Thanks,

Pranav


Hi Pranav, 


 I converted above objective c code to swift but I am getting nil values 

  

Fields: nil

Predicate: Optional(lmt >= "2005-10-09T18:30:00.000Z" AND _acl.creator == "<kinvey_id>")

Sort Descriptors: Optional([(lmt, ascending, compare:)])

Skip: nil

Limit: nil



  let dateFormat = "2005-10-09T18:30:00.000Z"

  let predicateDate = NSPredicate(format: "lmt >= %@", dateFormat)

  let sortDescriptor = NSSortDescriptor(key: "lmt", ascending: true)

  let predicateAdmin = NSPredicate(format: "_acl.creator == %@", Kinvey.sharedClient.appKey!)

  let predicate = NSCompoundPredicate(andPredicateWithSubpredicates: [predicateDate, predicateAdmin])

  let query = Query(predicate:predicate,sortDescriptors:[sortDescriptor])  

        

Answer

Wasim,


Have you tried implementing all the queries mentioned on this link in Swift 4 directly? Please elaborate on what you are trying to achieve so that I can try implementing it in my environment.


Thanks,

Pranav

Hi!


I tried Swift 4 directly. It is not of much use on iOS 11.3.


---------------------------------------------------------------------

Zayn Appvn Jio4GVoice  3DS Emulator

Login or Signup to post a comment