title: How to make a declaration common to both the methods of a class->Objective C
body: <p>I have a class called <code>RSTimer</code> that has two methods called <code>CreateTimer</code> and <code>KillTimer</code> which uses the same dictionary object. I could not able to declare the variable inside the interface as well as inside the implementation. Its pointing out in the declaration and says that it is not a constant.</p>
  
  <pre><code>-(BOOL)KillTimer:(unsigned short)wTimerId
  {
      stRs232Timer* pEvent;
      BOOL bReturn=FALSE;
      CFDictionaryValueCallBacks cbs = {0,NULL,NULL,NULL,NULL};
      CFMutableDictionaryRef cfdict = CFDictionaryCreateMutableNULL,0,&amp;kCFTypeDictionaryKeyCallBacks,&amp;cbs);
        NSLock* theLock = [[NSLock alloc]init];
        if ([theLock tryLock]) {
          if (CFDictionaryContainsKey(cfdict,&amp;wTimerId)) {
           free(pEvent);
           bReturn = TRUE;
          }
          [theLock unlock];
      }
  return bReturn;
  }
  -(BOOL)CreateTimer:(RS232TimerInterface*)pStack withTimerId:(unsigned short)wTimerId withPeriod:(uint8_t)uPeriod withPersistentState:(BOOL)bPersistent
  {
  
      CFDictionaryValueCallBacks cbs = {0,NULL,NULL,NULL,NULL};
      CFMutableDictionaryRef cfdict = CFDictionaryCreateMutable(NULL,0,&amp;kCFTypeDictionaryKeyCallBacks,&amp;cbs);
      CFNumberRef timerId = CFNumberCreate(NULL,kCFNumberShortType,&amp;wTimerId);
      [self KillTimer:wTimerId];
      NSLock* theLock = [[NSLock alloc]init];
      if ([theLock tryLock]) {
           CFDictionarySetValue(cfdict,&amp;timerId,pEvent);
          [theLock unlock];
      }
  
  }
  </code></pre>
  
  <p>I tried declaring it in 'init' method also. How can i make </p>
  
  <pre><code>CFDictionaryValueCallBacks cbs = {0,NULL,NULL,NULL,NULL};   
  CFMutableDictionaryRef cfdict = CFDictionaryCreateMutable(NULL,0,&amp;kCFTypeDictionaryKeyCallBacks,&amp;cbs);
  </code></pre>
  
  <p>common to both the methods..</p>