To run the example project, clone the repo, and run pod install from the Example directory first.
- iOS 10.0+
- Swift 4.0+ (如果使用 Swift 项目)
FindDomainObjc is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'FindDomainObjc'#import <FindDomainObjc/FindDomainObjc.h>
// 创建配置
FindDomainConfig *config = [[FindDomainConfig alloc] init];
config.checkUrls = @[@"https://example.com/check1", @"https://example.com/check2"];
config.domainPrefix = @"PREFIX";
config.domainSuffix = @"SUFFIX";
config.domainSeparator = @"SEPARATOR";
// 配置查找器
[[FindDomainObjc shared] configureWithConfig:config];
// 查找可用域名
[[FindDomainObjc shared] findAvailableDomainWithSuccess:^(NSString *domain) {
NSLog(@"找到可用域名: %@", domain);
} failure:^{
NSLog(@"查找失败");
}];import FindDomainObjc
// 创建配置
let config = FindDomainConfig(
checkUrls: [
"https://example.com/check1",
"https://example.com/check2"
],
domainPrefix: "PREFIX",
domainSuffix: "SUFFIX",
domainSeparator: "SEPARATOR"
)
// 配置查找器
FindDomainObjc.shared().configure(with: config)
// 查找可用域名
FindDomainObjc.shared().findAvailableDomain { result in
switch result {
case .success(let domain):
print("找到可用域名: \(domain)")
case .failure(let error):
print("查找失败: \(error.localizedDescription)")
}
}import FindDomainObjc
// 创建配置
let config = FindDomainConfig(
checkUrls: [
"https://example.com/check1",
"https://example.com/check2"
],
domainPrefix: "PREFIX",
domainSuffix: "SUFFIX",
domainSeparator: "SEPARATOR"
)
// 配置查找器
FindDomainObjc.shared().configure(with: config)
// 使用 async/await
Task {
do {
let domain = try await FindDomainObjc.shared().findAvailableDomain()
print("找到可用域名: \(domain)")
} catch {
print("查找失败: \(error.localizedDescription)")
}
}import FindDomainObjc
// 创建配置
let config = FindDomainConfig()
config.checkUrls = ["https://example.com/check1", "https://example.com/check2"]
config.domainPrefix = "PREFIX"
config.domainSuffix = "SUFFIX"
config.domainSeparator = "SEPARATOR"
// 配置查找器
FindDomainObjc.shared().configure(with: config)
// 使用 Objective-C 风格的回调
FindDomainObjc.shared().findAvailableDomain(
success: { (domain: String) in
print("找到可用域名: \(domain)")
},
failure: {
print("查找失败")
}
)Computer, [email protected]
FindDomainObjc is available under the MIT license. See the LICENSE file for more info.