This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ObjectMapperRealmHelper.swift | |
// | |
// Created by Santiago Bustamante on 07/27/18. | |
// | |
// | |
import ObjectMapper | |
import RealmSwift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ObjectMapperRealmHelper.swift | |
// Pods | |
// | |
// Created by Santiago Bustamante on 10/13/16. | |
// | |
// | |
import ObjectMapper | |
import RealmSwift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infix operator <~> : AssignmentPrecedence | |
//Bidirectional bind RxSwift, swift 3 | |
public func <~> <E,C: ControlPropertyType>(property: C, variable: Variable<E>) -> Disposable where C.E == E? { | |
let bindToUIDisposable = variable.asObservable() | |
.bindTo(property) | |
let bindToVariable = property | |
.subscribe(onNext: { n in | |
if let n = n{ | |
variable.value = n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
add the content of a dictionary into another dictionary | |
swift 3 | |
*/ | |
func += <K>( dict1:inout [K:Any], dict2:[K:Any]){ | |
dict2.forEach { (key: K, value: Any) in | |
dict1[key] = value | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func formatFrom(_ value:String) -> (dateString:String?, dateFormat:String?) { | |
var regexString = "\\A(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})" // Mandatory - YYYY-MM-DDTHH:mm | |
regexString = regexString + ":?(\\d{2})?" // Optional - :ss | |
regexString = regexString + "[.]?(\\d{1,6})?" // Optional - .nnnnnn | |
regexString = regexString + "([+-])?(\\d{2})?:?(\\d{2})?|Z" // Optional -[+-]hh:mm or Z | |
regexString = regexString + "\\z" | |
let regex: NSRegularExpression? | |
var matchesResult: [NSTextCheckingResult]? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension UIView { | |
/** | |
Convert current view to image | |
:returns: return the image | |
*/ | |
public func convertToImage() -> UIImage { | |
UIGraphicsBeginImageContext(self.bounds.size); | |
self.layer.render(in: UIGraphicsGetCurrentContext()!) | |
let viewImage = UIGraphicsGetImageFromCurrentImageContext() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ObjectMapper | |
import RealmSwift | |
open class BaristaISO8601DateTransform: TransformType { | |
public typealias Object = Date | |
public typealias JSON = String | |
let dateFormatter: DateFormatter = DateFormatter() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//transform array from objectMapper parsing to Realm List | |
public class ArrayTransform<T:RealmSwift.Object where T:Mappable> : TransformType { | |
public typealias Object = List<T> | |
public typealias JSON = Array<Any> | |
public init(){ | |
} | |
public func transformFromJSON(_ value: Any?) -> List<T>? { | |
let result = List<T>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post_install do |installer| | |
installer.pods_project.targets.each do |target| | |
target.build_configurations.each do |config| | |
config.build_settings['SWIFT_VERSION'] = '3.0' | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class func getAddressFromCoords(coords:CLLocationCoordinate2D, complete:(location:Location?, error:NSError?)->()){ | |
var url = "http://maps.googleapis.com/maps/api/geocode/json" | |
var str = String(format: "%f",coords.latitude) + "," + String(format:"%f",coords.longitude) | |
var params = ["latlng":str, "sensor":true] | |
AFHTTPRequestOperationManager().GET(url, parameters: params, success: { (operation:AFHTTPRequestOperation!, response:AnyObject!) -> Void in | |
let json:JSON = JSON(response) | |
var loc = Location(dictionary: json) |
NewerOlder