Search code examples
iosobjective-ccloudkit

How do I separate out fields in a CKRecords results Xcode objective-c


I have saved data to fields in CloudKit and I have queried for the posts by date in decending order and by getting the one at index(0) I have the last post. My question is how do I separate out the various fields and use them to populate the text in various labels in my view. Here is what I have for the latest post query.

<CKRecord: 0x104e5b600; recordID=157F08E2-FF00-42DD-8B89-7CB10FAC81B6:(_defaultZone:__defaultOwner__), recordChangeTag=kk6d3s69, values={ temperature=54, trip=50, level=53, battery=64, date=1-20-2021      20:57:09 }, recordType=MyPoolInfo>

If someone could help me out I would appreciate it. Thanks


Solution

  • I figured this out. This is a dictionary. So I just called the following:

    NSLog(@"temperature:%@",[dictionary objectForKey:@"temperature"]) ;
                   NSLog(@"date:%@",[dictionary objectForKey:@"date"]) ;
                   NSLog(@"trip:%@",[dictionary objectForKey:@"trip"]) ;
                   NSLog(@"battery:%@",[dictionary objectForKey:@"battery"]) ;
                   NSLog(@"level:%@",[dictionary objectForKey:@"level"]) ;
    

    I could then fill in the label.text like this:

    self.DateLabel.text =[dictionary objectForKey:@"date"];
    

    in case anyone needs to know.