0

i really don't know how to convert the example provided by apple into macruby code, since address is a char pointer, irghhh:

SCNetworkReachabilityRef target;
SCNetworkConnectionFlags flags = 0;
Boolean ok;

target = SCNetworkReachabilityCreateWithAddress(NULL, address);
ok = SCNetworkReachabilityGetFlags(target, &flags);

CFRelease(target);

here is an example implementation in Objective-C:

Determining Internet Availability on iPhone?

UPDATE:

i just realized, that i can do it very quickly with macruby itself, but i am stil interested in how you would do this with macruby.

def network_available?
  Socket.getaddrinfo('example.com', nil)
rescue
  false
end
0

1 Answer 1

2

You should simply get the pointer of your MacRuby NSString instance:

address = "example.com".pointer
...
target = SCNetworkReachabilityCreateWithAddress(NULL, address)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.