This file contains hidden or 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
/// This is a simple example of Neumorphism applied to buttons in SwiftUI | |
/// As seen on https://twitter.com/dev_jac/status/1228575575171723264 | |
/// This should work straight out of the box, no other files are required | |
import SwiftUI | |
extension Color { | |
static let mainColor = Color(red: 224/255, green: 229/255, blue: 236/255) | |
static let mainColorActive = Color(red: 220/255, green: 225/255, blue: 232/255) | |
static let grayShadow = Color(red: 163/255, green: 177/255, blue: 198/255) |
This file contains hidden or 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
### Keybase proof | |
I hereby claim: | |
* I am julioacarrettoni on github. | |
* I am dev_jac (https://keybase.io/dev_jac) on keybase. | |
* I have a public key whose fingerprint is AE67 C01B BCF8 5591 662B 6765 F000 C442 1C88 09CF | |
To claim this, I am signing this object: |
This file contains hidden or 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 Foundation | |
//https://twitter.com/manuelmaly/status/898141485228544000 | |
class Foo { | |
var y: Int = 8 | |
func bar() { | |
let b = { [weak self] in | |
let x = { | |
// self is nil here | |
return self?.y | |
}() |
This file contains hidden or 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
// First we need to take a look at the documentation | |
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string | |
optional public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool // return NO to not change text | |
- TextField: The text field containing the text. | |
- range: The range of characters to be replaced. | |
- string: The replacement string for the specified range. During typing, this parameter normally contains only the single new character that was typed, but it may contain more characters if the user is pasting text. When the user deletes one or more characters, the replacement string is empty. | |
//So you actualy need to combine the actual text and the new string together, not just count the character, as for example the user might be replacing a chunk of text with another using "paste" or auto correct. | |
//Obj-C | |
- (BOOL)textField:(UITextField *)textField shouldChangeCharac |
This file contains hidden or 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
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache" | |
rm -rf ~/Library/Developer/Xcode/DerivedData | |
rm -rf ~/Library/Caches/com.apple.dt.Xcode |
This file contains hidden or 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
let array = [1, 2, 3, 4, 5, 6] | |
array.map { (value) -> [Int] in | |
print(value) | |
return [value] | |
} | |
array.lazy.map { (value) -> [Int] in | |
print("value: \(value)") | |
return [value] |
This file contains hidden or 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
let mixedArray = [1, "2", 3, "4", 5, 6] | |
let resultA = mixedArray.flatMap({ $0 as? String }) | |
resultA.first | |
let resultB = mixedArray.lazy.flatMap({ $0 as? String }) | |
resultB.first |
This file contains hidden or 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
let array = [1, 2, 3, 4, 5, 6] | |
array.map { (value) -> [Int] in | |
print(value) | |
return [value] | |
} | |
array.lazy.map { (value) -> [Int] in | |
print("value: \(value)") | |
return [value+1] |
This file contains hidden or 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
// Extend UILabel with a method which sets font, to be used by UIAppearance | |
extension UILabel | |
{ | |
func setFontName(fontName:String) | |
{ | |
self.font = UIFont(name: fontName, size: self.font.pointSize) | |
} | |
} | |
// Somewhere in the code, call the extension method on the UIAppearance proxy object of UILabel, example: |
This file contains hidden or 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
https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/freeProductCodeWizard?code= |
NewerOlder