我在 iOS 10 中使用 CXCallObserver 更改了 CTCallCenter。
这是我的代码:
#import <CallKit/CXCallObserver.h>
#import <CallKit/CXCall.h>
-(void)viewDidLoad {
CXCallObserver *callObserver = [[CXCallObserver alloc] init];
[callObserver setDelegate:self queue:nil];
... ...
}
- (void)callObserver:(CXCallObserver *)callObserver callChanged:(CXCall *)call {
if (call.hasConnected) {
NSLog(@"********** voice call connected **********/n");
} else if(call.hasEnded) {
NSLog(@"********** voice call disconnected **********/n");
}
}
Run Code Online (Sandbox Code Playgroud)
但是我无法收到语音呼叫事件,并且收到了如下警告:
Sending 'HomeViewController *const __strong' to parameter of incompatible type 'id<CXCallObserverDelegate> _Nullable
Run Code Online (Sandbox Code Playgroud)
请帮我。
我正在尝试将我的快速字典转换为Json字符串但是通过说出来会变得奇怪
由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'JSON写入的无效类型(_SwiftValue)'
我的代码:
let jsonObject: [String: AnyObject] = [
"firstname": "aaa",
"lastname": "sss",
"email": "my_email",
"nickname": "ddd",
"password": "123",
"username": "qqq"
]
do {
let jsonData = try JSONSerialization.data(withJSONObject: jsonObject, options: .prettyPrinted)
// here "jsonData" is the dictionary encoded in JSON data
let decoded = try JSONSerialization.jsonObject(with: jsonData, options: [])
// here "decoded" is of type `Any`, decoded from JSON data
// you can now cast it with the right type
if let dictFromJSON = decoded as? [String:String] {
// …Run Code Online (Sandbox Code Playgroud) 现在我正在尝试实施Google登录.我跟着这样说:https: //developers.google.com/identity/sign-in/ios/sign-in?ver = swift
但我在AppDelegate.swift中遇到错误:
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate
....
Run Code Online (Sandbox Code Playgroud)
错误:
类型'AppDelegate'不符合协议'GIDSignInDelegate'
帮我.
我有一个快速的2.2项目.现在我将它升级到Swift 3.0但我有一些错误.
open var gridClippingRect: CGRect
{
var contentRect = viewPortHandler?.contentRect ?? CGRect.zero
contentRect.insetInPlace(dx: 0.0, dy: -(self.axis?.gridLineWidth ?? 0.0) / 2.0)
return contentRect
}
Run Code Online (Sandbox Code Playgroud)
错误:'CGRect'类型的值没有成员'insetInPlace'
如何解决这个错误?