0

私は iOS が初めてで、AWS は 100% の初心者です。ファイルをアップロードする必要があるアプリを構築しています。CocoaPods を介して Amazon SDK をダウンロードし、ブリッジング ヘッダーを使用して Swift で動作させました。

これが私のヘッダーです:

#ifndef ObjC_Bridging_Header_h
#define ObjC_Bridging_Header_h

#import "AWSCore.h"
#import "AWSS3.h"
#import "AWSDynamoDB.h"
#import "AWSSQS.h"
#import "AWSSNS.h"
#import "AWSCognito.h"

#endif /* ObjC_Bridging_Header_h */

ビルド設定でそのファイルを指定して、コンパイラにそのファイルがどこにあるかを伝えました。

次に、このコードを使用して AppDelegate.swift で SDK を構成しようとしました。

var window: UIWindow?
let cognitoAccountId = "I'm not going to post this"
let cognitoIdentityPoolId = "I'm not going to post this"
let cognitoUnauthRoleArn = "I'm not going to post this"
let cognitoAuthRoleArn = "I'm not going to post this"

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    let credentialsProvider = AWSCognitoCredentialsProvider.credentialsWithRegionType(
        AWSRegionType.USEast1,
        accountId: cognitoAccountId,
        identityPoolId: cognitoIdentityPoolId,
        unauthRoleArn: cognitoUnauthRoleArn,
        authRoleArn: cognitoAuthRoleArn)
    let defaultServiceConfiguration = AWSServiceConfiguration(
        region: AWSRegionType.USEast1,
        credentialsProvider: credentialsProvider)
    AWSServiceManager.defaultServiceManager().setDefaultServiceConfiguration(defaultServiceConfiguration)


    return true
}

(そして、はい、すべての ID 文字列などを入力しました。投稿したくなかっただけです)

この最後の行を除いて、すべてが機能します。 AWSServiceManager.defaultServiceManager().setDefaultServiceConfiguration(defaultServiceConfiguration)

それは言ってエラー: "Value of type 'AWSServiceManager' has no member 'setDefaultServiceConfiguration'"

この行を除いてすべてが機能しているのはなぜですか? どうしたの?

4

1 に答える 1

0

AWSServiceManagerには のセッターがありませんdefaultServiceConfiguration

代わりに使用する必要があります

AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = defaultServiceConfiguration

これでうまくいきます。

于 2016-01-17T06:30:51.287 に答える