Browse Source

[pasteboard declareTypes] needs to be called before every time you set a string to the pasteboard.

Grant Limberg 9 years ago
parent
commit
91b8d6f34f
2 changed files with 3 additions and 6 deletions
  1. 0 2
      ZeroTier One/AppDelegate.h
  2. 3 4
      ZeroTier One/AppDelegate.m

+ 0 - 2
ZeroTier One/AppDelegate.h

@@ -31,8 +31,6 @@
 
 @property (nonatomic) NodeStatus *status;
 
-@property (nonatomic) NSPasteboard *pasteboard;
-
 - (void)buildMenu;
 
 - (void)onNetworkListUpdated:(NSNotification*)note;

+ 3 - 4
ZeroTier One/AppDelegate.m

@@ -28,9 +28,6 @@
     self.monitor = [[NetworkMonitor alloc] init];
     self.networks = [NSMutableArray<Network*> array];
     self.status = nil;
-    self.pasteboard = [NSPasteboard generalPasteboard];
-
-    [self.pasteboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil];
 
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
     NSDictionary *defaultsDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:@"firstRun"];
@@ -266,7 +263,9 @@
 
 - (void)copyNodeID {
     if(self.status != nil) {
-        [self.pasteboard setString:self.status.address forType:NSPasteboardTypeString];
+        NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
+        [pasteboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil];
+        [pasteboard setString:self.status.address forType:NSPasteboardTypeString];
     }
 }