objective c - What other code is needed to get the photos from Instagram's API to show up? -
i'm new programming , i'm trying create photo app ios development class displays users pics based on specific hashtag, not having luck. have api instagram along client_id. when run it, there aren't errors screen black. else needed me images showing up? have far. in advance!
@interface viewcontroller () <uicollectionviewdatasource, uicollectionviewdelegate> @property (weak, nonatomic) iboutlet uicollectionview *collectionview; @property nsmutablearray *picfeed; @end @implementation viewcontroller - (void)viewdidload { [super viewdidload]; nsurl *url = [nsurl urlwithstring:@"https://api.instagram.com/v1/tags/chicago/media/recent?count=100&client_id=d3eed38ae896497e9e58298dd793333b"]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; [nsurlconnection sendasynchronousrequest:request queue:[nsoperationqueue mainqueue] completionhandler:^(nsurlresponse *response, nsdata *data, nserror *connectionerror) { self.picfeed = [nsjsonserialization jsonobjectwithdata:data options:nsjsonreadingallowfragments error:&connectionerror]; [self.collectionview reloaddata]; }]; } -(nsinteger)collectionview:(uicollectionview *)collectionview numberofitemsinsection:(nsinteger)section { return self.picfeed.count; } -(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { uicollectionviewcell *cell = [collectionview dequeuereusablecellwithreuseidentifier:@"cellid" forindexpath:indexpath]; return cell; }
Comments
Post a Comment