Parse Problem

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Parse Problem

    Hi kann mir hier jemand weiterhelfen?
    Ich kriege zwar auch das Ergebnis welches ich will im NSLog aber Xcode kann das View nicht laden welches den geparsten Tag beinhaltet.
    Ligen diese Fehler an der Website oder am Code ?
    Und wenn im Code was habe ich falsch gemacht?

    Danke schon mal im Voraus.
    Kroetephil

    Der Parser: github.com/zootreeves/Objective-C-HMTL-Parser

    Die Errors:

    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    error : out of memory error
    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    error : out of memory error
    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    error : out of memory error
    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    error : out of memory error
    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    error : Memory allocation failed : creating buffer
    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    error : out of memory error
    Html Parser(2656,0xad1d72c0) malloc: *** mmap(size=2097152) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug

    Mein Code:- (void)viewDidLoad
    {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    NSError *error = nil;

    NSStringEncoding theUsedEncoding;

    NSString *html = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.cvo-hamburg.de/vertretungsplan/"] usedEncoding:&theUsedEncoding error:nil];

    HTMLParser *parser = [[HTMLParser alloc] initWithString:html error:&error];

    if (error) {
    NSLog(@"Error: %@", error);
    return;
    }

    HTMLNode *bodyNode = [parser body];

    NSArray *tableNodes = [bodyNode findChildTags:@"td"];


    for (HTMLNode *tableNode in tableNodes) {
    NSLog(@"%@", [tableNode allContents]);



    for (int i =1; i < tableNodes.count; i=1+1) {
    [[tableNodes objectAtIndex:i] allContents];
    Label1.Text = [tableNode allContents];
    }




    }
  • Danke für die schnelle Antwort
    In dem Fall ist es egal welches view ich lade damit meine ich sobald ich egal in welchem View das Label reinziehe und verbinde und anschließiend über einen Button dahingelangen möchten stürtzt die App ab.
    Ich überschreibe Offensichtlich mein Label allerdings ist die zweite Zeile im Nslog das was ich haben möchte.
    Sofern muss ich nurnoch die Errors wegkriegen.
    Außer die Fehler besagen das ich das Label Nicht überschreiben kann oder so etwas in der Art.
    Mir sagen diese Fehler nähmlich garnichts.
  • Kroetephil schrieb:

    Mir sagen diese Fehler nähmlich garnichts


    Dir geht der Speicher aus …
    Xcode 4 sucks – „,Multiple exclamation marks‘, he went on, shaking his head, are a sure sign of a diseased mind.‘“ (Terry Pratchett 1992: Eric)

    "Wir ordnen und befehlen hiermit allen Ernstes, dass die Advocati wollene schwarze Mäntel, welche bis unter das Knie gehen, unserer Verordnung gemäß zu tragen haben, damit man die Spitzbuben schon von weitem erkennt." (Friedrich Wilhelm I., Soldatenkönig)
  • So ungefähr?

    Quellcode

    1. HTMLNode *bodyNode = [parser body];
    2. NSArray *tableNodes = [bodyNode findChildTags:@"td"];
    3. for (HTMLNode *tableNode in tableNodes) {
    4. NSLog(@"%@", [tableNode allContents]);
    5. for (int i =1; i < tableNodes.count; i=1+1) {
    6. [[tableNodes objectAtIndex:i] allContents];
    7. Label1.Text = [[tableNodes objectAtIndex:i] allContents];
    8. if (i= 2)
    9. break;
    10. }
    Alles anzeigen
  • Nicht ganz.

    So z.B.

    Quellcode

    1. NSError * error = nil;
    2. NSString * html = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.cvo-hamburg.de/vertretungsplan/"] encoding:NSISOLatin1StringEncoding error:&error];
    3. HTMLParser * parser = [[HTMLParser alloc] initWithString:html error:&error];
    4. if (error)
    5. {
    6. NSLog(@"%@", error);
    7. return;
    8. }
    9. HTMLNode * body = [parser body];
    10. NSArray * tableNodes = [body findChildTags:@"td"];
    11. NSString * content = nil;
    12. for (HTMLNode * node in tableNodes)
    13. {
    14. for (int i=0;i<tableNodes.count;i++)
    15. {
    16. if (i == 2)
    17. {
    18. content = [[tableNodes objectAtIndex:i] allContents];
    19. break;
    20. }
    21. }
    22. }
    23. NSLog(@"content = %@", content);
    Alles anzeigen


    Wenn du das in der viewDidLoad so lässt, wird dein Bildschirm schwarz bleiben, bis die Schleife durchlaufen ist.
    So etwas lässt man im Hintergrund laufen.
  • matz schrieb:

    Quellcode

    1. NSError * error = nil;
    2. NSString * html = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.cvo-hamburg.de/vertretungsplan/"] encoding:NSISOLatin1StringEncoding error:&error];
    3. HTMLParser * parser = [[HTMLParser alloc] initWithString:html error:&error];
    4. if (error)
    5. {
    6. NSLog(@"%@", error);
    7. return;
    8. }
    9. HTMLNode * body = [parser body];
    10. NSArray * tableNodes = [body findChildTags:@"td"];
    11. NSString * content = nil;
    12. for (HTMLNode * node in tableNodes)
    13. {
    14. for (int i=0;i<tableNodes.count;i++)
    15. {
    16. if (i == 2)
    17. {
    18. content = [[tableNodes objectAtIndex:i] allContents];
    19. break;
    20. }
    21. }
    22. }
    23. NSLog(@"content = %@", content);
    Alles anzeigen

    Wenn du das in der viewDidLoad so lässt, wird dein Bildschirm schwarz bleiben, bis die Schleife durchlaufen ist.

    Kann mir mal jemand den Sinn in den beiden Schleifen erklären? Ich meine, auf das selbe Ergebnis komme ich auch mit

    Quellcode

    1. if ([tableNodes count] >= 3) {
    2. content = [[tableNodes objectAtIndex:2] allContents];
    3. }

    Michael
  • Michael schrieb:

    matz schrieb:

    Quellcode

    1. NSError * error = nil;
    2. NSString * html = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.cvo-hamburg.de/vertretungsplan/"] encoding:NSISOLatin1StringEncoding error:&error];
    3. HTMLParser * parser = [[HTMLParser alloc] initWithString:html error:&error];
    4. if (error)
    5. {
    6. NSLog(@"%@", error);
    7. return;
    8. }
    9. HTMLNode * body = [parser body];
    10. NSArray * tableNodes = [body findChildTags:@"td"];
    11. NSString * content = nil;
    12. for (HTMLNode * node in tableNodes)
    13. {
    14. for (int i=0;i<tableNodes.count;i++)
    15. {
    16. if (i == 2)
    17. {
    18. content = [[tableNodes objectAtIndex:i] allContents];
    19. break;
    20. }
    21. }
    22. }
    23. NSLog(@"content = %@", content);
    Alles anzeigen

    Wenn du das in der viewDidLoad so lässt, wird dein Bildschirm schwarz bleiben, bis die Schleife durchlaufen ist.

    Kann mir mal jemand den Sinn in den beiden Schleifen erklären? Ich meine, auf das selbe Ergebnis komme ich auch mit

    Quellcode

    1. if ([tableNodes count] >= 3) {
    2. content = [[tableNodes objectAtIndex:2] allContents];
    3. }

    Michael


    Warum die Schleife da ist, war mir egal.

    Das wird dir der TO sicher beschreiben können :)

    Klar geht das auch so wie du es machst
  • matz schrieb:

    Warum die Schleife da ist, war mir egal.

    Selbst wenn die Schleifen irgendeinen Sinn haben sollten, dann würde ich die innere Schleife auch nicht per break abbrechen. Die Bedingung kann man auch oben rein schreiben:

    Quellcode

    1. for (int i = 0; (i < [tableNodes count]) && (i < 3); i++)

    Michael
  • matz schrieb:

    Warum die Schleife da ist, war mir egal.
    Selbst wenn die Schleifen irgendeinen Sinn haben sollten, dann würde ich die innere Schleife auch nicht per break abbrechen. Die Bedingung kann man auch oben rein schreiben:

    Quellcode

    1. for (int i = 0; (i < [tableNodes count]) && (i < 3); i++)
    Michael
    Ja in diesem Fall schon. Aber was wäre jetzt z. B. wenn es eine andere Bedingung wäre, den String auf Inhalt zu untersuchen und die Schleife beim gefundenen zu beenden?