The Movie Database Support Forum

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 Antwort (Seite 1 von 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?

Es fehlt ein Film oder eine Serie? Logge dich ein zum Ergänzen.

Allgemein

s Fokus auf Suchfeld
p Profil öffnen
esc Fenster schließen
? Tastenkürzel anzeigen

Videos

b Zurück
e Bearbeiten

Staffeln

Nächste Staffel
Vorherige Staffel

Episoden

Nächste Episode
Vorherige Episode

Bilder

a Poster oder Hintergrundbild hinzufügen

Editieren

t Sprachauswahl öffnen
ctrl+ s Speichern

Diskussionen

n Neue Diskussion erstellen
w Beobachten an / aus
p Diskussion öffentlich / privat
c Diskussion öffnen / schließen
a Diskussionsverlauf anzeigen
r Auf Diskussion antworten
l Letzte Antwort anzeigen
ctrl+ enter Senden
Nächste Seite
Vorherige Seite

Einstellungen

Diesen Eintrag bewerten oder zu einer Liste hinzufügen?

Anmelden