Skip to content

Instantly share code, notes, and snippets.

View ahikmatf's full-sized avatar
💭
Learning how to code

Asep Hikmat Fatahillah ahikmatf

💭
Learning how to code
View GitHub Profile
@ahikmatf
ahikmatf / localize.swift
Created February 28, 2017 03:45 — forked from Maxdw/localize.swift
genstrings for custom translation function
extension String {
func localizedWith(comment:String) -> String {
return NSLocalizedString(self, tableName: nil, bundle: Bundle.main, value: "", comment: comment)
}
}
@ahikmatf
ahikmatf / gist:e9e4840712804d4688b1a40f120c0c69
Created January 17, 2017 02:32 — forked from ttran4040/gist:74a07380af8c76d1b3d4
Check for Internet Connection (Swift)
import Foundation
import SystemConfiguration
public class Reachability {
class func isConnectedToNetwork() -> Bool {
var zeroAddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress))
zeroAddress.sin_family = sa_family_t(AF_INET)