title: Objective C, How to convert this java statment into Objective C code?
body: <p>I have a very simple java code like this. I don't have any idea how to do this in Objective C. Especially, the static part which calls the getLocalAddress() method and assign it into the static string variable. I know how to set a static variable and a static method in Objective but I dont know how to implement that static { } part in java. 
  Thanks in advance...</p>
  
  <pre><code>public class Address {
  
       public static String localIpAddress;
  
      static {
          localIpAddress =  getLocalIpAddress();
      }
  
      public Address() {
  
      }
  
      static String getLocalIpAddress() {
           //do something to get local ip address
       }
  </code></pre>
  
  <p>}</p>
  
  <p>I added this in my .h file</p>
  
  <pre><code> #import &lt;Foundation/Foundation.h&gt;
  
   extern NSString *localIpAddress;
  
   @class WifiAddrss;
  
   @interface Address : NSObject {
  
   }
  
   @end
  </code></pre>
  
  <p>And my .m file looks like</p>
  
  <pre><code> #import "Address.h"
   #import "WifiAddress.h"
  
   @implementation Address
  
   +(void)initialize{
       if(self == [Address class]){
           localIpAddress = [self getLocalIpAddress];
       }
   }
  
   +(NSString *)getLocalIpAddress{
        return address here
   }
  
   -(id)init{    
       self = [super init];
       if (self == nil){
           NSLog(@"init error");
       }
  
       return self;
   }
   @end
  </code></pre>
  
  <p>And Now I am getting a linking error and it complains about "extern NSString *localIpAddress" part. If I change the extern to static, it works fine. But what I wanted to do is that I want make the scope of "localIpAddress" variable as grobal. Since if I put "static" in front of a variable in Objective-C then the variable is only visible in the class. But this time, I want to make that as a grobal variable. So my question is how to make "localIpAddress" variable as a grobal variable which is initialized once when the first time Address class is created.. Thanks in advance...</p>