The Movie Database support

int i = 1;

while (i < 1000)
{
    NSString *num = [NSString stringWithFormat:@"%i", i];

    NSString *personURL = [@"https://api.themoviedb.org/3/person/" stringByAppendingString:num];

    personURL = [personURL stringByAppendingString:@"?api_key=XXXXXXXXXXXXXXXXXXXXX"];


    NSURLSession *session = [NSURLSession sharedSession];
    [[session dataTaskWithURL:[NSURL URLWithString:personURL]
            completionHandler:^(NSData *data,
                                NSURLResponse *response,
                                NSError *error) {


                NSString *strData = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];

                NSError* errorJ;
                NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&errorJ];


                if(strData.length != 94 )// for an invalid ID
                {

                   [self.actors addObject:json];     //array in obj-c to hold all valid people
                }



            }]
     resume];
    i++;
}

That is all within one function receiving no parameters and only being called once. I feel like I am doing this wrong or forgetting something with the session since it takes a long time and is using a lot of memory. Please help me, Thank you in advance!

1 svar (på side 1 af 1)

Jump to last post

Do I need to close off the session or end the session or just keep the request limit in mind?

Kan du ikke finde en film eller TV-serie? Log in og opret den.

Global

s focus the search bar
p open profile menu
esc luk et åbent vindue
? open keyboard shortcut window

På mediesider

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

På alle billedesider

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

På diskussionssider

n opret ny diskussion
w toggle watching status
p toggle public/private
c toggle close/open
a åben aktivitet
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Indstillinger

Want to rate or add this item to a list?

Log ind