Add a singleton |+instance| method to AppDelegate so we don't cast everywhere.
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 31 Oct 2010 14:26:51 +0000 (10:26 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 31 Oct 2010 14:26:51 +0000 (10:26 -0400)
Source/AppDelegate.h
Source/AppDelegate.m
Source/DebuggerConnection.m
Source/NSXMLElementAdditions.m

index a9919eee7eec45d21a9176feeca784e9d925ee03..c92978ffb19c2ff24b2b5cb19f5466ef7b9941b0 100644 (file)
 @property (readonly) BreakpointController* breakpoint;
 @property (readonly) LoggingController* loggingController;
 
+// Returns the instance of this class that is acting as the application's
+// delegate.
++ (AppDelegate*)instance;
+
 - (IBAction)showDebuggerWindow:(id)sender;
 - (IBAction)showBreakpointWindow:(id)sender;
 - (IBAction)showPreferences:(id)sender;
index 8239128224b8fed4d3fe46e57aedfb4c79098b3f..941d98a9ec167ca5930fbe7c64b9ea7eeed209d3 100644 (file)
   [pool release];
 }
 
++ (AppDelegate*)instance
+{
+  return (AppDelegate*)[NSApp delegate];
+}
+
 /**
  * Shows the debugger window
  */
index f17697dc7fe3409c2d684a66e24ace2f99d5cc7f..07fd033d129938760a0b966ca9ce56e09990f917 100644 (file)
@@ -425,7 +425,7 @@ void SocketAcceptCallback(CFSocketRef socket,
 
 - (LogEntry*)recordSend:(NSString*)command
 {
-  LoggingController* logger = [(AppDelegate*)[NSApp delegate] loggingController];
+  LoggingController* logger = [[AppDelegate instance] loggingController];
   LogEntry* entry = [LogEntry newSendEntry:command];
   entry.lastReadTransactionID = lastReadTransaction_;
   entry.lastWrittenTransactionID = lastWrittenTransaction_;
@@ -437,7 +437,7 @@ void SocketAcceptCallback(CFSocketRef socket,
 
 - (LogEntry*)recordReceive:(NSString*)command
 {
-  LoggingController* logger = [(AppDelegate*)[NSApp delegate] loggingController];
+  LoggingController* logger = [[AppDelegate instance] loggingController];
   LogEntry* entry = [LogEntry newReceiveEntry:command];
   entry.lastReadTransactionID = lastReadTransaction_;
   entry.lastWrittenTransactionID = lastWrittenTransaction_;
index f8a9a63f0cf57b9d9a38661798d6a3c21467f0e8..b3ea0b23f0b3570d26748e37203e399231ed2310 100644 (file)
@@ -53,7 +53,7 @@
   // If this node has children but they haven't been loaded from the backend,
   // request them asynchronously.
   if (![self isLeaf] && [children count] < 1) {
-    [[[(AppDelegate*)[NSApp delegate] debugger] connection] getProperty:[self fullname]];
+    [[AppDelegate instance].debugger.connection getProperty:[self fullname]];
   }
   return children;
 }