reachabilityForLocalWiFi crashes in iPhone 4 projects

Question: When I change the Xcode target from iPhone 3.2 (iOs 3.2, iPad) to iPhone 4 (iOS 4) my application crashes. Exception ‘NSInvalidArgumentException’ is fired. Error log is:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[Reachability<0x3701c> init]: cannot init a class object.'
*** Call stack at first throw:
    0   CoreFoundation    0x02d26919 __exceptionPreprocess + 185
    1   libobjc.A.dylib   0x02b3b5de objc_exception_throw + 47
    2   CoreFoundation    0x02d2823e +[NSObject(NSObject) init] + 174
    3   MyApp             0x0002222e +[Reachability reachabilityForLocalWiFi] + 86
What’s wrong? Answer: If your iPhone/iPad application requires WiFi and/or 3G connection, then you have to test if the network is available. This is a usability requirement that Apple enforces. The error is in the sample code Apple provided to all of us. Find the file of Reachability.m and uncomment the [super init]; line here:
+ (Reachability*) reachabilityForLocalWiFi;
    // [super init];      <------------
    struct sockaddr_in localWifiAddress;
    bzero(&localWifiAddress, sizeof(localWifiAddress));
    localWifiAddress.sin_len = sizeof(localWifiAddress);
    localWifiAddress.sin_family = AF_INET;
    // IN_LINKLOCALNETNUM is defined in <netinet/in.h> as
    localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
    Reachability* retVal = [self reachabilityWithAddress: &localWifiAddress];
    if(retVal!= NULL)
        retVal->localWiFiRef = YES;
    return retVal;
Please note that if your application uses a WiFi network connection, you should enable UIRequiresPersistentWiFi, ie. Application uses Wi-Fi, in your app’s Info.plist. Otherwise the device will put its WiFi connection to sleep after a few minutes. For the WiFi network it can take 10 seconds or more to be alive after the device is woken up from sleep.