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
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://optimizerapi.ds.trustsourcing.com"]]; | |
NSMutableURLRequest *request = [httpClient requestWithMethod:@"GET" | |
path:@"/Api/RestorePassword" | |
parameters:@{@"email":@"[email protected]"}]; | |
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; | |
[httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]]; | |
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { | |
// Print the response body in text | |
NSLog(@"Response: %@", [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]); | |
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { |
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
[yourSwitchObject addTarget:self action:@selector(setState:) forControlEvents:UIControlEventValueChanged]; | |
- (void)setState:(id)sender { | |
BOOL state = [sender isOn]; | |
} |
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
1). ------------------------------------------------------------- | |
lazy var validator: Validator = { [unowned self] in | |
let validator = Validator() | |
validator.setSomething = "Foo" | |
validator.setSomethingMore = "Bar" | |
return validator | |
}() | |
2). ------------------------------------------------------------- | |
var validator: Validator { | |
let validator = Validator() |
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
/// Start | |
func drawCircles(count: Int) { | |
var cX = [CGFloat!](count: count, repeatedValue: nil) | |
var cY = [CGFloat!](count: count, repeatedValue: nil) | |
var i: Int = 0 | |
var j: Int = 0 | |
var n = count | |
var cR: CGFloat = 45 | |
var dMinQ = pow(cR * 2, 2) | |
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 iterateEnum<T: Hashable>(_: T.Type) -> AnyGenerator<T> { | |
var i = 0 | |
return AnyGenerator { | |
let next = withUnsafePointer(&i) { UnsafePointer<T>($0).memory } | |
return next.hashValue == i++ ? next : nil | |
} | |
} |
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
CATransaction.begin() | |
CATransaction.setDisableActions(true) | |
let oldBottomOffset = self.collectionView.contentSize.height - self.collectionView.contentOffset.y | |
self.collectionView.performBatchUpdates({ | |
// indexPaths for earlier messages | |
let lastIdx = history.count - 1 | |
//let lastIdx = self.messagesCountIndexes | |
var indexPaths: [AnyObject] = [] |
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
extension Collection where Iterator.Element: Comparable { | |
func lessThanFirst() -> [Iterator.Element] { | |
guard let first = self.first else { return [] } | |
return self.filter { $0 < first } | |
} | |
} | |
let items = [5, 6, 10, 4, 110, 3].lessThanFirst() | |
print(items) |
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
NSLog(@"DEBUG ------"); | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
NSLog(@"`dispatch_get_main_queue`"); | |
if (_delegate != nil) { | |
NSLog(@"`_delegate != nil`"); | |
if ([_delegate respondsToSelector:@selector(onConversionDataSuccess:)]) { | |
NSLog(@"`respondsToSelector`"); | |
[_delegate performSelector:@selector(onConversionDataSuccess:) withObject:conversionDict]; | |
NSLog(@"conversionDict: %@", conversionDict); | |
NSLog(@"FINISH -------"); |
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
SEL mySel = @selector(onConversionDataSuccess:); | |
void (*myMsgSend)(id _delegate, SEL mySel, id param1); | |
myMsgSend = (void(*)(id, SEL, id))objc_msgSend; | |
myMsgSend(_delegate, mySel, conversionDict); |
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
@echo off | |
setlocal | |
set GRADLEPATH=%~dp0 | |
set GRADLE_CMD_LINE_ARGS= | |
:setupArgs | |
if ""%1""=="""" goto doneStart | |
set GRADLE_CMD_LINE_ARGS=%GRADLE_CMD_LINE_ARGS% %1 | |
call "%GRADLEPATH%\gradlew.bat" :app:assembleRelease -Dfile.encoding=UTF-8 | |
shift | |
goto setupArgs |
OlderNewer