Working with NSThreads

Discussion in 'Mac Programming' started by Samppaa, Jul 5, 2010.

  1. Samppaa macrumors regular

    Joined:
    Mar 26, 2010
    #1
    Hey I am making application where the program constantly downloads webpage in background and compares it to the old one, so I need thread for this I did this to my function where it starts getting the webpage [self performSelectorInBackground:mad:selector(testFunction) withObject:nil];

    Yes, it keeps running the function, but I get error in console

    Here is the test function
    Code:
    -(void)testFunction
    {
        int i = 0;
        while(true) {
             [statusText setIntValue:i];
             i++;
        }
    }
    
    I get this error
    Code:
    2010-07-05 17:22:46.517 Checker[1797:4b0f] *** __NSAutoreleaseNoPool(): Object 0x10014ddb0 of class NSCFNumber autoreleased with no pool in place - just leaking
    
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
  3. Samppaa thread starter macrumors regular

    Joined:
    Mar 26, 2010
    #3
    I read the guide abit but I missed the autorelease pool part, thanks so much! Thread programming is so easy in cocoa I love this.
     
  4. Menge macrumors 6502a

    Menge

    Joined:
    Dec 22, 2008
    Location:
    Amsterdam
    #4
    The second thing it'll tell you is: never change the UI from within a thread. Which is likely the next issue you'll run into ;)
     
  5. Samppaa thread starter macrumors regular

    Joined:
    Mar 26, 2010

Share This Page