问:
Asihttprequest 61 errors
I'm using the ASIhttprequest in many projects but recently with each new project when I'm trying to add the ASIhttprequest classes I get the following error before using classes just when I'm trying to import them:

Build finjan of project finjan with configuration Debug

```<code>Ld build/Debug-iphonesimulator/finjan.app/finjan normal i386
cd /Users/Apple/Desktop/application/finjan
setenv MACOSX_DEPLOYMENT_TARGET 10.5
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk -L/Users/Apple/Desktop/application/finjan/build/Debug-iphonesimulator -F/Users/Apple/Desktop/application/finjan/build/Debug-iphonesimulator -filelist /Users/Apple/Desktop/application/finjan/build/finjan.build/Debug-iphonesimulator/finjan.build/Objects-normal/i386/finjan.LinkFileList -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -framework AudioToolbox -framework AVFoundation -o /Users/Apple/Desktop/application/finjan/build/Debug-iphonesimulator/finjan.app/finjan

Undefined symbols:
  "_CFHTTPAuthenticationIsValid", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_CFHTTPMessageApplyCredentialDictionary", referenced from:
      -[ASIHTTPRequest applyAuthorizationHeader] in ASIHTTPRequest.o
      -[ASIHTTPRequest applyAuthorizationHeader] in ASIHTTPRequest.o
      -[ASIHTTPRequest applyProxyCredentials:] in ASIHTTPRequest.o
      -[ASIHTTPRequest applyCredentials:] in ASIHTTPRequest.o
  "_CFHTTPMessageIsHeaderComplete", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_kCFStreamPropertyHTTPSProxyPort", referenced from:
      _kCFStreamPropertyHTTPSProxyPort$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPSProxyPort$non_lazy_ptr)
  "_inflate", referenced from:
      +[ASIHTTPRequest uncompressZippedData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_kCFStreamSSLCertificates", referenced from:
      _kCFStreamSSLCertificates$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamSSLCertificates$non_lazy_ptr)
  "_CFNetworkCopyProxiesForAutoConfigurationScript", referenced from:
      +[ASIHTTPRequest proxiesForURL:fromPAC:] in ASIHTTPRequest.o
  "_kCFProxyTypeKey", referenced from:
      _kCFProxyTypeKey$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyTypeKey$non_lazy_ptr)
  "_CFReadStreamCreateForStreamedHTTPRequest", referenced from:
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
  "_kCFProxyPortNumberKey", referenced from:
      _kCFProxyPortNumberKey$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyPortNumberKey$non_lazy_ptr)
  "_kUTTagClassMIMEType", referenced from:
      _kUTTagClassMIMEType$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kUTTagClassMIMEType$non_lazy_ptr)
  "_inflateEnd", referenced from:
      +[ASIHTTPRequest uncompressZippedData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_inflateInit2_", referenced from:
      +[ASIHTTPRequest uncompressZippedData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_kCFProxyAutoConfigurationURLKey", referenced from:
      _kCFProxyAutoConfigurationURLKey$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyAutoConfigurationURLKey$non_lazy_ptr)
  "_CFHTTPAuthenticationRequiresUserNameAndPassword", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_kCFHTTPAuthenticationUsername", referenced from:
      _kCFHTTPAuthenticationUsername$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationUsername$non_lazy_ptr)
  "_kCFStreamPropertyHTTPProxy", referenced from:
      _kCFStreamPropertyHTTPProxy$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPProxyPort$non_lazy_ptr, _kCFStreamPropertyHTTPProxyHost$non_lazy_ptr , _kCFStreamPropertyHTTPProxy$non_lazy_ptr )
  "_kCFStreamPropertyHTTPResponseHeader", referenced from:
      _kCFStreamPropertyHTTPResponseHeader$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPResponseHeader$non_lazy_ptr)
  "_CFHTTPMessageGetResponseStatusCode", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_kCFProxyTypeHTTP", referenced from:
      _kCFProxyTypeHTTP$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyTypeHTTP$non_lazy_ptr)
  "_kCFHTTPAuthenticationSchemeBasic", referenced from:
      _kCFHTTPAuthenticationSchemeBasic$non_lazy_ptr in ASIAuthenticationDialog.o
      _kCFHTTPAuthenticationSchemeBasic$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationSchemeBasic$non_lazy_ptr)
  "_SCNetworkReachabilityScheduleWithRunLoop", referenced from:
      -[Reachability startNotifier] in Reachability.o
  "_SCNetworkReachabilityGetFlags", referenced from:
      -[Reachability currentReachabilityStatus] in Reachability.o
      -[Reachability isReachable] in Reachability.o
      -[Reachability isConnectionRequired] in Reachability.o
      -[Reachability isConnectionOnDemand] in Reachability.o
      -[Reachability isInterventionRequired] in Reachability.o
      -[Reachability isReachableViaWWAN] in Reachability.o
      -[Reachability isReachableViaWiFi] in Reachability.o
      -[Reachability reachabilityFlags] in Reachability.o
  "_deflateInit2_", referenced from:
      +[ASIHTTPRequest compressData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_CFNetworkCopyProxiesForURL", referenced from:
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
      +[ASIHTTPRequest proxiesForURL:fromPAC:] in ASIHTTPRequest.o
  "_CFHTTPMessageSetHeaderFieldValue", referenced from:
      -[ASIHTTPRequest main] in ASIHTTPRequest.o
      -[ASIHTTPRequest checkRequestStatus] in ASIHTTPRequest.o
  "_kCFProxyTypeSOCKS", referenced from:
      _kCFProxyTypeSOCKS$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyTypeSOCKS$non_lazy_ptr)
  "_kCFStreamPropertyHTTPAttemptPersistentConnection", referenced from:
      _kCFStreamPropertyHTTPAttemptPersistentConnection$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPAttemptPersistentConnection$non_lazy_ptr)
  "_CFHTTPMessageCopyVersion", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_CFHTTPAuthenticationCopyRealm", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_CFHTTPMessageCopyAllHeaderFields", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_CFHTTPMessageCreateRequest", referenced from:
      -[ASIHTTPRequest main] in ASIHTTPRequest.o
  "_kCFProxyHostNameKey", referenced from:
      _kCFProxyHostNameKey$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyHostNameKey$non_lazy_ptr)
  "_kCFStreamPropertyHTTPProxyHost", referenced from:
      _kCFStreamPropertyHTTPProxyHost$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPProxyHost$non_lazy_ptr)
  "_CFHTTPMessageCopyResponseStatusLine", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_kCFStreamPropertyHTTPRequestBytesWrittenCount", referenced from:
      _kCFStreamPropertyHTTPRequestBytesWrittenCount$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPRequestBytesWrittenCount$non_lazy_ptr)
  "_deflate", referenced from:
      +[ASIHTTPRequest compressData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_SCNetworkReachabilityCreateWithAddress", referenced from:
      +[Reachability reachabilityWithAddress:] in Reachability.o
  "_kCFErrorDomainCFNetwork", referenced from:
      _kCFErrorDomainCFNetwork$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFErrorDomainCFNetwork$non_lazy_ptr)
  "_kCFStreamSSLValidatesCertificateChain", referenced from:
      _kCFStreamSSLValidatesCertificateChain$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamSSLValidatesCertificateChain$non_lazy_ptr)
  "_CFHTTPAuthenticationCreateFromResponse", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_deflateEnd", referenced from:
      +[ASIHTTPRequest compressData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_UTTypeCopyPreferredTagWithClass", referenced from:
      +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
  "_kCFStreamPropertyHTTPSProxyHost", referenced from:
      _kCFStreamPropertyHTTPSProxyHost$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPSProxyHost$non_lazy_ptr)
  "_kCFHTTPAuthenticationSchemeNTLM", referenced from:
      _kCFHTTPAuthenticationSchemeNTLM$non_lazy_ptr in ASIAuthenticationDialog.o
      _kCFHTTPAuthenticationSchemeNTLM$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationSchemeNTLM$non_lazy_ptr)
  "_CFHTTPAuthenticationCopyMethod", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_kCFHTTPAuthenticationAccountDomain", referenced from:
      _kCFHTTPAuthenticationAccountDomain$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationAccountDomain$non_lazy_ptr)
  "_UTTypeCreatePreferredIdentifierForTag", referenced from:
      +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
  "_CFNetworkCopySystemProxySettings", referenced from:
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
  "_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:
      -[Reachability stopNotifier] in Reachability.o
  "_kCFStreamPropertyHTTPProxyPort", referenced from:
      _kCFStreamPropertyHTTPProxyPort$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPProxyPort$non_lazy_ptr)
  "_CFHTTPAuthenticationRequiresAccountDomain", referenced from:
      -[ASIHTTPRequest findProxyCredentials] in ASIHTTPRequest.o
      -[ASIHTTPRequest findCredentials] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_SCNetworkReachabilityCreateWithName", referenced from:
      +[Reachability reachabilityWithHostName:] in Reachability.o
  "_SCNetworkReachabilitySetCallback", referenced from:
      -[Reachability startNotifier] in Reachability.o
  "_kCFHTTPAuthenticationPassword", referenced from:
      _kCFHTTPAuthenticationPassword$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationPassword$non_lazy_ptr)
  "_kCFHTTPVersion1_0", referenced from:
      _kCFHTTPVersion1_0$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPVersion1_0$non_lazy_ptr)
  "_kCFHTTPVersion1_1", referenced from:
      _kCFHTTPVersion1_1$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPVersion1_1$non_lazy_ptr)
  "_kCFStreamPropertySSLSettings", referenced from:
      _kCFStreamPropertySSLSettings$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertySSLSettings$non_lazy_ptr)
  "_kCFStreamErrorDomainHTTP", referenced from:
      _kCFStreamErrorDomainHTTP$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamErrorDomainHTTP$non_lazy_ptr)
  "_CFReadStreamCreateForHTTPRequest", referenced from:
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
  "_kUTTagClassFilenameExtension", referenced from:
      _kUTTagClassFilenameExtension$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kUTTagClassFilenameExtension$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status
</code>```

What is causing this?

答:
More specifically, it requires CFNetwork, SystemConfiguration, MobileCoreServices, and lib (libz.tbd for iOS 9).

Edit: It also needs libxml2

Title: Asihttprequest 61 errors

Body:
I'm using the ASIhttprequest in many projects but recently with each new project when I'm trying to add the ASIhttprequest classes I get the following error before using classes just when I'm trying to import them:

Build finjan of project finjan with configuration Debug

Ld build/Debug-iphonesimulator/finjan.app/finjan normal i386
cd /Users/Apple/Desktop/application/finjan
setenv MACOSX_DEPLOYMENT_TARGET 10.5
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk -L/Users/Apple/Desktop/application/finjan/build/Debug-iphonesimulator -F/Users/Apple/Desktop/application/finjan/build/Debug-iphonesimulator -filelist /Users/Apple/Desktop/application/finjan/build/finjan.build/Debug-iphonesimulator/finjan.build/Objects-normal/i386/finjan.LinkFileList -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -framework AudioToolbox -framework AVFoundation -o /Users/Apple/Desktop/application/finjan/build/Debug-iphonesimulator/finjan.app/finjan

