Latest 0.1.0
Homepage https://github.com/carlSQ/ProtocolExtension
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

Introduce

protocol extension for Objective-C like Swift

protocol 参数目前只支持Object

Usage

定义protocol


@protocol PETest <NSObject>

@optional

- (id)test:(id)arg1 arg2:(id)arg2 arg3:(id)arg3;

@end

定义protocol 默认行为


@extension(PETest)

- (id)test:(id)arg1 arg2:(id)arg2 arg3:(id)arg3 {
NSLog(@"===================>%@===%@=====%@",arg1,arg2,arg3);
[self testLog];
return [NSObject new];
}

- (void)testLog {
NSLog(@"======================class: %@",self.class);
}

@end

具体使用


@interface PEProtocolTest : NSObject<PETest>

@end

@implementation PEProtocolTest

@end

...

[[PEProtocolTest new] test:@"xxxxxxxxxxxxx" arg2:@"yyyyyyyy" arg3:@"zzzzzzzzzzzz"];

结果


===================>xxxxxxxxxxxxx===yyyyyyyy=====zzzzzzzzzzzz

======================class: PEProtocolTest

Install

pod "ProtocolExtension"

Author

carl shen

License

ProtocolExtension is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ProtocolExtension",
    "version": "0.1.0",
    "summary": "protocol extension for Objective-C like Swift",
    "description": "protocol extension for Objective-C like Swiftnprotocol u53c2u6570u76eeu524du53eau652fu6301Object",
    "homepage": "https://github.com/carlSQ/ProtocolExtension",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "[email protected]": "carlSQ"
    },
    "source": {
        "git": "https://github.com/carlSQ/ProtocolExtension.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "ProtocolExtension/Classes/**/*"
}

Pin It on Pinterest

Share This