Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

shtuceron

macrumors newbie
Original poster
Dec 22, 2009
16
0
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];
}
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.