Undefined symbols:
  "_CFHTTPAuthenticationIsValid", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_CFHTTPMessageApplyCredentialDictionary", referenced from:
      -[ASIHTTPRequest applyAuthorizationHeader] in ASIHTTPRequest.o
      -[ASIHTTPRequest applyAuthorizationHeader] in ASIHTTPRequest.o
      -[ASIHTTPRequest applyProxyCredentials:] in ASIHTTPRequest.o
      -[ASIHTTPRequest applyCredentials:] in ASIHTTPRequest.o
  "_CFHTTPMessageIsHeaderComplete", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_kCFStreamPropertyHTTPSProxyPort", referenced from:
      _kCFStreamPropertyHTTPSProxyPort$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPSProxyPort$non_lazy_ptr)
  "_inflate", referenced from:
      +[ASIHTTPRequest uncompressZippedData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_kCFStreamSSLCertificates", referenced from:
      _kCFStreamSSLCertificates$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamSSLCertificates$non_lazy_ptr)
  "_CFNetworkCopyProxiesForAutoConfigurationScript", referenced from:
      +[ASIHTTPRequest proxiesForURL:fromPAC:] in ASIHTTPRequest.o
  "_kCFProxyTypeKey", referenced from:
      _kCFProxyTypeKey$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyTypeKey$non_lazy_ptr)
  "_CFReadStreamCreateForStreamedHTTPRequest", referenced from:
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
  "_kCFProxyPortNumberKey", referenced from:
      _kCFProxyPortNumberKey$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyPortNumberKey$non_lazy_ptr)
  "_kUTTagClassMIMEType", referenced from:
      _kUTTagClassMIMEType$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kUTTagClassMIMEType$non_lazy_ptr)
  "_inflateEnd", referenced from:
      +[ASIHTTPRequest uncompressZippedData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_inflateInit2_", referenced from:
      +[ASIHTTPRequest uncompressZippedData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest uncompressZippedDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_kCFProxyAutoConfigurationURLKey", referenced from:
      _kCFProxyAutoConfigurationURLKey$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyAutoConfigurationURLKey$non_lazy_ptr)
  "_CFHTTPAuthenticationRequiresUserNameAndPassword", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_kCFHTTPAuthenticationUsername", referenced from:
      _kCFHTTPAuthenticationUsername$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationUsername$non_lazy_ptr)
  "_kCFStreamPropertyHTTPProxy", referenced from:
      _kCFStreamPropertyHTTPProxy$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPProxyPort$non_lazy_ptr, _kCFStreamPropertyHTTPProxyHost$non_lazy_ptr , _kCFStreamPropertyHTTPProxy$non_lazy_ptr )
  "_kCFStreamPropertyHTTPResponseHeader", referenced from:
      _kCFStreamPropertyHTTPResponseHeader$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPResponseHeader$non_lazy_ptr)
  "_CFHTTPMessageGetResponseStatusCode", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_kCFProxyTypeHTTP", referenced from:
      _kCFProxyTypeHTTP$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyTypeHTTP$non_lazy_ptr)
  "_kCFHTTPAuthenticationSchemeBasic", referenced from:
      _kCFHTTPAuthenticationSchemeBasic$non_lazy_ptr in ASIAuthenticationDialog.o
      _kCFHTTPAuthenticationSchemeBasic$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationSchemeBasic$non_lazy_ptr)
  "_SCNetworkReachabilityScheduleWithRunLoop", referenced from:
      -[Reachability startNotifier] in Reachability.o
  "_SCNetworkReachabilityGetFlags", referenced from:
      -[Reachability currentReachabilityStatus] in Reachability.o
      -[Reachability isReachable] in Reachability.o
      -[Reachability isConnectionRequired] in Reachability.o
      -[Reachability isConnectionOnDemand] in Reachability.o
      -[Reachability isInterventionRequired] in Reachability.o
      -[Reachability isReachableViaWWAN] in Reachability.o
      -[Reachability isReachableViaWiFi] in Reachability.o
      -[Reachability reachabilityFlags] in Reachability.o
  "_deflateInit2_", referenced from:
      +[ASIHTTPRequest compressData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_CFNetworkCopyProxiesForURL", referenced from:
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
      +[ASIHTTPRequest proxiesForURL:fromPAC:] in ASIHTTPRequest.o
  "_CFHTTPMessageSetHeaderFieldValue", referenced from:
      -[ASIHTTPRequest main] in ASIHTTPRequest.o
      -[ASIHTTPRequest checkRequestStatus] in ASIHTTPRequest.o
  "_kCFProxyTypeSOCKS", referenced from:
      _kCFProxyTypeSOCKS$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyTypeSOCKS$non_lazy_ptr)
  "_kCFStreamPropertyHTTPAttemptPersistentConnection", referenced from:
      _kCFStreamPropertyHTTPAttemptPersistentConnection$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPAttemptPersistentConnection$non_lazy_ptr)
  "_CFHTTPMessageCopyVersion", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_CFHTTPAuthenticationCopyRealm", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_CFHTTPMessageCopyAllHeaderFields", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_CFHTTPMessageCreateRequest", referenced from:
      -[ASIHTTPRequest main] in ASIHTTPRequest.o
  "_kCFProxyHostNameKey", referenced from:
      _kCFProxyHostNameKey$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFProxyHostNameKey$non_lazy_ptr)
  "_kCFStreamPropertyHTTPProxyHost", referenced from:
      _kCFStreamPropertyHTTPProxyHost$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPProxyHost$non_lazy_ptr)
  "_CFHTTPMessageCopyResponseStatusLine", referenced from:
      -[ASIHTTPRequest readResponseHeaders] in ASIHTTPRequest.o
  "_kCFStreamPropertyHTTPRequestBytesWrittenCount", referenced from:
      _kCFStreamPropertyHTTPRequestBytesWrittenCount$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPRequestBytesWrittenCount$non_lazy_ptr)
  "_deflate", referenced from:
      +[ASIHTTPRequest compressData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_SCNetworkReachabilityCreateWithAddress", referenced from:
      +[Reachability reachabilityWithAddress:] in Reachability.o
  "_kCFErrorDomainCFNetwork", referenced from:
      _kCFErrorDomainCFNetwork$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFErrorDomainCFNetwork$non_lazy_ptr)
  "_kCFStreamSSLValidatesCertificateChain", referenced from:
      _kCFStreamSSLValidatesCertificateChain$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamSSLValidatesCertificateChain$non_lazy_ptr)
  "_CFHTTPAuthenticationCreateFromResponse", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_deflateEnd", referenced from:
      +[ASIHTTPRequest compressData:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
      +[ASIHTTPRequest compressDataFromSource:toDestination:] in ASIHTTPRequest.o
  "_UTTypeCopyPreferredTagWithClass", referenced from:
      +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
  "_kCFStreamPropertyHTTPSProxyHost", referenced from:
      _kCFStreamPropertyHTTPSProxyHost$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPSProxyHost$non_lazy_ptr)
  "_kCFHTTPAuthenticationSchemeNTLM", referenced from:
      _kCFHTTPAuthenticationSchemeNTLM$non_lazy_ptr in ASIAuthenticationDialog.o
      _kCFHTTPAuthenticationSchemeNTLM$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationSchemeNTLM$non_lazy_ptr)
  "_CFHTTPAuthenticationCopyMethod", referenced from:
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_kCFHTTPAuthenticationAccountDomain", referenced from:
      _kCFHTTPAuthenticationAccountDomain$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationAccountDomain$non_lazy_ptr)
  "_UTTypeCreatePreferredIdentifierForTag", referenced from:
      +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
  "_CFNetworkCopySystemProxySettings", referenced from:
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
  "_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:
      -[Reachability stopNotifier] in Reachability.o
  "_kCFStreamPropertyHTTPProxyPort", referenced from:
      _kCFStreamPropertyHTTPProxyPort$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertyHTTPProxyPort$non_lazy_ptr)
  "_CFHTTPAuthenticationRequiresAccountDomain", referenced from:
      -[ASIHTTPRequest findProxyCredentials] in ASIHTTPRequest.o
      -[ASIHTTPRequest findCredentials] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyProxyCredentialsAndResume] in ASIHTTPRequest.o
      -[ASIHTTPRequest attemptToApplyCredentialsAndResume] in ASIHTTPRequest.o
  "_SCNetworkReachabilityCreateWithName", referenced from:
      +[Reachability reachabilityWithHostName:] in Reachability.o
  "_SCNetworkReachabilitySetCallback", referenced from:
      -[Reachability startNotifier] in Reachability.o
  "_kCFHTTPAuthenticationPassword", referenced from:
      _kCFHTTPAuthenticationPassword$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPAuthenticationPassword$non_lazy_ptr)
  "_kCFHTTPVersion1_0", referenced from:
      _kCFHTTPVersion1_0$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPVersion1_0$non_lazy_ptr)
  "_kCFHTTPVersion1_1", referenced from:
      _kCFHTTPVersion1_1$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFHTTPVersion1_1$non_lazy_ptr)
  "_kCFStreamPropertySSLSettings", referenced from:
      _kCFStreamPropertySSLSettings$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamPropertySSLSettings$non_lazy_ptr)
  "_kCFStreamErrorDomainHTTP", referenced from:
      _kCFStreamErrorDomainHTTP$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kCFStreamErrorDomainHTTP$non_lazy_ptr)
  "_CFReadStreamCreateForHTTPRequest", referenced from:
      -[ASIHTTPRequest startRequest] in ASIHTTPRequest.o
  "_kUTTagClassFilenameExtension", referenced from:
      _kUTTagClassFilenameExtension$non_lazy_ptr in ASIHTTPRequest.o
     (maybe you meant: _kUTTagClassFilenameExtension$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status

What is causing this?


来源: stackexchange

问:
Are references orthogonal to pointers?
The question is meant as language orthogonal(as is in lack of redundency) features. References (never null[1]) in C++ can be implemented with pointers while compilers check for the semantic differences. There are languages like Java or C# that only have references (maybe null) but no pointers and C has it the other way round. So one is sufficent for a complete language. Is the behaviour in C++ different enough to be orthogonal?

[1] You can de-reference a nullptr but that is undefined.

答:
Due to reference collapsing rules (§8.3.2), references has become
quite useful; they now support "perfect forwarding" something not
possible with pointers. Example:

```<code>template<typename T>
class some_container
{
public:
    // ... lots of other stuff
    template<typename... Args>
    void emplace_back(Args&&... args)
    {
        T* ptr = find_slot_for_new_data();
        new (ptr) T( std::forward<Args>(args)... );
    }
};
</code>```

This will construct a T in-place, (emplace_xxx are delegating constructors)
and it will use
"perfect forwarding" to do so, that is;

T&& where T is deduced will preserve the:

type

value category

cv-qualifiers

This is not possible with pointers.

ContentLicense: CC BY-SA 3.0

Title: Are references orthogonal to pointers?

Body:
Due to reference collapsing rules (§8.3.2), references has become
quite useful; they now support "perfect forwarding" something not
possible with pointers. Example:

template<typename T>
class some_container
{
public:
    // ... lots of other stuff
    template<typename... Args>
    void emplace_back(Args&&... args)
    {
        T* ptr = find_slot_for_new_data();
        new (ptr) T( std::forward<Args>(args)... );
    }
};

This will construct a T in-place, (emplace_xxx are delegating constructors)
and it will use
"perfect forwarding" to do so, that is;

T&& where T is deduced will preserve the:

type

value category

cv-qualifiers

This is not possible with pointers.


问:
Show not matching strings in two files
I am trying to do a mutiple search. In one file I've got some words and I want to get back those which are not in the second one.

For example if I got lamp and cat in file 1 and I love cats in file 2, I need to have back lamp. File 1 would be a list of 2.800 words and file 2 a book with 900.000 words. I'm looking to get those of the 2.800 that do not appear.

Is it possible somehow?

I've tried this:

```<code>awk 'FNR==NR {a[$1]; next} {for (i=1;i<=NF;i++) {if ($i in a) delete a[$i]}} END {for (i in a) print i}' File1.rtf File2.rtf
</code>```

and this

```<code>while read word; do grep -q "$word" File2.rtf || echo "$word"; done < File1.rtf
</code>```

Thank you very much for your help!!

答:
Your filenames suggest that you're dealing with RTF files, which you'd need to convert to plain text first.

Your awk-based solution attempt would only work if (a) the 2nd file contained no punctuation and (b) it is acceptable to treat word variations (such as cat vs. cats) as separate words.

Your grep-based solution will be very slow, because it creates a grep child process for every word in the list. Aside from that, it performs substring matching, which is probably not what you want.

The following variation of your awk command assumes plain-text input files and
that variations of a word can be treated separately; in other words: it only addresses the punctuation problem:

```<code>$ awk '
  FNR==NR {a[$1]; next}
  {
    for (i=1; i<=NF; i++) {
      # Remove punctuation from the field (word).
      gsub(/[[:punct:]]/, "", $i)
      if ($i in a) delete a[$i]}
    }
  END {for (i in a) print i}
' <(echo $'lamp\ncat') <(echo 'I love my cat.')
lamp
</code>```

Also note that the output words will be in no particular order, because the ordering of keys of an Awk array is undefined (it is an implementation detail).

Overall, you should consider specialized tools that support stemming; also, sorting your word list and the words in the book beforehand may speed up things.

Title: Show not matching strings in two files

Body:
I am trying to do a mutiple search. In one file I've got some words and I want to get back those which are not in the second one.

For example if I got lamp and cat in file 1 and I love cats in file 2, I need to have back lamp. File 1 would be a list of 2.800 words and file 2 a book with 900.000 words. I'm looking to get those of the 2.800 that do not appear.

Is it possible somehow?

I've tried this:

awk 'FNR==NR {a[$1]; next} {for (i=1;i<=NF;i++) {if ($i in a) delete a[$i]}} END {for (i in a) print i}' File1.rtf File2.rtf

and this

while read word; do grep -q "$word" File2.rtf || echo "$word"; done < File1.rtf

Thank you very much for your help!!

Body:
Your filenames suggest that you're dealing with RTF files, which you'd need to convert to plain text first.

Your awk-based solution attempt would only work if (a) the 2nd file contained no punctuation and (b) it is acceptable to treat word variations (such as cat vs. cats) as separate words.

Your grep-based solution will be very slow, because it creates a grep child process for every word in the list. Aside from that, it performs substring matching, which is probably not what you want.

The following variation of your awk command assumes plain-text input files and
that variations of a word can be treated separately; in other words: it only addresses the punctuation problem:

$ awk '
  FNR==NR {a[$1]; next}
  {
    for (i=1; i<=NF; i++) {
      # Remove punctuation from the field (word).
      gsub(/[[:punct:]]/, "", $i)
      if ($i in a) delete a[$i]}
    }
  END {for (i in a) print i}
' <(echo $'lamp\ncat') <(echo 'I love my cat.')
lamp

Also note that the output words will be in no particular order, because the ordering of keys of an Awk array is undefined (it is an implementation detail).

Overall, you should consider specialized tools that support stemming; also, sorting your word list and the words in the book beforehand may speed up things.


问:
How to read a file to a list of lists?
I want to create a list of lists from a file that contains the following data:

```<code>101 Rahul
102 Julie
103 Helena
104 Kally
</code>```

CODE

```<code>lis = []

with open("student_details.txt" , "r+") as f:
    for i in range(1,3,1):
        for data in f.read().split():
            lis.append(data)
print(lis)
</code>```

Output I Want

```<code>[[101,Rahul] ,[102,Julie] ,[103,Helena] ,[104,Kally]]
</code>```

Output I m getting

```<code>['101', 'Rahul', '102', 'Julie', '103', 'Helena', '104', 'Kally']
</code>```

答:
You could read line by line iterating on the handle or using readlines(), splitting each line, appending each result, etc... Fixing your code would require to remove the range loop which just reads the file 3 times (but only effectively reads once the first time), and append the splitted items of the lines, using a list comprehension to be more pythonic:

```<code>with open("student_details.txt" , "r+") as f:
     lis = [line.split() for line in f]
</code>```

note that the cool thing about line.split() (without parameters) is that it gets rid of the line terminator(s) automatically.

but you can make it simpler: csv module does all the parsing for you:

```<code>import csv
with open("student_details.txt" , "r") as f:
   cr = csv.reader(f,delimiter=" ")
   # iterate on rows and generate list of lists:
   result = list(cr)
</code>```

ContentLicense: CC BY-SA 4.0

Title: How to read a file to a list of lists?

Body:
I want to create a list of lists from a file that contains the following data:

101 Rahul
102 Julie
103 Helena
104 Kally

CODE

lis = []

with open("student_details.txt" , "r+") as f:
    for i in range(1,3,1):
        for data in f.read().split():
            lis.append(data)
print(lis)

Output I Want

[[101,Rahul] ,[102,Julie] ,[103,Helena] ,[104,Kally]]

Output I m getting

['101', 'Rahul', '102', 'Julie', '103', 'Helena', '104', 'Kally']

Body:
You could read line by line iterating on the handle or using readlines(), splitting each line, appending each result, etc... Fixing your code would require to remove the range loop which just reads the file 3 times (but only effectively reads once the first time), and append the splitted items of the lines, using a list comprehension to be more pythonic:

with open("student_details.txt" , "r+") as f:
     lis = [line.split() for line in f]

note that the cool thing about line.split() (without parameters) is that it gets rid of the line terminator(s) automatically.

but you can make it simpler: csv module does all the parsing for you:

import csv
with open("student_details.txt" , "r") as f:
   cr = csv.reader(f,delimiter=" ")
   # iterate on rows and generate list of lists:
   result = list(cr)


问:
Solve linear equations with minimum variance constraint from existing vector
Suppose there are given matrices A (m x n), B(n x 1), and C(m x 1)

We want to solve for X such that A dot X = C with the constraint that we want X to have minimum variance from B, i.e. min((X-B)^2)

Are there any python packages that work well with this kind of problems? Also the matrix B is likely to be large, with thousands of entries.

答:
Following Erwin's recommendation (in the comment), here is a solution using cvxpy.

Keep in mind, that you got two competing objectives! This means, you either have to balance these (which one is how important) or post one of these as a fixed constraint (e.g. variance-diff lower than some given constant). Here is some code for the former.

Another remark: while your original variance-term is sum-of-squares, i'm using the euclidean norm here, which is better in regards to solving (nice SOCP problem-formulation) and probably more interesting too in regards to balancing with alpha, as both grow the same (asymptotically).

The default-solver used is ECOS (open-source).

Code

```<code>import numpy as np
from cvxpy import *

""" Random data """
M = 10
N = 10
A = np.random.rand(M,N)
B = np.random.rand(N)
C = np.random.rand(M)

""" Solve """
alpha = 0.01                                             # Regularization
factor -> multiple objectives

X = Variable(B.shape[0])
component_A, component_B = norm(A * X - C), norm(X - B)  # norm more useful than sum_of_squares
objective = Minimize(component_A + alpha * component_B)
problem = Problem(objective, [])                         # [] = no constraints
problem.solve(verbose=False)

print(problem.value)
print('A*X: ', A.dot(X.value).T.flatten())
print('C: ', C)
print('X: ', X.value.T.flatten())
print('B: ', B)
</code>```

Output alpha=0.1 -> variance-diff not that important in comparison to A*X=C

```<code>0.02115062805819827
A*X:  [[ 0.08126681  0.61685533  0.51072777  0.62493694  0.33443435  0.70281179
   0.89593751  0.34521676  0.16157952  0.62992064]]
C:  [ 0.08126681  0.61685533  0.51072777  0.62493694  0.33443435  0.70281179
  0.89593751  0.34521676  0.16157952  0.62992064]
X:  [[-0.03327532 -0.32668216 -0.44441417  0.75708529 -0.00958777 -0.33155358
   0.60025503  0.52237198  0.3052468  -0.14709605]]
B:  [ 0.89801455  0.50875127  0.77806572  0.17184964  0.06610118  0.27861303
  0.40513181  0.85778655  0.86835541  0.32786036]
</code>```

Output alpha=10 -> variance more important compared to A*X=C

```<code>5.3146149509187195
A*X:  [[ 1.87714559  2.11056115  1.74268386  1.68503155  2.59590194
1.9540973 2.37874233  2.07600857  1.6713983   1.2590621 ]]
C:  [ 0.18125564  0.33469345  0.63367096  0.0075308   0.19983206  0.76975212
  0.22084296  0.35758024  0.0214036   0.42501635]
X:  [[ 0.25227884  0.4022509   0.17074389  0.22068181  0.04595178 0.85354537
   0.1039422   0.76882144  0.85936741  0.14723398]]
B:  [ 0.25227884  0.4022509   0.17074389  0.22068181  0.04595178  0.85354537
  0.1039422   0.76882144  0.85936741  0.14723398]
</code>```

A random dense 1000x1000 problem took 15 secs on my machine using ECOS (commercial solver MOSEK will do it in ~ 1 sec). One could also use solver SCS, which can be much faster with slightly reduced precision (and can run on GPU in one of two configurations -> indirect-mode).

Both solvers can gain a lot if your problem would be sparse.

Body:
Following Erwin's recommendation (in the comment), here is a solution using cvxpy.

Keep in mind, that you got two competing objectives! This means, you either have to balance these (which one is how important) or post one of these as a fixed constraint (e.g. variance-diff lower than some given constant). Here is some code for the former.

Another remark: while your original variance-term is sum-of-squares, i'm using the euclidean norm here, which is better in regards to solving (nice SOCP problem-formulation) and probably more interesting too in regards to balancing with alpha, as both grow the same (asymptotically).

The default-solver used is ECOS (open-source).

Code

import numpy as np
from cvxpy import *

""" Random data """
M = 10
N = 10
A = np.random.rand(M,N)
B = np.random.rand(N)
C = np.random.rand(M)

""" Solve """
alpha = 0.01                                             # Regularization
factor -> multiple objectives

X = Variable(B.shape[0])
component_A, component_B = norm(A * X - C), norm(X - B)  # norm more useful than sum_of_squares
objective = Minimize(component_A + alpha * component_B)
problem = Problem(objective, [])                         # [] = no constraints
problem.solve(verbose=False)

print(problem.value)
print('A*X: ', A.dot(X.value).T.flatten())
print('C: ', C)
print('X: ', X.value.T.flatten())
print('B: ', B)

Output alpha=0.1 -> variance-diff not that important in comparison to A*X=C

0.02115062805819827
A*X:  [[ 0.08126681  0.61685533  0.51072777  0.62493694  0.33443435  0.70281179
   0.89593751  0.34521676  0.16157952  0.62992064]]
C:  [ 0.08126681  0.61685533  0.51072777  0.62493694  0.33443435  0.70281179
  0.89593751  0.34521676  0.16157952  0.62992064]
X:  [[-0.03327532 -0.32668216 -0.44441417  0.75708529 -0.00958777 -0.33155358
   0.60025503  0.52237198  0.3052468  -0.14709605]]
B:  [ 0.89801455  0.50875127  0.77806572  0.17184964  0.06610118  0.27861303
  0.40513181  0.85778655  0.86835541  0.32786036]

Output alpha=10 -> variance more important compared to A*X=C

5.3146149509187195
A*X:  [[ 1.87714559  2.11056115  1.74268386  1.68503155  2.59590194
1.9540973 2.37874233  2.07600857  1.6713983   1.2590621 ]]
C:  [ 0.18125564  0.33469345  0.63367096  0.0075308   0.19983206  0.76975212
  0.22084296  0.35758024  0.0214036   0.42501635]
X:  [[ 0.25227884  0.4022509   0.17074389  0.22068181  0.04595178 0.85354537
   0.1039422   0.76882144  0.85936741  0.14723398]]
B:  [ 0.25227884  0.4022509   0.17074389  0.22068181  0.04595178  0.85354537
  0.1039422   0.76882144  0.85936741  0.14723398]

A random dense 1000x1000 problem took 15 secs on my machine using ECOS (commercial solver MOSEK will do it in ~ 1 sec). One could also use solver SCS, which can be much faster with slightly reduced precision (and can run on GPU in one of two configurations -> indirect-mode).

Both solvers can gain a lot if your problem would be sparse.


问:
About the "delete" command of C++
I am a new C++ learner. I have a simple question. Here is the code from a book. Is it necessary to create a new pointer, "pCat"? Can I just use the "rCat" and delete it? If not, why? </p>

```<code>class SimpleCat
{
public:
    SimpleCat (int age, int weight);

    ~SimpleCat() {}

    int GetAge() { return itsAge; }
    int GetWeight() { return itsWeight; }

private:
    int itsAge;
    int itsWeight;
};

SimpleCat::SimpleCat(int age, int weight):
    itsAge(age), itsWeight(weight) {}

SimpleCat* TheFunction();

int main()
{
    SimpleCat* rCat = TheFunction();

    int age = rCat->GetAge();

    std::cout << "rCat is " << age << " years old!\n";

    std::cout << "rCat: " << rCat << "\n";
    // How do you get rid of that memory?
    SimpleCat* pCat = rCat;
    delete pCat;
    return 0;
}

SimpleCat* TheFunction()
{
    SimpleCat *pFrisky = new SimpleCat(5,9);``
    std::cout << "pFrisky: " << pFrisky << "\n";
    return pFrisky;
}
</code>```

答:
Given that definition of TheFunction, yes, you should eventually delete the return value.  Note you could just delete rCat; directly - you don't need to copy it into another pointer pCat and then delete that.

However, it would be better if TheFunction returned a std::unique_ptr<SimpleCat> instead of a raw SimpleCat* pointer.

First, this makes it clear that the returned value is something that must be cleaned up, and not for example a pointer to something actually stored somewhere else.

Second, the caller wouldn't need to actually use delete at all, since the unique_ptr object does that for you.

Title: About the "delete" command of C++

Body:
I am a new C++ learner. I have a simple question. Here is the code from a book. Is it necessary to create a new pointer, "pCat"? Can I just use the "rCat" and delete it? If not, why?

class SimpleCat
{
public:
    SimpleCat (int age, int weight);

    ~SimpleCat() {}

    int GetAge() { return itsAge; }
    int GetWeight() { return itsWeight; }

private:
    int itsAge;
    int itsWeight;
};

SimpleCat::SimpleCat(int age, int weight):
    itsAge(age), itsWeight(weight) {}

SimpleCat* TheFunction();

int main()
{
    SimpleCat* rCat = TheFunction();

    int age = rCat->GetAge();

    std::cout << "rCat is " << age << " years old!\n";

    std::cout << "rCat: " << rCat << "\n";
    // How do you get rid of that memory?
    SimpleCat* pCat = rCat;
    delete pCat;
    return 0;
}

SimpleCat* TheFunction()
{
    SimpleCat *pFrisky = new SimpleCat(5,9);``
    std::cout << "pFrisky: " << pFrisky << "\n";
    return pFrisky;
}


问:
How to transform ES2017 to ES5
I have a es2017 code with async/await, I want to transform it to es5 so that it'll be supported by most Node.js versions.

My current .babelrc file looks like this:

```<code>{
    "presets": ["es2015", "es2016", "es2017"]
}
</code>```

So I'm transforming es2017 to es2016, from es2016 to es2015 and from es2015 to es5.

When I'm trying to run the code after I built it with babel src -d dist -s I'm getting error saying that: ReferenceError: regeneratorRuntime is not defined

How can I transform the es2017 code to es5? I wanna publish the code later and make it usable by node.js v4 and up.

答:
Thanks to @Bergi I found a way how to solve this ReferenceError: regeneratorRuntime is not defined error.

I added the transform-runtime plugin to my .babelrc

Now my .babelrc is:

```<code>{
    "presets": ["es2015", "es2016", "es2017"],
    "plugins": ["transform-runtime"]
}
</code>```

There aren't any errors now and it works fine.

Title: How to transform ES2017 to ES5

Body:
I have a es2017 code with async/await, I want to transform it to es5 so that it'll be supported by most Node.js versions.

My current .babelrc file looks like this:

{
    "presets": ["es2015", "es2016", "es2017"]
}

So I'm transforming es2017 to es2016, from es2016 to es2015 and from es2015 to es5.

When I'm trying to run the code after I built it with babel src -d dist -s I'm getting error saying that: ReferenceError: regeneratorRuntime is not defined

How can I transform the es2017 code to es5? I wanna publish the code later and make it usable by node.js v4 and up.

Body:
Thanks to @Bergi I found a way how to solve this ReferenceError: regeneratorRuntime is not defined error.

I added the transform-runtime plugin to my .babelrc

Now my .babelrc is:

{
    "presets": ["es2015", "es2016", "es2017"],
    "plugins": ["transform-runtime"]
}

There aren't any errors now and it works fine.


问:
How to get only City, State, Country from lat, long in android
I have the below code to convert lat, long to human readable address. Now iam getting full details including street name. How can i get only city, state, country? I don't want anything more details.  Please help me. </p>

```<code>Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault());
try {
   List<Address> addresses = geoCoder.getFromLocation(latitude, longitude, 1);

   String add = "";
   if (addresses.size() > 0)
   {
      for (int i=0; i<addresses.get(0).getMaxAddressLineIndex();i++)
     add += addresses.get(0).getAddressLine(i) + "\n";
   }

   showToastMessage(add);
}
catch (IOException e1) {
   e1.printStackTrace();
}
</code>```

答:
Add this list of country code in the your string file.

```<code><string-array name="CountryCodes">
        <item>93,AF</item>
        <item>355,AL</item>
        <item>213,DZ</item>
        <item>376,AD</item>
        <item>244,AO</item>
        <item>672,AQ</item>
        <item>54,AR</item>
        <item>374,AM</item>
        <item>297,AW</item>
        <item>61,AU</item>
        <item>43,AT</item>
        <item>994,AZ</item>
        <item>973,BH</item>
        <item>880,BD</item>
        <item>375,BY</item>
        <item>32,BE</item>
        <item>501,BZ</item>
        <item>229,BJ</item>
        <item>975,BT</item>
        <item>591,BO</item>
        <item>387,BA</item>
        <item>267,BW</item>
        <item>55,BR</item>
        <item>673,BN</item>
        <item>359,BG</item>
        <item>226,BF</item>
        <item>95,MM</item>
        <item>257,BI</item>
        <item>855,KH</item>
        <item>237,CM</item>
        <item>1,CA</item>
        <item>238,CV</item>
        <item>236,CF</item>
        <item>235,TD</item>
        <item>56,CL</item>
        <item>86,CN</item>
        <item>61,CX</item>
        <item>61,CC</item>
        <item>57,CO</item>
        <item>269,KM</item>
        <item>242,CG</item>
        <item>243,CD</item>
        <item>682,CK</item>
        <item>506,CR</item>
        <item>385,HR</item>
        <item>53,CU</item>
        <item>357,CY</item>
        <item>420,CZ</item>
        <item>45,DK</item>
        <item>253,DJ</item>
        <item>670,TL</item>
        <item>593,EC</item>
        <item>20,EG</item>
        <item>503,SV</item>
        <item>240,GQ</item>
        <item>291,ER</item>
        <item>372,EE</item>
        <item>251,ET</item>
        <item>500,FK</item>
        <item>298,FO</item>
        <item>679,FJ</item>
        <item>358,FI</item>
        <item>33,FR</item>
        <item>689,PF</item>
        <item>241,GA</item>
        <item>220,GM</item>
        <item>995,GE</item>
        <item>49,DE</item>
        <item>233,GH</item>
        <item>350,GI</item>
        <item>30,GR</item>
        <item>299,GL</item>
        <item>502,GT</item>
        <item>224,GN</item>
        <item>245,GW</item>
        <item>592,GY</item>
        <item>509,HT</item>
        <item>504,HN</item>
        <item>852,HK</item>
        <item>36,HU</item>
        <item>91,IN</item>
        <item>62,ID</item>
        <item>98,IR</item>
        <item>964,IQ</item>
        <item>353,IE</item>
        <item>44,IM</item>
        <item>972,IL</item>
        <item>39,IT</item>
        <item>225,CI</item>
        <item>81,JP</item>
        <item>962,JO</item>
        <item>7,KZ</item>
        <item>254,KE</item>
        <item>686,KI</item>
        <item>965,KW</item>
        <item>996,KG</item>
        <item>856,LA</item>
        <item>371,LV</item>
        <item>961,LB</item>
        <item>266,LS</item>
        <item>231,LR</item>
        <item>218,LY</item>
        <item>423,LI</item>
        <item>370,LT</item>
        <item>352,LU</item>
        <item>853,MO</item>
        <item>389,MK</item>
        <item>261,MG</item>
        <item>265,MW</item>
        <item>60,MY</item>
        <item>960,MV</item>
        <item>223,ML</item>
        <item>356,MT</item>
        <item>692,MH</item>
        <item>222,MR</item>
        <item>230,MU</item>
        <item>262,YT</item>
        <item>52,MX</item>
        <item>691,FM</item>
        <item>373,MD</item>
        <item>377,MC</item>
        <item>976,MN</item>
        <item>382,ME</item>
        <item>212,MA</item>
        <item>258,MZ</item>
        <item>264,NA</item>
        <item>674,NR</item>
        <item>977,NP</item>
        <item>31,NL</item>
        <item>599,AN</item>
        <item>687,NC</item>
        <item>64,NZ</item>
        <item>505,NI</item>
        <item>227,NE</item>
        <item>234,NG</item>
        <item>683,NU</item>
        <item>850,KP</item>
        <item>47,NO</item>
        <item>968,OM</item>
        <item>92,PK</item>
        <item>680,PW</item>
        <item>507,PA</item>
        <item>675,PG</item>
        <item>595,PY</item>
        <item>51,PE</item>
        <item>63,PH</item>
        <item>870,PN</item>
        <item>48,PL</item>
        <item>351,PT</item>
        <item>1,PR</item>
        <item>974,QA</item>
        <item>40,RO</item>
        <item>7,RU</item>
        <item>250,RW</item>
        <item>590,BL</item>
        <item>685,WS</item>
        <item>378,SM</item>
        <item>239,ST</item>
        <item>966,SA</item>
        <item>221,SN</item>
        <item>381,RS</item>
        <item>248,SC</item>
        <item>232,SL</item>
        <item>65,SG</item>
        <item>421,SK</item>
        <item>386,SI</item>
        <item>677,SB</item>
        <item>252,SO</item>
        <item>27,ZA</item>
        <item>82,KR</item>
        <item>34,ES</item>
        <item>94,LK</item>
        <item>290,SH</item>
        <item>508,PM</item>
        <item>249,SD</item>
        <item>597,SR</item>
        <item>268,SZ</item>
        <item>46,SE</item>
        <item>41,CH</item>
        <item>963,SY</item>
        <item>886,TW</item>
        <item>992,TJ</item>
        <item>255,TZ</item>
        <item>66,TH</item>
        <item>228,TG</item>
        <item>690,TK</item>
        <item>676,TO</item>
        <item>216,TN</item>
        <item>90,TR</item>
        <item>993,TM</item>
        <item>688,TV</item>
        <item>971,AE</item>
        <item>256,UG</item>
        <item>44,GB</item>
        <item>380,UA</item>
        <item>598,UY</item>
        <item>1,US</item>
        <item>998,UZ</item>
        <item>678,VU</item>
        <item>39,VA</item>
        <item>58,VE</item>
        <item>84,VN</item>
        <item>681,WF</item>
        <item>967,YE</item>
        <item>260,ZM</item>
        <item>263,ZW</item>
    </string-array>
</code>```

Then after add location change method with below code.

```<code>@Override
    public void onLocationChanged(Location location) {
        super.onLocationChanged(location);
        try {
            Geocoder gcd = new Geocoder(context, Locale.getDefault());
            List<Address> addresses = gcd.getFromLocation(location.getLatitude(),
                    location.getLongitude(), 1);

            if (addresses.size() > 0) {
                String countryName = addresses.get(0).getCountryCode();
                LogUtils.LOGE("TAG_DATA", getCountryZipCode(countryName), Const.LOG_VISIBILITY);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String getCountryZipCode(String country) {
        String CountryZipCode = "";

        String[] rl = this.getResources().getStringArray(R.array.CountryCodes);
        for (String aRl : rl) {
            String[] g = aRl.split(",");
            if (g[1].trim().equals(country)) {
                CountryZipCode = "+" + g[0];
                break;
            }
        }
        return CountryZipCode;
    }
</code>```

Body:
I have the below code to convert lat, long to human readable address. Now iam getting full details including street name. How can i get only city, state, country? I don't want anything more details.  Please help me.

Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault());
try {
   List<Address> addresses = geoCoder.getFromLocation(latitude, longitude, 1);

   String add = "";
   if (addresses.size() > 0)
   {
      for (int i=0; i<addresses.get(0).getMaxAddressLineIndex();i++)
     add += addresses.get(0).getAddressLine(i) + "\n";
   }

   showToastMessage(add);
}
catch (IOException e1) {
   e1.printStackTrace();
}

