我希望AFNetworking
在Objective-C中使用与Swift中的Alamofire NetworkReachabilityManager 类似的功能:
//Reachability detection
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case AFNetworkReachabilityStatusReachableViaWWAN: {
[self LoadNoInternetView:NO];
break;
}
case AFNetworkReachabilityStatusReachableViaWiFi: {
[self LoadNoInternetView:NO];
break;
}
case AFNetworkReachabilityStatusNotReachable: {
break;
}
default: {
break;
}
}
}];
Run Code Online (Sandbox Code Playgroud)
我目前正在使用监听器来了解网络状态的变化
let net = NetworkReachabilityManager()
net?.startListening()
Run Code Online (Sandbox Code Playgroud)
有人可以描述如何支持这些用例吗?
我想设计一个用于设置出生日期的 UI。为此,我选择UIDatePickerView
. 现在我想将日期限制在 01-01-1990 和当前日期之间。它不应显示未来日期和过去日期。目前我正在使用以下代码:
NSDateComponents *components=[[NSDateComponents alloc] init];
[components setYear:1900];
pickerView.datePicker.minimumDate = [[NSCalendar currentCalendar] dateFromComponents:components];
pickerView.datePicker.maximumDate=[NSDate date]
Run Code Online (Sandbox Code Playgroud)
它限制了日期,但它允许用户滚动到未来日期和过去日期。我怎样才能隐藏或避免它们?
我可以在 iPad 上的通讯录应用程序中看到该功能。要查看联系人 --> 按顶部的“+”符号,然后按添加生日按钮。
我正在使用FBSDKCoreKit(4.12.0)FBSDKLoginKit(4.12.0)我首先得到屏幕1
这种方法永远不会被调用.
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email",@"public_profile"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
//never called
}];
Run Code Online (Sandbox Code Playgroud)
得到这个警告
Warning: Attempt to present <FBSDKContainerViewController: 0x16570810> on <ViewController: 0x16528870> whose view is not in the window hierarchy!
Run Code Online (Sandbox Code Playgroud)
然后我按下确定按钮我得到空白页面而不移动到任何其他页面
我使用的Plist文件是
对于Transpost安全
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
Query schems
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth</string>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string> …
Run Code Online (Sandbox Code Playgroud) Swizzling 不执行动态方法交换。这是我使用的代码。我听说这是一个解决方案,其中依赖注入无法在 xcode 7 中的 XCTest 中执行。您能否通过示例解释一下 Swizzling over DI(Dependency)?
#import "TNUserDetail+Swizzle.h"
#import <objc/runtime.h>
@implementation TNUserDetail (Swizzle)
+ (void) swizzleInstanceSelector:(SEL)originalSelector
withNewSelector:(SEL)newSelector
{
Method originalMethod = class_getClassMethod(self, originalSelector);
Method newMethod = class_getClassMethod(self, newSelector);
BOOL methodAdded = class_addMethod([self class],
originalSelector,
method_getImplementation(newMethod),
method_getTypeEncoding(newMethod));
if (methodAdded) {
class_replaceMethod([self class],
newSelector,
method_getImplementation(originalMethod),
method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, newMethod);
}
}
+(BOOL)isSignUpSwizzle {
return sighUp;
}
Test
_____
@implementation TNSettingsViewControllerTests
- (void)setUp {
[super setUp];
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
self.settingVC = [sb instantiateViewControllerWithIdentifier:@"TNSettingsViewController"];
[self.settingVC …
Run Code Online (Sandbox Code Playgroud) ios ×3
objective-c ×3
alamofire ×1
ios9 ×1
reachability ×1
swift ×1
swizzle ×1
uidatepicker ×1