我在以下回溯中遇到了很多崩溃,但我找不到原因。
根据 Apple -[NSObject(NSObject)doesNotRecognizeSelector:]当一个新对象被分配到先前被释放的对象占用的内存中时发生。
注意:向先前释放的对象发送消息可能会引发 NSInvalidArgumentException 而不是由于内存访问冲突而导致程序崩溃。当在先前被释放的对象占用的内存中分配新对象时,就会发生这种情况。如果您的应用程序由于未捕获的 NSInvalidArgumentException(在异常回溯中查找 -[NSObject(NSObject) doesNotRecognizeSelector:])而崩溃,请考虑使用 Zombies 工具分析您的应用程序以消除不正确的内存管理是原因的可能性。
https://developer.apple.com/library/archive/technotes/tn2151/_index.html
但是回溯的其余部分是怎么回事,尤其是-[UIUndoGestureInteraction didMoveToView:]事情?
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x1ae45498c __exceptionPreprocess + 220 (NSException.m:199)
1 libobjc.A.dylib 0x1ae17d0a4 objc_exception_throw + 56 (objc-exception.mm:565)
2 CoreFoundation 0x1ae35843c -[NSObject(NSObject) doesNotRecognizeSelector:] + 140 (NSObject.m:144)
3 UIKitCore 0x1b24902a8 -[UIResponder doesNotRecognizeSelector:] + 296 (UIResponder.m:659)
4 CoreFoundation 0x1ae458e08 ___forwarding___ + 1324 (NSForwarding.m:3325)
5 CoreFoundation 0x1ae45abec _CF_forwarding_prep_0 …Run Code Online (Sandbox Code Playgroud) 在这篇文章之后,我尝试在我的消息应用程序中实现共享表建议。
我已INSendMessageIntent在我的共享扩展的info.plist.
它甚至出现在“支持的意图”下的目标中。
但每次我捐赠时都会INSendMessageIntent失败,说不INSendMessageIntent支持。
错误域=IntentsErrorDomain代码=1901“此扩展不支持捐赠意图'INSendMessageIntent'。请确保您通过在其Info.plist中包含NSUserActivityTypes键来声明您的应用程序支持的意图,或者您的应用程序包含一个Intents扩展支持这一意图。”
// Create an INSendMessageIntent to donate an intent for a conversation with Juan Chavez.
let groupName = INSpeakableString(spokenPhrase: "Juan Chavez")
let sendMessageIntent = INSendMessageIntent(recipients: nil,
content: nil,
speakableGroupName: groupName,
conversationIdentifier: "sampleConversationIdentifier",
serviceName: nil,
sender: nil)
// Add the user's avatar to the intent.
let image = INImage(named: "Juan Chavez")
sendMessageIntent.setImage(image, forParameterNamed: \.speakableGroupName)
// Donate the intent.
let interaction = INInteraction(intent: sendMessageIntent, response: nil) …Run Code Online (Sandbox Code Playgroud) 我正在尝试将以下curl请求Swagger转换为URLRequest:
curl -X GET --header 'Accept: application/json'
--header 'Authorization: key ttn-account-v2.<app-key>'
'https://<app-id>.data.thethingsnetwork.org/api/v2/query'
Run Code Online (Sandbox Code Playgroud)
URL和标题设置正确。我仍然收到响应:401-未经授权。
let key = "ttn-account-v2.<app-key>"
let url = URL(string: "https://<app-id>.data.thethingsnetwork.org/api/v2/query")
var request = URLRequest(url: url!)
request.httpMethod = "GET"
request.addValue("application/json", forHTTPHeaderField: "Accept")
request.addValue("key \(key)", forHTTPHeaderField: "Authorization")
let task = URLSession.shared.dataTask(with: url!) { data, response, error in
guard error == nil else {
print(error!)
return
}
guard let data = data else {
print("Data is empty")
return
}
let json = try! JSONSerialization.jsonObject(with: data, options: [])
print(json)
}
task.resume()
Run Code Online (Sandbox Code Playgroud)
我想念什么吗?