Body:
Add this list of country code in the your string file.

<string-array name="CountryCodes">
        <item>93,AF</item>
        <item>355,AL</item>
        <item>213,DZ</item>
        <item>376,AD</item>
        <item>244,AO</item>
        <item>672,AQ</item>
        <item>54,AR</item>
        <item>374,AM</item>
        <item>297,AW</item>
        <item>61,AU</item>
        <item>43,AT</item>
        <item>994,AZ</item>
        <item>973,BH</item>
        <item>880,BD</item>
        <item>375,BY</item>
        <item>32,BE</item>
        <item>501,BZ</item>
        <item>229,BJ</item>
        <item>975,BT</item>
        <item>591,BO</item>
        <item>387,BA</item>
        <item>267,BW</item>
        <item>55,BR</item>
        <item>673,BN</item>
        <item>359,BG</item>
        <item>226,BF</item>
        <item>95,MM</item>
        <item>257,BI</item>
        <item>855,KH</item>
        <item>237,CM</item>
        <item>1,CA</item>
        <item>238,CV</item>
        <item>236,CF</item>
        <item>235,TD</item>
        <item>56,CL</item>
        <item>86,CN</item>
        <item>61,CX</item>
        <item>61,CC</item>
        <item>57,CO</item>
        <item>269,KM</item>
        <item>242,CG</item>
        <item>243,CD</item>
        <item>682,CK</item>
        <item>506,CR</item>
        <item>385,HR</item>
        <item>53,CU</item>
        <item>357,CY</item>
        <item>420,CZ</item>
        <item>45,DK</item>
        <item>253,DJ</item>
        <item>670,TL</item>
        <item>593,EC</item>
        <item>20,EG</item>
        <item>503,SV</item>
        <item>240,GQ</item>
        <item>291,ER</item>
        <item>372,EE</item>
        <item>251,ET</item>
        <item>500,FK</item>
        <item>298,FO</item>
        <item>679,FJ</item>
        <item>358,FI</item>
        <item>33,FR</item>
        <item>689,PF</item>
        <item>241,GA</item>
        <item>220,GM</item>
        <item>995,GE</item>
        <item>49,DE</item>
        <item>233,GH</item>
        <item>350,GI</item>
        <item>30,GR</item>
        <item>299,GL</item>
        <item>502,GT</item>
        <item>224,GN</item>
        <item>245,GW</item>
        <item>592,GY</item>
        <item>509,HT</item>
        <item>504,HN</item>
        <item>852,HK</item>
        <item>36,HU</item>
        <item>91,IN</item>
        <item>62,ID</item>
        <item>98,IR</item>
        <item>964,IQ</item>
        <item>353,IE</item>
        <item>44,IM</item>
        <item>972,IL</item>
        <item>39,IT</item>
        <item>225,CI</item>
        <item>81,JP</item>
        <item>962,JO</item>
        <item>7,KZ</item>
        <item>254,KE</item>
        <item>686,KI</item>
        <item>965,KW</item>
        <item>996,KG</item>
        <item>856,LA</item>
        <item>371,LV</item>
        <item>961,LB</item>
        <item>266,LS</item>
        <item>231,LR</item>
        <item>218,LY</item>
        <item>423,LI</item>
        <item>370,LT</item>
        <item>352,LU</item>
        <item>853,MO</item>
        <item>389,MK</item>
        <item>261,MG</item>
        <item>265,MW</item>
        <item>60,MY</item>
        <item>960,MV</item>
        <item>223,ML</item>
        <item>356,MT</item>
        <item>692,MH</item>
        <item>222,MR</item>
        <item>230,MU</item>
        <item>262,YT</item>
        <item>52,MX</item>
        <item>691,FM</item>
        <item>373,MD</item>
        <item>377,MC</item>
        <item>976,MN</item>
        <item>382,ME</item>
        <item>212,MA</item>
        <item>258,MZ</item>
        <item>264,NA</item>
        <item>674,NR</item>
        <item>977,NP</item>
        <item>31,NL</item>
        <item>599,AN</item>
        <item>687,NC</item>
        <item>64,NZ</item>
        <item>505,NI</item>
        <item>227,NE</item>
        <item>234,NG</item>
        <item>683,NU</item>
        <item>850,KP</item>
        <item>47,NO</item>
        <item>968,OM</item>
        <item>92,PK</item>
        <item>680,PW</item>
        <item>507,PA</item>
        <item>675,PG</item>
        <item>595,PY</item>
        <item>51,PE</item>
        <item>63,PH</item>
        <item>870,PN</item>
        <item>48,PL</item>
        <item>351,PT</item>
        <item>1,PR</item>
        <item>974,QA</item>
        <item>40,RO</item>
        <item>7,RU</item>
        <item>250,RW</item>
        <item>590,BL</item>
        <item>685,WS</item>
        <item>378,SM</item>
        <item>239,ST</item>
        <item>966,SA</item>
        <item>221,SN</item>
        <item>381,RS</item>
        <item>248,SC</item>
        <item>232,SL</item>
        <item>65,SG</item>
        <item>421,SK</item>
        <item>386,SI</item>
        <item>677,SB</item>
        <item>252,SO</item>
        <item>27,ZA</item>
        <item>82,KR</item>
        <item>34,ES</item>
        <item>94,LK</item>
        <item>290,SH</item>
        <item>508,PM</item>
        <item>249,SD</item>
        <item>597,SR</item>
        <item>268,SZ</item>
        <item>46,SE</item>
        <item>41,CH</item>
        <item>963,SY</item>
        <item>886,TW</item>
        <item>992,TJ</item>
        <item>255,TZ</item>
        <item>66,TH</item>
        <item>228,TG</item>
        <item>690,TK</item>
        <item>676,TO</item>
        <item>216,TN</item>
        <item>90,TR</item>
        <item>993,TM</item>
        <item>688,TV</item>
        <item>971,AE</item>
        <item>256,UG</item>
        <item>44,GB</item>
        <item>380,UA</item>
        <item>598,UY</item>
        <item>1,US</item>
        <item>998,UZ</item>
        <item>678,VU</item>
        <item>39,VA</item>
        <item>58,VE</item>
        <item>84,VN</item>
        <item>681,WF</item>
        <item>967,YE</item>
        <item>260,ZM</item>
        <item>263,ZW</item>
    </string-array>

