out of scope exception

Discussion in 'Mac Programming' started by shtuceron, Feb 3, 2010.

  1. shtuceron macrumors newbie

    Joined:
    Dec 22, 2009
    #1
    Hello all.
    I have some code which read buffer and write this value in variable, but on the second iteration of timer i get out of memory exception, what is mean?
    Thanks.

    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    self.previousString == [NSString stringWithString:[self stringFromPasteboard]];

    NSLog(@"%@", self.previousString);

    [self startTimer];
    }

    - (void)startTimer {
    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:mad:selector(readPasteboard:) userInfo:nil repeats:YES];
    }

    - (void)readPasteboard:(NSTimer *)theTimer {
    NSLog(@"%@", self.previousString); //<- this i hawe mistake.
    }

    - (NSString *)stringFromPasteboard {
    NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];

    NSArray *classes = [[NSArray alloc] initWithObjects:[NSString class], nil];

    NSDictionary *options = [NSDictionary dictionary];

    NSArray *copiedItems = [pasteboard readObjectsForClasses:classes options:eek:ptions];

    return [copiedItems objectAtIndex:0];
    }
     
  2. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
    In applicationDidFinishLaunching:, you use the == comparison operator instead of the = assignment operator. Not sure if that's the problem, but it's probably not what you want.

    Also, please wrap your code listings in CODE tags to make it more readable.
     

Share This Page