pulling a value from NSMutableDictionary

Posted by Jared Gross on Stack Overflow See other posts from Stack Overflow or by Jared Gross
Published on 2013-10-19T03:01:44Z Indexed on 2013/10/19 3:54 UTC
Read the original article Hit count: 205

I have a dictionary array with a key:@"titleLabel". I am trying to load a pickerView with ONE instance of each @"titleLabel" key so that if there are multiple objects with the same @"titleLabel" only one title will be displayed. I've done some research on this forum and looked at apples docs but haven't been able to put the puzzle together. Below is my code but I am having trouble pulling the values. Right now when I run this code it throws an error Incompatible pointer types sending 'PFObject *' to parameter of type 'NSString' which i understand but am just not sure how to remedy. Cheers!

        else {
        // found messages!
        self.objectsArray = objects;

        NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
        for(id obj in self.objectsArray){
            PFObject *key = [self.objectsArray valueForKey:@"titleLabel"];

            if(![dict objectForKey:@"titleLabel"]){
                [dict setValue:obj forKey:key];
            }
        }
        for (id key in dict) {
        NSLog(@"Objects array is %d", [self.objectsArray count]);
        NSLog(@"key: %@, value: %@ \n", key, [dict objectForKey:key]);
        }
        [self.pickerView reloadComponent:0];
    }
}];`

Here is where I define the PFObject and keys:

 PFObject *image = [PFObject objectWithClassName:@"Images"];
        [image setObject:file forKey:@"file"];
        [image setObject:fileType forKey:@"fileType"];
        [image setObject:title forKey:@"titleLabel"];
        [image setObject:self.recipients forKey:@"recipientIds"];
        [image setObject:[[PFUser currentUser] objectId] forKey:@"senderId"];
        [image setObject:[[PFUser currentUser] username] forKey:@"senderName"];
        [image saveInBackground];

© Stack Overflow or respective owner

Related posts about ios

Related posts about nsmutabledictionary