Then after add location change method with below code.

@Override
    public void onLocationChanged(Location location) {
        super.onLocationChanged(location);
        try {
            Geocoder gcd = new Geocoder(context, Locale.getDefault());
            List<Address> addresses = gcd.getFromLocation(location.getLatitude(),
                    location.getLongitude(), 1);

            if (addresses.size() > 0) {
                String countryName = addresses.get(0).getCountryCode();
                LogUtils.LOGE("TAG_DATA", getCountryZipCode(countryName), Const.LOG_VISIBILITY);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String getCountryZipCode(String country) {
        String CountryZipCode = "";

        String[] rl = this.getResources().getStringArray(R.array.CountryCodes);
        for (String aRl : rl) {
            String[] g = aRl.split(",");
            if (g[1].trim().equals(country)) {
                CountryZipCode = "+" + g[0];
                break;
            }
        }
        return CountryZipCode;
    }


问:
spring data jpa repository inject fails using @Autowired in spring boot
spring boot entry class

```<code>package com.test;

@SpringBootApplication(exclude={
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class})
public class AssetManagementDigital2Application {

    public static void main(String[] args) {
        SpringApplication.run(AssetManagementDigital2Application.class, args);
    }
}
</code>```

Controller class

```<code>package com.test.assetmanagementdigital.controller;

 @RestController

public class ShopController {

    @Autowired
    private ShopServiceImpl shopServiceImpl;

    @RequestMapping(value="/shops",method=RequestMethod.POST)
    public void shopDetails(Shop shop){
        shopServiceImpl.addShopDetails(shop);

    }

}
</code>```

Entity

```<code>package com.test.assetmanagementdigital.model;

import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name="ShopDetails")
public class Shop {

    private String shopName;
    private Address address;

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

}
</code>```

data jpa repository interface

```<code>package com.test.assetmanagementdigital.repository;
    @Repository
    public interface ShopRepository extends CrudRepository<Shop,Long>{

    }
</code>```

Service class

```<code>package com.test.assetmanagementdigital.service;
@Service
public class ShopServiceImpl {

    @Autowired
    private ShopRepository shopRepository;

    public void addShopDetails(Shop shop) {
        shopRepository.save(shop);
    }

}
</code>```

gradle file

```<code> buildscript {
        ext {
            springBootVersion = '2.0.0.BUILD-SNAPSHOT'
        }
        repositories {
            mavenCentral()
            maven { url "https://repo.spring.io/snapshot" }
            maven { url "https://repo.spring.io/milestone" }
        }
        dependencies {
            classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        }
    }

    apply plugin: 'java'
    apply plugin: 'eclipse-wtp'
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'
    apply plugin: 'war'

    version = '0.0.1-SNAPSHOT'
    sourceCompatibility = 1.8

    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }

    configurations {
        providedRuntime
    }

    dependencies {
        compile('org.springframework.boot:spring-boot-starter-data-jpa')
        compile('org.springframework.boot:spring-boot-starter-web')
        compile("com.h2database:h2")
        compile group: 'org.hibernate', name: 'hibernate-core', version: '4.2.2.Final'
        providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
        testCompile('org.springframework.boot:spring-boot-starter-test')
    }
</code>```

I am getting following error

```<code>Description:

Field shopRepository in com.test.assetmanagementdigital.service.ShopServiceImpl required a bean of type 'com.test.assetmanagementdigital.repository.ShopRepository' that could not be found.

Action:

Consider defining a bean of type 'com.test.assetmanagementdigital.repository.ShopRepository' in your configuration.
</code>```

if i remove the @Autowired annotation from ShopRepository then it will throw `NullPointerException

I have tried @EnableJpaRepositories("com.test.assetmanagementdigital.repository") here I get

```<code>org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'shopController': Unsatisfied dependency expressed through field 'shopServiceImpl'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'shopServiceImpl': Unsatisfied dependency expressed through field 'shopRepository'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shopRepository': Post-processing of merged bean definition failed; nested exception is
java.lang.NoSuchMethodError: javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType;
</code>```

答:
Your Spring configuration is not correct.

The spring-boot-starter-data-jpa already provides the hibernate-core dependency. While you declare it with a specific version :

```<code>compile group: 'org.hibernate', name: 'hibernate-core', version: '4.2.2.Final'
</code>```

You have not to declare it a second time as your specified version may be different and not compatible with the version provided by the starter.

And according to your error, it seems be the case as the javax.persistence.PersistenceContext.synchronization() method is not found at runtime.

Post-processing of merged bean definition failed; nested exception is
  java.lang.NoSuchMethodError:
  javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType;

Just remove the hibernate-core dependency and it should work.

Body:
spring boot entry class

package com.test;

@SpringBootApplication(exclude={
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class})
public class AssetManagementDigital2Application {

    public static void main(String[] args) {
        SpringApplication.run(AssetManagementDigital2Application.class, args);
    }
}

Controller class

package com.test.assetmanagementdigital.controller;

 @RestController

public class ShopController {

    @Autowired
    private ShopServiceImpl shopServiceImpl;

    @RequestMapping(value="/shops",method=RequestMethod.POST)
    public void shopDetails(Shop shop){
        shopServiceImpl.addShopDetails(shop);

    }

}

Entity

package com.test.assetmanagementdigital.model;

import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name="ShopDetails")
public class Shop {

    private String shopName;
    private Address address;

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

}

data jpa repository interface

package com.test.assetmanagementdigital.repository;
    @Repository
    public interface ShopRepository extends CrudRepository<Shop,Long>{

    }

Service class

package com.test.assetmanagementdigital.service;
@Service
public class ShopServiceImpl {

    @Autowired
    private ShopRepository shopRepository;

    public void addShopDetails(Shop shop) {
        shopRepository.save(shop);
    }

}

gradle file

 buildscript {
        ext {
            springBootVersion = '2.0.0.BUILD-SNAPSHOT'
        }
        repositories {
            mavenCentral()
            maven { url "https://repo.spring.io/snapshot" }
            maven { url "https://repo.spring.io/milestone" }
        }
        dependencies {
            classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        }
    }

    apply plugin: 'java'
    apply plugin: 'eclipse-wtp'
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'
    apply plugin: 'war'

    version = '0.0.1-SNAPSHOT'
    sourceCompatibility = 1.8

    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }

    configurations {
        providedRuntime
    }

    dependencies {
        compile('org.springframework.boot:spring-boot-starter-data-jpa')
        compile('org.springframework.boot:spring-boot-starter-web')
        compile("com.h2database:h2")
        compile group: 'org.hibernate', name: 'hibernate-core', version: '4.2.2.Final'
        providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
        testCompile('org.springframework.boot:spring-boot-starter-test')
    }

I am getting following error

Description:

Field shopRepository in com.test.assetmanagementdigital.service.ShopServiceImpl required a bean of type 'com.test.assetmanagementdigital.repository.ShopRepository' that could not be found.

Action:

Consider defining a bean of type 'com.test.assetmanagementdigital.repository.ShopRepository' in your configuration.

if i remove the @Autowired annotation from ShopRepository then it will throw `NullPointerException

I have tried @EnableJpaRepositories("com.test.assetmanagementdigital.repository") here I get

org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'shopController': Unsatisfied dependency expressed through field 'shopServiceImpl'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'shopServiceImpl': Unsatisfied dependency expressed through field 'shopRepository'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shopRepository': Post-processing of merged bean definition failed; nested exception is
java.lang.NoSuchMethodError: javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType;

Body:
Your Spring configuration is not correct.

The spring-boot-starter-data-jpa already provides the hibernate-core dependency. While you declare it with a specific version :

compile group: 'org.hibernate', name: 'hibernate-core', version: '4.2.2.Final'

You have not to declare it a second time as your specified version may be different and not compatible with the version provided by the starter.

And according to your error, it seems be the case as the javax.persistence.PersistenceContext.synchronization() method is not found at runtime.

Post-processing of merged bean definition failed; nested exception is
  java.lang.NoSuchMethodError:
  javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType;

Just remove the hibernate-core dependency and it should work.


问:
sort an array with another array which has sorted keys
How to sort an 1st array with 2nd array which has sorted keys in 2nd array without using any loop.

1st Array.

```<code>$chunk = array(
                [0] => Array
                    (
                        [id] => 212
                        [order] => 1
                        [title] => fdfdfdfdf
                    )

                [1] => Array
                    (
                        [id] => 5
                        [order] => 2
                        [title] =>
                    )

                [2] => Array
                    (
                        [id] => 781
                        [order] => 3
                        [title] =>
                    )
            )
</code>```

2nd array with sorted keys of 1st array.

```<code>$sort = array
    (
        [2] => 2
        [0] => 0
        [1] => 1
    )
</code>```

答:
Of course, there is no function for this. You'll have to do something similar

```<code><?php
$chunk  = [
    // data
];
$sorted = [];
$sort   = [
    // ordered keys
];

foreach($sort as $keyToFind) {
    foreach($chunk as $arrayElement) {
        if($arrayElement['id'] == $keyToFind)) {
            $sorted[$keyToFind] = $arrayElement;
        }
    }
}
</code>```

As you can see, this is a bit time and ressources consumming because of the two imbricated foreaches. Let's hope your arrays are not so big

Body:
How to sort an 1st array with 2nd array which has sorted keys in 2nd array without using any loop.

1st Array.

$chunk = array(
                [0] => Array
                    (
                        [id] => 212
                        [order] => 1
                        [title] => fdfdfdfdf
                    )

                [1] => Array
                    (
                        [id] => 5
                        [order] => 2
                        [title] =>
                    )

                [2] => Array
                    (
                        [id] => 781
                        [order] => 3
                        [title] =>
                    )
            )

2nd array with sorted keys of 1st array.

$sort = array
    (
        [2] => 2
        [0] => 0
        [1] => 1
    )

Body:
Of course, there is no function for this. You'll have to do something similar

<?php
$chunk  = [
    // data
];
$sorted = [];
$sort   = [
    // ordered keys
];

foreach($sort as $keyToFind) {
    foreach($chunk as $arrayElement) {
        if($arrayElement['id'] == $keyToFind)) {
            $sorted[$keyToFind] = $arrayElement;
        }
    }
}

As you can see, this is a bit time and ressources consumming because of the two imbricated foreaches. Let's hope your arrays are not so big


问:
Ionic views are different in browser and simulator
I designed an app, but there's a difference in the placement of the search box below the sub-header when run on both browser and emulator. Any idea on why is this happening ?

HTML Template

<ion-header-bar style="color: black; border-bottom: 2px solid #ed1b24 "class="bar bar-light bar-subheader">

     Home

      <button style="color: #ed1b24;" class="button button-icon icon ion-ios-shuffle-strong" ng-click="isClick=!isClick"></button>

   </ion-header-bar>

            <input type="text" placeholder="Search" ng-model="search">

<ion-content class="ion-content-below-my-video has-footer">.....
```

<p>CSS</p>

<pre class="lang-css prettyprint-override"><code>.fixed-header{
      margin-top: 88px;
  /* @in height,
   put your content below the header bar.
  */
}

.my-video
{
    width: 100%;
    position: absolute;
    background: #ed1b24;
    color: red;
    text-align: center;
    padding: 5px;
}

.ion-content-below-my-video{
      margin-top: 40px!important;
}
</code>```

答:
It looks like a CSS discrepancy between the iOS webview and your browser.

You shouldn't use custom input field for the search, it's strongly recommended to use the existing <ion-searchbar> element.

Also make sure you are not running a very old iOS version in your emulator. Consider bundling WKWebview into your app if you haven't already. iOS applications, especially on older devices benefit  greatly from that, although it increases your cordova build bundle size significantly.

Body:
I designed an app, but there's a difference in the placement of the search box below the sub-header when run on both browser and emulator. Any idea on why is this happening ?

HTML Template

<ion-header-bar style="color: black; border-bottom: 2px solid #ed1b24 "class="bar bar-light bar-subheader">

     Home

      <button style="color: #ed1b24;" class="button button-icon icon ion-ios-shuffle-strong" ng-click="isClick=!isClick"></button>

   </ion-header-bar>

            <input type="text" placeholder="Search" ng-model="search">

<ion-content class="ion-content-below-my-video has-footer">.....

CSS

.fixed-header{
      margin-top: 88px;
  /* @in height,
   put your content below the header bar.
  */
}

.my-video
{
    width: 100%;
    position: absolute;
    background: #ed1b24;
    color: red;
    text-align: center;
    padding: 5px;
}

.ion-content-below-my-video{
      margin-top: 40px!important;
}


问:
Stationary Test issue
I am working with air miles data set and i conducted three different tests to check for stationary in the time series data set

Test 1: Using acf and pacf

```<code>acf(airmiles)
</code>```

```<code>pacf(airmiles)
</code>```

After differentiating its seems most of the values lies in significance level now

```<code>acf(diff(airmiles))
pacf(diff(airmiles))
</code>```

Test 2: Using adf.test

```<code>adf.test(airmiles,k=0,alternative = "stationary")

    Augmented Dickey-Fuller Test

data:  airmiles
Dickey-Fuller = -1.1415, Lag order = 0, p-value = 0.8994
alternative hypothesis: stationary
</code>```

p-value seems to be greater than 0.05 so i differentiate and then conduct same test

```<code>adf.test(diff(airmiles),k=0,alternative = "stationary")

    Augmented Dickey-Fuller Test

data:  diff(airmiles)
Dickey-Fuller = -5.4406, Lag order = 0, p-value = 0.01
alternative hypothesis: stationary
</code>```

and so value is less now but in case of kpss.test

```<code>kpss.test(diff(airmiles))   KPSS Test for Level Stationarity

data:  diff(airmiles) KPSS Level = 0.83442, Truncation lag parameter = 1, p-value = 0.01
</code>```

The p-value is already less than 0.05 and i am concerned about which tests should i actually work with and which one leads to a better model at the end.

答: A differencing model with an AR1 and 2 outliers dealing with period 10 and 22 would be a good model. Notice there is no constant.

Title: Stationary Test issue

Body:
I am working with air miles data set and i conducted three different tests to check for stationary in the time series data set

Test 1: Using acf and pacf

acf(airmiles)

pacf(airmiles)

After differentiating its seems most of the values lies in significance level now

acf(diff(airmiles))
pacf(diff(airmiles))

Test 2: Using adf.test

adf.test(airmiles,k=0,alternative = "stationary")

    Augmented Dickey-Fuller Test

data:  airmiles
Dickey-Fuller = -1.1415, Lag order = 0, p-value = 0.8994
alternative hypothesis: stationary

p-value seems to be greater than 0.05 so i differentiate and then conduct same test

adf.test(diff(airmiles),k=0,alternative = "stationary")

    Augmented Dickey-Fuller Test

data:  diff(airmiles)
Dickey-Fuller = -5.4406, Lag order = 0, p-value = 0.01
alternative hypothesis: stationary

and so value is less now but in case of kpss.test

kpss.test(diff(airmiles))   KPSS Test for Level Stationarity

data:  diff(airmiles) KPSS Level = 0.83442, Truncation lag parameter = 1, p-value = 0.01

The p-value is already less than 0.05 and i am concerned about which tests should i actually work with and which one leads to a better model at the end.


问:
how to find date range between two dates in days format using linq c#
I have a requirement for generating report in form of 15 days,30 days,45 days.
I have to compare the list data which is coming from db with current date.example if difference is 5days. It is less than 15,so i should send to 15 days ,if >15 i should send to greater than 15etc.How to write linq query for this.can any one help on this please</p>

答:
You can use DaysBetween function in linq.It will return all dates betwee the given dates.
Example:
DateTime dt = DateTime.Today.Date.AddMonths(1);
 int d = dt.DaysBetween(DateTime.Today).ToList().Count;


问:
Conflicting collector combinations using G1 & IntelliJ 2017.1 on OSX
I'm trying to configure garbage collection with  Intellij Community Edition 2017.1. Using the following /Users/jilles/Library/Preferences/IdeaIC2017.1/idea.vmoptions

```<code># custom IntelliJ IDEA VM options

-XX:+UseG1GC
</code>```

It refuses to start with this. The above file only has 1 option that should turn on the G1. I simply removed options until I found which one was causing the issues. After some digging, I managed to at least get it to tell me why on the command line (this stuff never ends up in the log):

```<code>~/Library/Preferences/IdeaIC2017.1 $ /Applications/IntelliJ\ IDEA\ CE.app/Contents/MacOS/idea
2017-04-14 13:41:52.697 idea[54761:1579154] allVms required 1.8*,1.8+
2017-04-14 13:41:52.701 idea[54761:1579163] fullFileName is: /Applications/IntelliJ IDEA CE.app/Contents/bin/idea.vmoptions
2017-04-14 13:41:52.701 idea[54761:1579163] fullFileName exists: /Applications/IntelliJ IDEA CE.app/Contents/bin/idea.vmoptions
2017-04-14 13:41:52.701 idea[54761:1579163] Value of IDEA_VM_OPTIONS is (null)
2017-04-14 13:41:52.701 idea[54761:1579163] Processing VMOptions file at /Users/jilles/Library/Preferences/IdeaIC2017.1/idea.vmoptions
2017-04-14 13:41:52.702 idea[54761:1579163] Done
Conflicting collector combinations in option list; please refer to the release notes for the combinations allowed
2017-04-14 13:41:52.710 idea[54761:1579163] JNI_CreateJavaVM (/Applications/IntelliJ IDEA CE.app/Contents/jdk) failed: 4294967295
</code>```

The release notes seem to actually consist of a list of issues that were fixed, none of which seem to be about garbage collection.

Is the G1 garbage collector not supported in intellij? What are those conflicting settings and where are they configured or why is this not allowed? What are the current, up to date, recommendations for GC config for intellij? I'm sorry to ask since this seems a hotly debated topic in the context of intellij but pretty much all of the stuff I found related to this is for ancient versions of java + intellij. Google seems to happily suggest articles dating back to 2006 on this, which is less than helpful.

/Applications/IntelliJ IDEA CE.app/Contents/bin/idea.vmoptions does not configure any garbage collection stuff and comes with some strangely low heap size defaults that almost certainly will need some level of tweaking:

```<code>-Xms128m
-Xmx750m
-XX:ReservedCodeCacheSize=240m
-XX:+UseCompressedOops
</code>```

答:
I haven't tried this yet, but I'd suspect (as you apparently do) that it conflicts with another GC configuration.

Have you tried to turn the other ones off to cancel out any other options that could have been added by a parent configuration, e.g. by doing something like:

```<code>-XX:-UseParallelGC
-XX:-UseConcMarkSweepGC
-XX:+UseG1GC
</code>```

Update:

Apparently another answer to another similar question used the same approach. See this answer to Intellij Idea15 CE fails to launch with -XX:+UseG1GC.

See also this very helpful page, which lists the solution as well (although without stating why, I had not even noticed the '-' sign at first): https://github.com/FoxxMD/intellij-jvm-options-explained

Body:
I'm trying to configure garbage collection with  Intellij Community Edition 2017.1. Using the following /Users/jilles/Library/Preferences/IdeaIC2017.1/idea.vmoptions

# custom IntelliJ IDEA VM options

-XX:+UseG1GC

It refuses to start with this. The above file only has 1 option that should turn on the G1. I simply removed options until I found which one was causing the issues. After some digging, I managed to at least get it to tell me why on the command line (this stuff never ends up in the log):

~/Library/Preferences/IdeaIC2017.1 $ /Applications/IntelliJ\ IDEA\ CE.app/Contents/MacOS/idea
2017-04-14 13:41:52.697 idea[54761:1579154] allVms required 1.8*,1.8+
2017-04-14 13:41:52.701 idea[54761:1579163] fullFileName is: /Applications/IntelliJ IDEA CE.app/Contents/bin/idea.vmoptions
2017-04-14 13:41:52.701 idea[54761:1579163] fullFileName exists: /Applications/IntelliJ IDEA CE.app/Contents/bin/idea.vmoptions
2017-04-14 13:41:52.701 idea[54761:1579163] Value of IDEA_VM_OPTIONS is (null)
2017-04-14 13:41:52.701 idea[54761:1579163] Processing VMOptions file at /Users/jilles/Library/Preferences/IdeaIC2017.1/idea.vmoptions
2017-04-14 13:41:52.702 idea[54761:1579163] Done
Conflicting collector combinations in option list; please refer to the release notes for the combinations allowed
2017-04-14 13:41:52.710 idea[54761:1579163] JNI_CreateJavaVM (/Applications/IntelliJ IDEA CE.app/Contents/jdk) failed: 4294967295

The release notes seem to actually consist of a list of issues that were fixed, none of which seem to be about garbage collection.

Is the G1 garbage collector not supported in intellij? What are those conflicting settings and where are they configured or why is this not allowed? What are the current, up to date, recommendations for GC config for intellij? I'm sorry to ask since this seems a hotly debated topic in the context of intellij but pretty much all of the stuff I found related to this is for ancient versions of java + intellij. Google seems to happily suggest articles dating back to 2006 on this, which is less than helpful.

/Applications/IntelliJ IDEA CE.app/Contents/bin/idea.vmoptions does not configure any garbage collection stuff and comes with some strangely low heap size defaults that almost certainly will need some level of tweaking:

-Xms128m
-Xmx750m
-XX:ReservedCodeCacheSize=240m
-XX:+UseCompressedOops

Body:
I haven't tried this yet, but I'd suspect (as you apparently do) that it conflicts with another GC configuration.

Have you tried to turn the other ones off to cancel out any other options that could have been added by a parent configuration, e.g. by doing something like:

-XX:-UseParallelGC
-XX:-UseConcMarkSweepGC
-XX:+UseG1GC

Update:

Apparently another answer to another similar question used the same approach. See this answer to Intellij Idea15 CE fails to launch with -XX:+UseG1GC.

See also this very helpful page, which lists the solution as well (although without stating why, I had not even noticed the '-' sign at first): https://github.com/FoxxMD/intellij-jvm-options-explained


问:
Is generating components in render efficient?
In a simple component I have an array of child components. In the parent's state (among other things), I hold an array of objects and in the render function I construct the child components as:

```<code>const children = [];
let i = 1;
for(let child of this.state.children){
    children.push(<Decoration key={i++} {...child} />);
}
return (
    <div>{children} {this.state.something_else}</div>
);
</code>```

The problem is that whenever I change some other state values, the render function of the child component gets called which is strange since I don't change anything in the children array. Any ideas? Is this code inefficient?

答:
By default React re-render all components and sub components every time setState is called.

There is a method boolean shouldComponentUpdate(object nextProps, object nextState), each component has this method and its responsible to determine "should component update (run render function)?" every time you change state or pass new props from parent component.

You can write your own implementation of shouldComponentUpdate method for your component, but default implementation always returns true - meaning always re-run render function.

By default, shouldComponentUpdate always returns true to prevent
  subtle bugs when state is mutated in place, but if you are careful to
  always treat state as immutable and to read only from props and state
  in render() then you can override shouldComponentUpdate with an
  implementation that compares the old props and state to their
  replacements.
   http://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate

Body:
In a simple component I have an array of child components. In the parent's state (among other things), I hold an array of objects and in the render function I construct the child components as:

const children = [];
let i = 1;
for(let child of this.state.children){
    children.push(<Decoration key={i++} {...child} />);
}
return (

{children} {this.state.something_else}

);

The problem is that whenever I change some other state values, the render function of the child component gets called which is strange since I don't change anything in the children array. Any ideas? Is this code inefficient?


问:
How to style a file upload?
In firefox it looks like a text field that you click on and i just need a button like safari renders..Is there a way to not display the text field looking file upload in firefox</p>

答:
Asked many times before:

How can I style a file input field in Firefox?

Styling an input type="file" button

How to style "input file" with CSS3 / Javascript?

https://stackoverflow.com/questions/3984815/jquery-best-way-to-style-a-input-file-tag

Can we change <input type="file"> style?

Style of input=File as a button

Title: How to style a file upload?

ContentLicense: CC BY-SA 2.5


问:
How to timeout an fs.read in node.js?
I try to read from a filedescriptor with fs.read. The callback-function is called
after it got the data. It's working fine.

But now I want to implement a timeout mechanism: If the fs.read does not get data within the timeout it should stop reading.

How can I tell fs.read to stop reading? It is still hanging in the background trying to read.

I do roughly the following:

```<code>...
var fd = fs.openSync("/dev/ttyUSB0", 'rs+');
...
...
var bout = new Buffer(string,'binary');
fs.write(fd, bout, 0, bout.length,undefined,function(err, written, buffer) {
  console.log("error writing: "+err);

  var bin = new Buffer(1);
  fs.read(fd,bin,0,1,undefined,function(err,read,buffer) {
    console.log("got it: "+bin);
  });
});
...
...
</code>```

I want to write something to /dev/ttyUSB0 and read an answer, but sometimes there is no answer. If this happens, the read should timeout so that I can start another write/read.

Thanks

I tried to do it with Timeout and close, but it is not working, here is an example:
You have to make "mkfifo file" for the test.

```<code>var fs=require('fs');

console.log("open file");

fs.open('file', 'r+', function(err,fd) {

  console.log("start reading on "+fd);

  var length=5;

  var data = new Buffer(length);
  data.fill("-");

  setTimeout(function(){
    console.log("timeout");
    console.log("close fd "+fd);
    fs.close(fd,function(err) {
      console.log("close done: "+err);
    });
  }, 5000);

  fs.read(fd, data, 0, length,undefined, function(error, got) {
    console.log("error: "+error);
    console.log("got callback: "+data);
  });

  console.log("done");
});
</code>```

The fs.close does not work. After it has closed you can make a "echo test > file" and then the read get the data. Reading on a closed Filehandle?

Any Idea?

答:
For functions that do not provide a native timeout capability (like fs.stat, fs.read, etc..) you can wrap the callback using something like callback-timeout module.

You can do

```<code>const timeout = require('callback-timeout');
const fs = require('fs');

fs.stat('/mnt/never-returns', timeout((err, stats)=>{
   if(err) throw err;
   //happy with stats
}, 2000, 'fs.stat did not return in 2 secs'));
</code>```

Title: How to timeout an fs.read in node.js?

Body:
I try to read from a filedescriptor with fs.read. The callback-function is called
after it got the data. It's working fine.

But now I want to implement a timeout mechanism: If the fs.read does not get data within the timeout it should stop reading.

How can I tell fs.read to stop reading? It is still hanging in the background trying to read.

I do roughly the following:

...
var fd = fs.openSync("/dev/ttyUSB0", 'rs+');
...
...
var bout = new Buffer(string,'binary');
fs.write(fd, bout, 0, bout.length,undefined,function(err, written, buffer) {
  console.log("error writing: "+err);

  var bin = new Buffer(1);
  fs.read(fd,bin,0,1,undefined,function(err,read,buffer) {
    console.log("got it: "+bin);
  });
});
...
...

I want to write something to /dev/ttyUSB0 and read an answer, but sometimes there is no answer. If this happens, the read should timeout so that I can start another write/read.

Thanks

I tried to do it with Timeout and close, but it is not working, here is an example:
You have to make "mkfifo file" for the test.

var fs=require('fs');

console.log("open file");

fs.open('file', 'r+', function(err,fd) {

  console.log("start reading on "+fd);

  var length=5;

  var data = new Buffer(length);
  data.fill("-");

  setTimeout(function(){
    console.log("timeout");
    console.log("close fd "+fd);
    fs.close(fd,function(err) {
      console.log("close done: "+err);
    });
  }, 5000);

  fs.read(fd, data, 0, length,undefined, function(error, got) {
    console.log("error: "+error);
    console.log("got callback: "+data);
  });

  console.log("done");
});

The fs.close does not work. After it has closed you can make a "echo test > file" and then the read get the data. Reading on a closed Filehandle?

Any Idea?

Body:
For functions that do not provide a native timeout capability (like fs.stat, fs.read, etc..) you can wrap the callback using something like callback-timeout module.

You can do

const timeout = require('callback-timeout');
const fs = require('fs');

fs.stat('/mnt/never-returns', timeout((err, stats)=>{
   if(err) throw err;
   //happy with stats
}, 2000, 'fs.stat did not return in 2 secs'));


问:
Array Comparision
I have a array with 8 columns and 42 rows B2 TO I43. I have to compare this array with other arrays in the same sheet so that every array have same values. I defined array1 Rang('B2;I43") and need to compare every other array of same size. how to that in VBA.
My code is

```<code>Sub driver()
Dim array1, array2, m, n
Set array1 = Range("B2,I43")
total_rows = 42
total_cols = 8
Set array2 = Range("B44:I85")

For i = 1 To total_rows
For j = 1 To total_cols
    If array1(i, j) = array2(i, j) Then
    array2.Cells(i, j).Interior.ColorIndex = 0
    ElseIf array1(i, j) <> array2(i, j) Then
    array2.Cells(i, j).Interior.ColorIndex = 3
    End If
    Next j
    Next i
End Sub
</code>```

I want array2 to point to other set of values. Every array start after 42 rows.

答:
Your main task is to define the ranges accurately. In the code below I've assumed it's every 42 rows until end of data. You simply iterate your 42-row test arrays and compare against the reference array. To do this you basically need two row variables: one for your test array and one for your reference array.

The quickest way would be to read the test data just once into one big array and to create two ranges (one with matches and one with mis-matches) and then colour them at the end of the routine.

I don't know your colour palette (and therefore the color indexes) so I've used the .Color property. You can adjust this to suit.

```<code>Const ROW_COUNT As Long = 42
Const COL_COUNT As Long = 8
Const START_ROW As Long = 2
Dim refArray As Variant, testArray As Variant
Dim rowSize As Long, r As Long, c As Long, i As Long
Dim cell As Range, yesRng As Range, noRng As Range

'Read data into arrays
With Sheet1
    'Find last row of data
    rowSize = .Cells(.Rows.Count, "B").End(xlUp).Row
    'Adjust last row to be multiple of 42
    rowSize = Int((rowSize - START_ROW) / ROW_COUNT) * ROW_COUNT

    refArray = .Cells(START_ROW, "B").Resize(ROW_COUNT, COL_COUNT).Value2
    testArray = .Cells(START_ROW + ROW_COUNT, "B").Resize(rowSize, COL_COUNT).Value2
End With

'Compare test array with reference array
i = 1 'refArray row index
For r = 1 To UBound(testArray, 1)
    For c = 1 To UBound(testArray, 2)
        Set cell = Sheet1.Cells(r + START_ROW + ROW_COUNT - 1, c + 1)
        If testArray(r, c) = refArray(i, c) Then
            'It's a match so add to yes range
            If yesRng Is Nothing Then
                Set yesRng = cell
            Else
                Set yesRng = Union(yesRng, cell)
            End If
        Else
            'It's a miss so add to no range
            If noRng Is Nothing Then
                Set noRng = cell
            Else
                Set noRng = Union(noRng, cell)
            End If
        End If
    Next
    'Increment ref row index or set back to 1 if at 42
    i = IIf(i < ROW_COUNT, i + 1, 1)
Next

'Colour the ranges
If Not yesRng Is Nothing Then yesRng.Interior.Color = vbGreen
If Not noRng Is Nothing Then noRng.Interior.Color = vbRed
</code>```

Title: Array Comparision

Body:
I have a array with 8 columns and 42 rows B2 TO I43. I have to compare this array with other arrays in the same sheet so that every array have same values. I defined array1 Rang('B2;I43") and need to compare every other array of same size. how to that in VBA.
My code is

Sub driver()
Dim array1, array2, m, n
Set array1 = Range("B2,I43")
total_rows = 42
total_cols = 8
Set array2 = Range("B44:I85")

For i = 1 To total_rows
For j = 1 To total_cols
    If array1(i, j) = array2(i, j) Then
    array2.Cells(i, j).Interior.ColorIndex = 0
    ElseIf array1(i, j) <> array2(i, j) Then
    array2.Cells(i, j).Interior.ColorIndex = 3
    End If
    Next j
    Next i
End Sub

I want array2 to point to other set of values. Every array start after 42 rows.

Body:
Your main task is to define the ranges accurately. In the code below I've assumed it's every 42 rows until end of data. You simply iterate your 42-row test arrays and compare against the reference array. To do this you basically need two row variables: one for your test array and one for your reference array.

The quickest way would be to read the test data just once into one big array and to create two ranges (one with matches and one with mis-matches) and then colour them at the end of the routine.

I don't know your colour palette (and therefore the color indexes) so I've used the .Color property. You can adjust this to suit.

Const ROW_COUNT As Long = 42
Const COL_COUNT As Long = 8
Const START_ROW As Long = 2
Dim refArray As Variant, testArray As Variant
Dim rowSize As Long, r As Long, c As Long, i As Long
Dim cell As Range, yesRng As Range, noRng As Range

'Read data into arrays
With Sheet1
    'Find last row of data
    rowSize = .Cells(.Rows.Count, "B").End(xlUp).Row
    'Adjust last row to be multiple of 42
    rowSize = Int((rowSize - START_ROW) / ROW_COUNT) * ROW_COUNT

    refArray = .Cells(START_ROW, "B").Resize(ROW_COUNT, COL_COUNT).Value2
    testArray = .Cells(START_ROW + ROW_COUNT, "B").Resize(rowSize, COL_COUNT).Value2
End With

'Compare test array with reference array
i = 1 'refArray row index
For r = 1 To UBound(testArray, 1)
    For c = 1 To UBound(testArray, 2)
        Set cell = Sheet1.Cells(r + START_ROW + ROW_COUNT - 1, c + 1)
        If testArray(r, c) = refArray(i, c) Then
            'It's a match so add to yes range
            If yesRng Is Nothing Then
                Set yesRng = cell
            Else
                Set yesRng = Union(yesRng, cell)
            End If
        Else
            'It's a miss so add to no range
            If noRng Is Nothing Then
                Set noRng = cell
            Else
                Set noRng = Union(noRng, cell)
            End If
        End If
    Next
    'Increment ref row index or set back to 1 if at 42
    i = IIf(i < ROW_COUNT, i + 1, 1)
Next

'Colour the ranges
If Not yesRng Is Nothing Then yesRng.Interior.Color = vbGreen
If Not noRng Is Nothing Then noRng.Interior.Color = vbRed