小编Sam*_*Sam的帖子

Xcode:Alamofire获得String响应

我是IOS开发的新手,目前正在与Alamofire学习网络

我正在尝试登录...每当凭据正确时,.php文件返回一个json,我可以Alamofire通过以下代码获取该json :

    Alamofire.request(loginUrl, method: .post, parameters: parameters).responseJSON { (response:DataResponse<Any>) in
        print("String:\(response.result.value)")
        switch(response.result) {
        case .success(_):
            if let data = response.result.value{
                print(self.loginUrl)
                print(data)
            }

        case .failure(_):

            print(self.loginUrl)
            print("failed")
            print("Error message:\(response.result.error)")
            break

        }
    }
Run Code Online (Sandbox Code Playgroud)

现在......当凭证错误时,.php不会给json ..而且它返回一个字符串..例如"wrong_password"或"userLocked"等...我怎样才能获得String响应通过Alamofire?

xcode alamofire

9
推荐指数
1
解决办法
1万
查看次数

React Native:编译时显示运行时错误(Typescript)

TypeScript在我的react-native项目中使用,它工作正常。我遇到的唯一问题是,IDE 向我显示了错误和所有内容。但即使有一些打字稿错误,我仍然能够运行我的项目。例如,如果我有一个打字稿错误

 type something = 'abc'
Run Code Online (Sandbox Code Playgroud)
const fn(arg: something){ }
fn('somethingelse')
Run Code Online (Sandbox Code Playgroud)

IDE 将显示somethingelse未分配给abc. 但是当我重新加载应用程序/捆绑包时。它仍然编译。我添加了一些我的打字稿配置文件

tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "app",
    "target": "es2018",
    "lib": ["dom", "dom.iterable", "esnext"],
    "jsx": "preserve",
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "allowUnreachableCode": false,
    "declaration": false,
    "downlevelIteration": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "importHelpers": false,
    "isolatedModules": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noLib": false,
    "noUnusedParameters": true,
    "noUnusedLocals": true,
    "pretty": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "removeComments": true, …
Run Code Online (Sandbox Code Playgroud)

typescript react-native

5
推荐指数
0
解决办法
293
查看次数

标签 统计

alamofire ×1

react-native ×1

typescript ×1

xcode ×1