我知道测试API的响应时间基本上是由服务器或后端端完成的,但是因为我正在为一个应用程序工作,我还需要检查来自iOS End的api响应时间.
我怎样才能做到这一点 ?我读了几个链接,它说使用计时器启动和计时器结束,然后通过endTime - startTime找到响应时间, 但这似乎不方便.
我想使用Xcode(即使XCTest在那里).
这是我的API之一(我在ApiManager类的单独类中编写了所有Web服务使用方法):
LoginVC:
//Call Webservice
let apiManager = ApiManager()
apiManager.delegate = self
apiManager.getUserInfoAPI()
Run Code Online (Sandbox Code Playgroud)
ApiManager:
func getUserInfoAPI() {
//Header
let headers = [
"Accept" : "application/json",
"Content-Type" : "application/json",
]
//Call Web API using Alamofire library
AlamoFireSharedManagerInit()
Alamofire.request(HCConstants.URL, method: .post, parameters: nil, encoding: JSONEncoding.default, headers: headers).responseJSON { response in
do{
//Checking For Error
if let error = response.result.error {
//Stop AcitivityIndicator
self.hideHud()
//Call failure delegate method
//print(error)
self.delegate?.APIFailureResponse(HCConstants.EXCEPTION_MESSAGES.SERVICE_FAILURE)
return
} …Run Code Online (Sandbox Code Playgroud) 在watchOS 4.0(Xcode 9.0 beta 6)中执行后台任务时,我收到类似于下面的错误消息.它们似乎没有引起任何问题,但我不确定.有没有人知道是什么导致这些错误被记录,如果有修复或方法来抑制它们?
2017年8月24日09:03:40.130009-0400 cfanow关注应用信息[6906:377766] [bg_app_refresh] - [WKRefreshBackgroundTask cleanupStorage] _block_invoke:213:错误试图到达文件:///用户/ justindomnitz /库/开发/ CoreSimulator /设备/ 264AA014-FD6C-426A-88DF-64E502393BAF /数据/容器/数据/ PluginKitPlugin/107681EE-B30E-49CD-9416-8F030D1CA0BF /库/ com.apple.watchkit/bktasksnapshot_(空):错误域= NSCocoaErrorDomain代码= 260"无法打开文件"bktasksnapshot_(null)",因为没有这样的文件." 的UserInfo = {NSURL =文件:///用户/ justindomnitz /库/开发商/ CoreSimulator /设备/ 264AA014-FD6C-426A-88DF-64E502393BAF /数据/容器/数据/ PluginKitPlugin/107681EE-B30E-49CD-9416-8F030D1CA0BF /库/ com.apple.watchkit/bktasksnapshot_(空),NSFilePath = /用户/ justindomnitz /库/开发商/ CoreSimulator /设备/ 264AA014-FD6C-426A-88DF-64E502393BAF /数据/容器/数据/ PluginKitPlugin/107681EE-B30E- 49CD-9416-8F030D1CA0BF /库/ com.apple.watchkit/bktasksnapshot_(空),NSUnderlyingError = 0x79f3f3c0 {错误域= NSPOSIXErrorDomain代码= 2 "没有这样的文件或目录"}}
static func saveContext (context: NSManagedObjectContext = getContext()) {
if context.hasChanges {
do {
try context.save()
} catch let nserror as NSError {
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
}
}
}
Run Code Online (Sandbox Code Playgroud)
(我把它放在保存 CoreData 上下文上)
当我抛出 fatalError 时,Xcode 本身每次都会崩溃,我必须再次打开它。
也许有人知道如何解决它或什么?
我正在尝试使用文件夹引用模式将许多 Objective-C 文件添加到我的 Swift 项目中,这意味着当我将文件拖放到项目中时,我选择“创建文件夹引用”。
这是因为我所有的 obj-c 文件都使用#include "/folder/folder/folder/"example. 这些文件是用j2objc生成的项目生成的。
现在我的问题是当我想要#import或Xcode 中的#include某些.h文件myproject-Bridging-Header.h找不到头文件时。我用#import "/folder/folder/folder/"类似生成的文件,但没有机会。
我$(PROJECT_DIR)/在构建设置 - 搜索标头路径中添加,但它确实需要完全像$(PROJECT_DIR)/folder/folder/folder/. 有什么方法可以设置主文件夹和 Xcode 查找子文件夹吗?或者我需要单独写每个路径?
例如,当用户同时按下数字表冠和侧面按钮(又名截屏)时,本机锻炼应用程序和 Sportstracker 能够暂停锻炼。
我需要这样的东西,但我在文档或网上其他地方找不到任何有关它的信息。对于 iOS,有“notificationUIApplicationUserDidTakeScreenshot”,但这在 watchOS 上不起作用。
有人知道怎么做吗?它是公开可用的还是私有 API?是我看起来不够好吗?
我正在使用UIVideoEditorController,但是成功委托方法为我调用了两次。但是,所有传递的对象的所有指针都告诉它发送完全相同的数据。
let editor = UIVideoEditorController()
editor.videoMaximumDuration = 10.0
editor.videoQuality = .typeIFrame1280x720
editor.delegate = self
editor.videoPath = // some path goes here
self.present(editor, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
然后,以下方法将“ here”打印两次。
func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
print("here")
self.dismiss(animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud) 我一直在研究如何使用 venmo 深度链接方案,并尝试根据用户的用户名打开用户的帐户。我在互联网上查找了所有内容,最接近的是这篇博客文章。博客文章中的人非常接近实现我想要的目标,但我仍然无法弄清楚。我尝试多次更改“venmo://users”,试图用用户名打开个人资料,但没有任何效果。我怎样才能做到这一点?
先感谢您
我正在尝试使用所需的便利的可失败初始化程序。这是我正在使用的代码:
public init(authState: OIDAuthState, config: [String: String], accessibility: CFString = kSecAttrAccessibleWhenUnlockedThisDeviceOnly) throws {
self.authState = authState
self.config = config
self.accessibility = accessibility
super.init()
KeycloakAuth.configuration = config
}
public required convenience init?(coder aDecoder: NSCoder) {
try? self.init(authState: aDecoder.decodeObject(forKey: "authState") as! OIDAuthState,
config: aDecoder.decodeObject(forKey: "config") as! [String: String],
accessibility: aDecoder.decodeObject(forKey: "accessibility") as! CFString)
}
Run Code Online (Sandbox Code Playgroud)
'self' used before 'self.init' call我在线路上收到错误public required...,并且线路上再次出现相同的错误try? self.init(...。
我查看了 Stack Overflow 上的其他一些相关问题。即这些:
我是蒸汽的新手,我刚刚安装在 MacOS 上,我在构建它时遇到以下错误。有谁知道如何修理它?我已经搜索过,但提到的大多数解决方案都是针对 iOS 而不是 MacOS。
While building module 'Darwin' imported from /Users/imac1/ROOT/Vapor/Hello/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include/c_nio_http_parser.h:35:
In file included from <module-includes>:357:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/ncurses.h:141:
/opt/local/include/unctrl.h:60:63: error: unknown type name 'SCREEN'
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
^
/opt/local/include/unctrl.h:60:53: error: function cannot return function type 'char *(int *, chtype)' (aka 'char *(int *, unsigned int)')
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
^
/opt/local/include/unctrl.h:60:54: error: a parameter list without types is only allowed in a function definition
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype); …Run Code Online (Sandbox Code Playgroud) 我正在尝试向新 Xcode 15 字符串目录(又名 xcstrings)中的字符串添加换行符。我什么也没想,就在\n想要换行的地方添加了平常的内容。
但在我的 SwiftUI 视图中,我可以看到实际转义的内容\n,并且文本不会换行。因此,文本“lorem ipsum\ndolor”将作为“lorem ipsum\ndolor”呈现给用户。
如何在不使用目录中的多个独立字符串的情况下创建带有有意换行符的文本?
swift ×8
ios ×3
watchkit ×2
xcode ×2
core-data ×1
deep-linking ×1
j2objc ×1
localization ×1
macos ×1
objective-c ×1
performance ×1
response ×1
screenshot ×1
swift3 ×1
swift5 ×1
vapor ×1
venmo ×1
watchos-4 ×1
xcode15 ×1
xcstrings ×1