Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Load Multiple PFFiles from Parse in Xcode

I am using Parse for an iOS app and it requires me to load multiple image in one PFObject, and so I have multiple PFFiles in that object. I know you have to load each object seperately in order to use it, but is there a way to load multiple PFFiles at once from an object? Any input is appreciated!

like image 495
A.J. S. Avatar asked Apr 17 '26 01:04

A.J. S.


1 Answers

for other new folks like me, i believe the accepted answer from 'ahar083' may have a typo in it. i changed 'data1' to 'file1' and 'data2' to 'file2' (updated code = pasted below). i do not have enough points to comment on an answer = posted my comment as a new answer.

PFQuery *query = [PFQuery queryWithClassName:@"ManyFileClass"];
[query getObjectInBackgroundWithId:@"OBJECT_ID" 
                             block:^(PFObject *manyFileClass, NSError *error) {
    PFFile* file1 = [o objectForKey:@"file1"];
    PFFile* file2 = [o objectForKey:@"file2"];

    [file1 getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
        if (!error) {
            NSLog(@"Got data from file1@");
        }
    }];

    [file2 getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
        if (!error) {
            NSLog(@"Got data from file2@");
        }
    }];

}];
like image 166
tmr Avatar answered Apr 19 '26 13:04

tmr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!