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
// 監聽 UITextField 當內文有改變的時候,會執行內部 function | |
[[self.textView rac_signalForControlEvents:UIControlEventEditingChanged] subscribeNext:^(__kindof UIControl * _Nullable x) { | |
NSLog(@"text change"); | |
}]; | |
// 監聽 button UIControlEventTouchUpInside 狀態 | |
[[self.btnButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) { | |
NSLog(@"button click"); | |
}]; |
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
// create signnal | |
RACSignal *signal = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber> _Nonnull subscriber) { | |
[subscriber sendNext:@"message"]; | |
return nil; | |
}]; | |
// subscribe notification | |
RACDisposable *disposable = [signal subscribeNext:^(id _Nullable x) { | |
NSLog(@"content:%@", x); | |
}]; |
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
// create a signal | |
RACSubject *subject = [RACSubject subject]; | |
// subscribe notification | |
[subject subscribeNext:^(id _Nullable x) { | |
NSLog(@"content 2:%@", x); | |
}]; | |
// send message | |
[subject sendNext:@"message 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
// loop all element | |
NSArray *array = @[@"1", @"2", @"3", @"4", @"5"]; | |
[array.rac_sequence.signal subscribeNext:^(id _Nullable x) { | |
NSLog(@"element:%@", x); | |
}]; | |
// output | |
// element:1 | |
// element:2 | |
// element:3 |
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
[RACObserve(objA, strContent) subscribeNext:^(id x) { | |
NSLog(@"objA : %@",x); | |
[self.labelView setText:x]; | |
}]; |
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
[[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIKeyboardDidShowNotification object:nil] subscribeNext:^(NSNotification * _Nullable x) { | |
NSLog(@"keyboard - \n%@", x); | |
}]; |
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
@interface Model:NSObject | |
@property (strong, nonatomic) NSString *content; | |
@end | |
@implementation Model | |
@end | |
@interface ViewModel:NSObject | |
@property (strong, nonatomic) NSString *content; | |
- (void) execute:(NSString *)content; |
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
// JAVA | |
// QUESTION 1 | |
static String getReverseString(String input) { | |
char[] in = input.toCharArray(); | |
char buff; | |
for (int i=0,j=input.length()-1; i<input.length()/2;i++,j--) { | |
buff = in[i]; | |
in[i] = in[j]; | |
in[j] = buff; | |
} |
OlderNewer