KO
|
EN
gitlite — search
Search
#javascript
#python
#hacktoberfest
#react
#ai
#typescript
#llm
#go
#golang
#android
#machine-learning
#rust
#deep-learning
#linux
MUBlockDelegate
★ 10
Open GitHub ↗
No description available.
Download README (.md)
Explore Similar Repositories
arcanist-installer
:
No description available.
tomcat7-munin-plugins
:
plugins to monitor tomcat7 with munin
ProcessGoogleAnalytics
:
Processwire Google Analytics Page
request-caching
:
An HTTP client with caching, built on top of request.
andamio
:
A set of mini CSS design patterns
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
MUBlockDelegate
?
Download (.md)
MUBlockDelegate ============ 1.normally, we use delegates as follows: firstly, @protocol TestProtcol <NSObject> - (NSString*) testDelegateMethod:(NSString*) aString; @end @interface TestDelegateImpl : NSObject<TestProtcol> @end and: @implementation TestDelegateImpl - (NSString*) testDelegateMethod:(NSString *)aString { return aString; } @end secondly, #import "TestProtcol.h" @interface TestObject : NSObject @property(nonatomic, weak) id<TestProtcol> delegate; - (NSString*) callDelegate:(NSString*) aString; @end @implementation TestObject @synthesize delegate = _delegate; - (NSString*) callDelegate:(NSString*) aString { if ([_delegate respondsToSelector:@selector(testDelegateMethod:)]) { return [_delegate testDelegateMethod:aString]; } return nil; } @end at last, we do some tests: TestDelegateImpl* testDelegate = [[TestDelegateImpl alloc] init]; TestObject* testObject = [[TestObject alloc] init]; testObject.delegate = testDelegate; NSLog(@"result:%@", [testObject callDelegate:@"testNormal"]); 2.if you use MUBlockDelegate: firstly, MUBlockDelegate* testDelegate = [MUBlockDelegate delegateForSelectorString:@"(@)testDelegateMethod(@)" delegateBlock:^(NSInvocation *anInvocation, NSArray *params) { NSString* testString = [params objectAtIndex:0]; [anInvocation setReturnValue:&testString]; }]; then, do some tests, TestObject* testObject = [[TestObject alloc] init]; testObject.delegate = (id<TestProtcol>)testDelegate; NSString* testResult = [testObject callDelegate:@"testBlock"]; NSLog(@"testResult:%@", testResult); that's all. the other approach: MUBlockDelegate* testDelegate = [MUBlockDelegate delegateForClass:[TestDelegateImpl class] selector:@selector(testDelegateMethod:) delegateBlock:^(NSInvocation *anInvocation, NSArray *params) { NSString* testString = [params objectAtIndex:0]; [anInvocation setReturnValue:&testString]; }]; MUBlockDelegate* testDelegate = [MUBlockDelegate delegateForProtocol:@protocol(TestProtcol) selector:@selector(testDelegateMethod:) delegateBlock:^void(NSInvocation* anInvocation, NSArray *params) { NSLog(@"params:%@", anInvocation); NSString* testString = [params objectAtIndex:0]; [anInvocation setReturnValue:&testString]; }]; do the same thing. 3.run the TESTCASE