Skip to content

Instantly share code, notes, and snippets.

extension String {
func withHighlightedText(highlightedPartsOfString: Array<NSString>, font: UIFont, newFont: UIFont) -> NSAttributedString {
let nonHighlightedFontAttribute = [NSAttributedString.Key.font:font]
let highlightedFontAttribute = [NSAttributedString.Key.font:newFont]
let newText = NSMutableAttributedString(string: self as String, attributes: nonHighlightedFontAttribute)
for i in 0 ..< highlightedPartsOfString.count {
newText.addAttributes(highlightedFontAttribute, range: (self as NSString).range(of: highlightedPartsOfString[i] as String))
}
return newText
}
function contem(array, numero) {
var result = array.indexof(numero);
if (result != -1) {
return true;
}
return false;
}
@PauloLeon
PauloLeon / gambeta.m
Created August 10, 2019 21:16
gambfeia
NSString *agency = @"1234";
NSString *account = @"1234";
int count01 = [agency length];
int count03 = [account length];
if (count01+count03 < 12) {
NSString *newStr = agency;
int countDown = 12 - (count01 + count03);
for (int i = 1; i <= countDown; i++) {
init(fromJSON json: JSON) {
// tinha que alterar esse init:
let result = json["result"]
self.id = result["id"].stringValue
self.name = result["nome"].stringValue
self.token = result["token"].stringValue
self.email = result["usuario"].stringValue
self.cpf = result["cpf"].stringValue
self.password = result["senha"].stringValue
static func signin(_ data: URLRequestParams, success: @escaping (User) -> Void, failure: @escaping (ApiError) -> Void ){
var data = URLRequestParams()
data["usuario"] = "nayanne.moritsuka+tcr6@terras.agr.br"
data["senha"] = "1234"
// da um break na linha abaixo, e ve se a variavel data ta populada
Alamofire.request(Router.login(data: data))
.validate()
.responseJSON { response in
switch response.result {
case .success:
func asURLRequest() throws -> URLRequest {
let url: URL
if path == "estimates" || path == "users"{
url = try Router.routeResults.asURL()
} else {
url = try Router.routeGoogle.asURL()
}
var urlRequest = URLRequest(url: url.appendingPathComponent(path))
urlRequest.httpMethod = method.rawValue
if hearders != ""{
// MARK: - Paths
var hearders: String {
if path == "estimates" || path == "users"{
return "103260408667b5727f0bc10dc37240b2d38579051d9924b979ea2e4fe3a31635802b3b4ff8e25d31b39066957a8c3811c9f427e0d8a4c8c0bc58916fc3ea1be6"
}
return ""
}
//
// BaseApiClient.swift
// Melhor Corrida
//
// Created by Paulo Rosa on 07/08/17.
// Copyright © 2017 Paulo Rosa. All rights reserved.
//
//swiftlint:disable empty_enum_arguments
import UIKit
import Alamofire
@PauloLeon
PauloLeon / .swiftlint.yml
Created September 18, 2017 20:54
the custom rules for swxftlint
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
- Source/ExcludedFolder
- Source/ExcludedFile.swift
# rules that have both warning and error levels, can set just the warning level
# implicitly
line_length: 250
@PauloLeon
PauloLeon / .swiftlint.yml
Created September 18, 2017 20:54
the custom rules for swxftlint
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
- Source/ExcludedFolder
- Source/ExcludedFile.swift
# rules that have both warning and error levels, can set just the warning level
# implicitly
line_length: 250